View | Details | Raw Unified | Return to bug 340029
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-11 / +23 lines)
Lines 3310-3315 Link Here
3310
      }
3310
      }
3311
      enumConstant.initialization = allocationExpression;
3311
      enumConstant.initialization = allocationExpression;
3312
   }
3312
   }
3313
   // initialize the starting position of the allocation expression
3314
   enumConstant.initialization.sourceStart = enumConstant.declarationSourceStart;
3313
3315
3314
   // recovery
3316
   // recovery
3315
   if (this.currentElement != null) {
3317
   if (this.currentElement != null) {
Lines 3377-3398 Link Here
3377
	final FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr];
3379
	final FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr];
3378
	fieldDeclaration.declarationEnd = endOfEnumConstant;
3380
	fieldDeclaration.declarationEnd = endOfEnumConstant;
3379
	fieldDeclaration.declarationSourceEnd = endOfEnumConstant;
3381
	fieldDeclaration.declarationSourceEnd = endOfEnumConstant;
3382
	// initialize the starting position of the allocation expression
3383
	ASTNode initialization = fieldDeclaration.initialization;
3384
	if (initialization != null) {
3385
		initialization.sourceEnd = endOfEnumConstant;
3386
	}
3380
}
3387
}
3381
protected void consumeEnumConstants() {
3388
protected void consumeEnumConstants() {
3382
	concatNodeLists();
3389
	concatNodeLists();
3383
}
3390
}
3384
protected void consumeEnumConstantWithClassBody() {
3391
protected void consumeEnumConstantWithClassBody() {
3385
   dispatchDeclarationInto(this.astLengthStack[this.astLengthPtr--]);
3392
	dispatchDeclarationInto(this.astLengthStack[this.astLengthPtr--]);
3386
   TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr--]; // pop type
3393
	TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr--]; // pop type
3387
   this.astLengthPtr--;
3394
	this.astLengthPtr--;
3388
   anonymousType.bodyEnd = this.endPosition;
3395
	anonymousType.bodyEnd = this.endPosition;
3389
   anonymousType.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3396
	anonymousType.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3390
   final FieldDeclaration fieldDeclaration = ((FieldDeclaration) this.astStack[this.astPtr]);
3397
	final FieldDeclaration fieldDeclaration = ((FieldDeclaration) this.astStack[this.astPtr]);
3391
   fieldDeclaration.declarationEnd = this.endStatementPosition;
3398
	fieldDeclaration.declarationEnd = this.endStatementPosition;
3392
   fieldDeclaration.declarationSourceEnd = anonymousType.declarationSourceEnd;
3399
	int declarationSourceEnd = anonymousType.declarationSourceEnd;
3393
   this.intPtr --; // remove end position of the arguments
3400
	fieldDeclaration.declarationSourceEnd = declarationSourceEnd;
3394
   this.variablesCounter[this.nestedType] = 0;
3401
	this.intPtr --; // remove end position of the arguments
3395
   this.nestedType--;
3402
	this.variablesCounter[this.nestedType] = 0;
3403
	this.nestedType--;
3404
	ASTNode initialization = fieldDeclaration.initialization;
3405
	if (initialization != null) {
3406
		initialization.sourceEnd = declarationSourceEnd;
3407
	}
3396
}
3408
}
3397
protected void consumeEnumDeclaration() {
3409
protected void consumeEnumDeclaration() {
3398
	// EnumDeclaration ::= EnumHeader ClassHeaderImplementsopt EnumBody
3410
	// EnumDeclaration ::= EnumHeader ClassHeaderImplementsopt EnumBody
(-)src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java (-1 / +24 lines)
Lines 33-39 Link Here
33
	// All specified tests which does not belong to the class are skipped...
33
	// All specified tests which does not belong to the class are skipped...
34
	static {
34
	static {
35
//		TESTS_NAMES = new String[] { "test000" };
35
//		TESTS_NAMES = new String[] { "test000" };
36
//		TESTS_NUMBERS = new int[] { 182 };
36
//		TESTS_NUMBERS = new int[] { 185 };
37
//		TESTS_RANGE = new int[] { 21, 50 };
37
//		TESTS_RANGE = new int[] { 21, 50 };
38
	}
38
	}
39
	public static Test suite() {
39
	public static Test suite() {
Lines 6664-6667 Link Here
6664
		customOptions,
6664
		customOptions,
6665
		null);
6665
		null);
6666
}
6666
}
6667
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=
6668
public void test185() {
6669
	this.runNegativeTest(
6670
		new String[] {
6671
			"X.java",
6672
			"public enum X {\n" + 
6673
			"  A, B;\n" + 
6674
			"  private X() throws Exception {\n" + 
6675
			"  }\n" + 
6676
			"}",
6677
		},
6678
		"----------\n" + 
6679
		"1. ERROR in X.java (at line 2)\n" + 
6680
		"	A, B;\n" + 
6681
		"	^\n" + 
6682
		"Unhandled exception type Exception\n" + 
6683
		"----------\n" + 
6684
		"2. ERROR in X.java (at line 2)\n" + 
6685
		"	A, B;\n" + 
6686
		"	   ^\n" + 
6687
		"Unhandled exception type Exception\n" + 
6688
		"----------\n");
6689
}
6667
}
6690
}

Return to bug 340029