### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v retrieving revision 1.422.2.15 diff -u -r1.422.2.15 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 14 Mar 2011 18:59:56 -0000 1.422.2.15 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 15 Mar 2011 14:30:28 -0000 @@ -3310,6 +3310,8 @@ } enumConstant.initialization = allocationExpression; } + // initialize the starting position of the allocation expression + enumConstant.initialization.sourceStart = enumConstant.declarationSourceStart; // recovery if (this.currentElement != null) { @@ -3377,22 +3379,32 @@ final FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr]; fieldDeclaration.declarationEnd = endOfEnumConstant; fieldDeclaration.declarationSourceEnd = endOfEnumConstant; + // initialize the starting position of the allocation expression + ASTNode initialization = fieldDeclaration.initialization; + if (initialization != null) { + initialization.sourceEnd = endOfEnumConstant; + } } protected void consumeEnumConstants() { concatNodeLists(); } protected void consumeEnumConstantWithClassBody() { - dispatchDeclarationInto(this.astLengthStack[this.astLengthPtr--]); - TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr--]; // pop type - this.astLengthPtr--; - anonymousType.bodyEnd = this.endPosition; - anonymousType.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); - final FieldDeclaration fieldDeclaration = ((FieldDeclaration) this.astStack[this.astPtr]); - fieldDeclaration.declarationEnd = this.endStatementPosition; - fieldDeclaration.declarationSourceEnd = anonymousType.declarationSourceEnd; - this.intPtr --; // remove end position of the arguments - this.variablesCounter[this.nestedType] = 0; - this.nestedType--; + dispatchDeclarationInto(this.astLengthStack[this.astLengthPtr--]); + TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr--]; // pop type + this.astLengthPtr--; + anonymousType.bodyEnd = this.endPosition; + anonymousType.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); + final FieldDeclaration fieldDeclaration = ((FieldDeclaration) this.astStack[this.astPtr]); + fieldDeclaration.declarationEnd = this.endStatementPosition; + int declarationSourceEnd = anonymousType.declarationSourceEnd; + fieldDeclaration.declarationSourceEnd = declarationSourceEnd; + this.intPtr --; // remove end position of the arguments + this.variablesCounter[this.nestedType] = 0; + this.nestedType--; + ASTNode initialization = fieldDeclaration.initialization; + if (initialization != null) { + initialization.sourceEnd = declarationSourceEnd; + } } protected void consumeEnumDeclaration() { // EnumDeclaration ::= EnumHeader ClassHeaderImplementsopt EnumBody #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java,v retrieving revision 1.155.2.1 diff -u -r1.155.2.1 EnumTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 14 Mar 2011 19:00:21 -0000 1.155.2.1 +++ src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 15 Mar 2011 14:30:29 -0000 @@ -33,7 +33,7 @@ // All specified tests which does not belong to the class are skipped... static { // TESTS_NAMES = new String[] { "test000" }; -// TESTS_NUMBERS = new int[] { 182 }; +// TESTS_NUMBERS = new int[] { 185 }; // TESTS_RANGE = new int[] { 21, 50 }; } public static Test suite() { @@ -6664,4 +6664,27 @@ customOptions, null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id= +public void test185() { + this.runNegativeTest( + new String[] { + "X.java", + "public enum X {\n" + + " A, B;\n" + + " private X() throws Exception {\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " A, B;\n" + + " ^\n" + + "Unhandled exception type Exception\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " A, B;\n" + + " ^\n" + + "Unhandled exception type Exception\n" + + "----------\n"); +} }