Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth2019-01-11 13:49:52 -0500
committerJay Arthanareeswaran2019-05-20 06:23:12 -0400
commit749a725533763687a087f7127f05425654a6ac4d (patch)
tree42572504b2c6785876032713f2cd164e64c91a72
parent554ecdaf2404cd4cd7c4c1107e2e5850e97845e3 (diff)
downloadeclipse.jdt.core-749a725533763687a087f7127f05425654a6ac4d.tar.gz
eclipse.jdt.core-749a725533763687a087f7127f05425654a6ac4d.tar.xz
eclipse.jdt.core-749a725533763687a087f7127f05425654a6ac4d.zip
Bug 543266 Allow comments in enum declaration
Change-Id: I9f19fc03dd15144e7bd408361e0886164fdc0c44 Signed-off-by: Kenneth <kenneth@kean.nu>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java57
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java1
2 files changed, 58 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
index 9c3dbb179d..827e9f1bf6 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
@@ -2428,6 +2428,63 @@ public void test120902() throws CoreException {
}
}
+public void test543266() throws CoreException {
+ try {
+ String source =
+ "/**\r\n" +
+ " * enum A\r\n" +
+ " */\r\n" +
+ " public /** V1 */ enum /** V2 */ A /** V3 */ {\r\n" +
+ " /** A */\r\n" +
+ " a /**/, /**/ //\r\n" +
+ " /** B */\r\n" +
+ " b,\r\n" +
+ " /** C */\r\n" +
+ " /*\r\n" +
+ " * \r\n" +
+ " */\r\n" +
+ " /** Real C */\r\n" +
+ " c\r\n" +
+ " }";
+ createFile("/P/src/X.java", source);
+ final ICompilationUnit compilationUnit = getCompilationUnit("/P/src/X.java");
+
+ IType type = compilationUnit.getType("A");
+ final ISourceRange javadocRangeClass = type.getJavadocRange();
+ final int startClass = javadocRangeClass.getOffset();
+ final int endClass = javadocRangeClass.getLength() + startClass - 1;
+ String javadocSourceClass = source.substring(startClass, endClass);
+ assertTrue("Wrong javadoc", javadocSourceClass.indexOf("enum A") != -1);
+
+ IJavaElement[] children = type.getChildren();
+ for(IJavaElement child : children) {
+ final ISourceRange javadocRange = ((IMember) child).getJavadocRange();
+ final String elementName = child.getElementName();
+
+ if("a".equals(elementName)) {
+ final int start = javadocRange.getOffset();
+ final int end = javadocRange.getLength() + start - 1;
+ String javadocSource = source.substring(start, end);
+ assertTrue("Wrong javadoc", javadocSource.indexOf("A") != -1);
+ }
+ else if("b".equals(elementName)) {
+ final int start = javadocRange.getOffset();
+ final int end = javadocRange.getLength() + start - 1;
+ String javadocSource = source.substring(start, end);
+ assertTrue("Wrong javadoc", javadocSource.indexOf("B") != -1);
+ }
+ else if("c".equals(elementName)) {
+ final int start = javadocRange.getOffset();
+ final int end = javadocRange.getLength() + start - 1;
+ String javadocSource = source.substring(start, end);
+ assertTrue("Wrong javadoc", javadocSource.indexOf("Real C") != -1);
+ }
+ }
+ } finally {
+ deleteFile("/P/src/X.java");
+ }
+}
+
public void testApplyEdit() throws CoreException {
try {
String source =
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java
index 6608021444..36d1011654 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java
@@ -329,6 +329,7 @@ public ISourceRange getJavadocRange() throws JavaModelException {
break;
case ITerminalSymbols.TokenNameCOMMENT_LINE :
case ITerminalSymbols.TokenNameCOMMENT_BLOCK :
+ case ITerminalSymbols.TokenNameCOMMA:
terminal= scanner.getNextToken();
continue loop;
default :

Back to the top