Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2020-06-30 06:29:30 +0000
committerJay Arthanareeswaran2020-06-30 07:49:06 +0000
commitd6fdfb48c98dc3f94509f41f07432086fff67206 (patch)
tree77e30ae04bee6c47648f41464b160c5cdc482585
parentca5e66c98d346b28315c9c551d1592955ec12175 (diff)
downloadeclipse.jdt.core-d6fdfb48c98dc3f94509f41f07432086fff67206.tar.gz
eclipse.jdt.core-d6fdfb48c98dc3f94509f41f07432086fff67206.tar.xz
eclipse.jdt.core-d6fdfb48c98dc3f94509f41f07432086fff67206.zip
Bug 564729 - [14] Records- Model representation of Record should excludeI20200630-1800
implicit constructors Change-Id: I26008d29f42084e813e334516d5fd3fb9947fd5f Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RecordsElementTests.java30
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java2
2 files changed, 32 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RecordsElementTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RecordsElementTests.java
index e8619bbe14..99ae94eff9 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RecordsElementTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RecordsElementTests.java
@@ -18,6 +18,7 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
@@ -116,6 +117,35 @@ public class RecordsElementTests extends AbstractJavaModelTests {
comp = recordComponents[1];
assertEquals("type should be a record component", IJavaElement.FIELD, comp.getElementType());
assertEquals("incorrect element name", "x2", comp.getElementName());
+ IMethod[] methods = types[0].getMethods();
+ assertNotNull("should not be null", methods);
+ assertEquals("Incorret no of methods", 1, methods.length);
+ IMethod iMethod = methods[0];
+ assertEquals("type should be a record component", IJavaElement.METHOD, iMethod.getElementType());
+ assertEquals("incorrect element name", "Point", iMethod.getElementName());
+ String[] parameterNames = iMethod.getParameterNames();
+ assertEquals("parameters not matching", 2, parameterNames.length);
+ }
+ finally {
+ deleteProject("RecordsElement");
+ }
+ }
+ public void test004() throws Exception {
+ try {
+ IJavaProject project = createJavaProject("RecordsElement");
+ project.open(null);
+ String fileContent = "@SuppressWarnings(\"preview\")\n" +
+ "public record Point(int x1, int x2) {\n" +
+ "}\n";
+ createFile( "/RecordsElement/src/X.java", fileContent);
+ ICompilationUnit unit = getCompilationUnit("/RecordsElement/src/X.java");
+ IType[] types = unit.getTypes();
+ assertEquals("Incorret no of types", 1, types.length);
+ assertTrue("type should be a record", types[0].isRecord());
+ assertEquals("type should be a record", IJavaElement.TYPE, types[0].getElementType());
+ IMethod[] methods = types[0].getMethods();
+ assertNotNull("should not be null", methods);
+ assertEquals("Incorret no of methods", 0, methods.length);
}
finally {
deleteProject("RecordsElement");
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java
index c66ba9bab2..b4a6370182 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java
@@ -250,6 +250,8 @@ protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDecl
this.visitIfNeeded(methodDeclaration);
return;
}
+ if ((methodDeclaration.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.IsImplicit) != 0)
+ return;
if (methodDeclaration.isDefaultConstructor()) {
if (this.reportReferenceInfo) {

Back to the top