Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2020-05-04 08:00:50 +0000
committerJay Arthanareeswaran2020-05-05 16:25:40 +0000
commit5242be46d1960c5063ff459292d90897eccf8a35 (patch)
tree64470ae7471899a366bf90787a9984ef828fe7bc /org.eclipse.jdt.compiler.apt/src
parentf3da8e568a49f24deb97b9ffca636152eaad1255 (diff)
downloadeclipse.jdt.core-5242be46d1960c5063ff459292d90897eccf8a35.tar.gz
eclipse.jdt.core-5242be46d1960c5063ff459292d90897eccf8a35.tar.xz
eclipse.jdt.core-5242be46d1960c5063ff459292d90897eccf8a35.zip
Bug 562760 - [apt] APT annotation changes / JavaElement14 testRecordsI20200505-1800
failure Change-Id: I1e43efc283a87bdebad33d7a453c3fda72249bbe Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.compiler.apt/src')
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/RecordComponentElementImpl.java10
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java13
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java3
3 files changed, 14 insertions, 12 deletions
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/RecordComponentElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/RecordComponentElementImpl.java
index 9be30c625c..16df7c2b69 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/RecordComponentElementImpl.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/RecordComponentElementImpl.java
@@ -20,14 +20,14 @@ import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.RecordComponentElement;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
public class RecordComponentElementImpl extends VariableElementImpl implements RecordComponentElement {
- protected RecordComponentElementImpl(BaseProcessingEnvImpl env, FieldBinding binding) {
+ protected RecordComponentElementImpl(BaseProcessingEnvImpl env, RecordComponentBinding binding) {
super(env, binding);
}
@@ -38,10 +38,10 @@ public class RecordComponentElementImpl extends VariableElementImpl implements R
@Override
public ExecutableElement getAccessor() {
- FieldBinding field = (FieldBinding) this._binding;
- ReferenceBinding binding = field.declaringClass;
+ RecordComponentBinding comp = (RecordComponentBinding) this._binding;
+ ReferenceBinding binding = comp.declaringRecord;
if (binding instanceof SourceTypeBinding) {
- MethodBinding accessor = ((SourceTypeBinding) binding).getRecordComponentAccessor(field.name);
+ MethodBinding accessor = ((SourceTypeBinding) binding).getRecordComponentAccessor(comp.name);
return new ExecutableElementImpl(_env, accessor);
}
return null;
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java
index 1855bbab92..d2dfd2175d 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java
@@ -45,6 +45,7 @@ import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
@@ -165,8 +166,8 @@ public class TypeElementImpl extends ElementImpl implements TypeElement {
}
if (binding.isRecord() && binding instanceof SourceTypeBinding) {
SourceTypeBinding sourceBinding = (SourceTypeBinding) binding;
- for (FieldBinding field : sourceBinding.getImplicitComponentFields()) {
- RecordComponentElement rec = new RecordComponentElementImpl(_env, field);
+ for (RecordComponentBinding comp : sourceBinding.components()) {
+ RecordComponentElement rec = new RecordComponentElementImpl(_env, comp);
enclosed.add(rec);
}
}
@@ -185,11 +186,9 @@ public class TypeElementImpl extends ElementImpl implements TypeElement {
if (_binding instanceof SourceTypeBinding) {
SourceTypeBinding binding = (SourceTypeBinding) _binding;
List<RecordComponentElement> enclosed = new ArrayList<>();
- for (FieldBinding field : binding.fields()) {
- if (!field.isSynthetic()) {
- RecordComponentElement variable = new RecordComponentElementImpl(_env, field);
- enclosed.add(variable);
- }
+ for (RecordComponentBinding comp : binding.components()) {
+ RecordComponentElement variable = new RecordComponentElementImpl(_env, comp);
+ enclosed.add(variable);
}
Collections.sort(enclosed, new SourceLocationComparator());
return Collections.unmodifiableList(enclosed);
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
index 86986a3d9d..9a4c8c23c7 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
@@ -37,6 +37,7 @@ import org.eclipse.jdt.internal.compiler.lookup.AptBinaryLocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.AptSourceLocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
+import org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
@@ -109,6 +110,8 @@ public class VariableElementImpl extends ElementImpl implements VariableElement
return _env.getFactory().newElement(((AptSourceLocalVariableBinding) _binding).methodBinding);
} else if (_binding instanceof AptBinaryLocalVariableBinding) {
return _env.getFactory().newElement(((AptBinaryLocalVariableBinding) _binding).methodBinding);
+ } else if (_binding instanceof RecordComponentBinding) {
+ return _env.getFactory().newElement(((RecordComponentBinding)_binding).declaringRecord);
}
return null;
}

Back to the top