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

(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-7 / +16 lines)
Lines 3272-3284 Link Here
3272
   enumConstant.modifiers = this.intStack[this.intPtr--];
3272
   enumConstant.modifiers = this.intStack[this.intPtr--];
3273
   enumConstant.declarationSourceStart = enumConstant.modifiersSourceStart;
3273
   enumConstant.declarationSourceStart = enumConstant.modifiersSourceStart;
3274
3274
3275
	// Store secondary info
3276
	if ((enumConstant.bits & ASTNode.IsMemberType) == 0 && (enumConstant.bits & ASTNode.IsLocalType) == 0) {
3277
		if (this.compilationUnit != null && !CharOperation.equals(enumConstant.name, this.compilationUnit.getMainTypeName())) {
3278
			enumConstant.bits |= ASTNode.IsSecondaryType;
3279
		}
3280
	}
3281
3282
	// consume annotations
3275
	// consume annotations
3283
   int length;
3276
   int length;
3284
   if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3277
   if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
Lines 3408-3413 Link Here
3408
	if (enumDeclaration.modifiersSourceStart >= 0) {
3401
	if (enumDeclaration.modifiersSourceStart >= 0) {
3409
		enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart;
3402
		enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart;
3410
	}
3403
	}
3404
3405
	// Store secondary info
3406
	if ((enumDeclaration.bits & ASTNode.IsMemberType) == 0 && (enumDeclaration.bits & ASTNode.IsLocalType) == 0) {
3407
		if (this.compilationUnit != null && !CharOperation.equals(enumDeclaration.name, this.compilationUnit.getMainTypeName())) {
3408
			enumDeclaration.bits |= ASTNode.IsSecondaryType;
3409
		}
3410
	}
3411
3411
	// consume annotations
3412
	// consume annotations
3412
	int length;
3413
	int length;
3413
	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3414
	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
Lines 3487-3492 Link Here
3487
	if (enumDeclaration.modifiersSourceStart >= 0) {
3488
	if (enumDeclaration.modifiersSourceStart >= 0) {
3488
		enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart;
3489
		enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart;
3489
	}
3490
	}
3491
3492
	// Store secondary info
3493
	if ((enumDeclaration.bits & ASTNode.IsMemberType) == 0 && (enumDeclaration.bits & ASTNode.IsLocalType) == 0) {
3494
		if (this.compilationUnit != null && !CharOperation.equals(enumDeclaration.name, this.compilationUnit.getMainTypeName())) {
3495
			enumDeclaration.bits |= ASTNode.IsSecondaryType;
3496
		}
3497
	}
3498
3490
	// consume annotations
3499
	// consume annotations
3491
	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3500
	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3492
		System.arraycopy(
3501
		System.arraycopy(
(-)src/org/eclipse/jdt/core/tests/model/ClassNameTests.java (+36 lines)
Lines 1289-1292 Link Here
1289
		deleteProject("P");
1289
		deleteProject("P");
1290
	}
1290
	}
1291
}
1291
}
1292
1293
/**
1294
 * @bug 306477: Indexer(?) fails to recognise enum as a type
1295
 * @test Ensure that enum secondary type are well indexed
1296
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=306477"
1297
 */
1298
public void testBug306477() throws Exception {
1299
	try {
1300
		// create test case
1301
		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
1302
		createFolder("/P/p");
1303
		createFile(
1304
			"/P/p/Alice.java",
1305
			"package p;\n" + 
1306
			"class Alice {\n" + 
1307
			"	Object j = Bob.CHARLIE;\n" + 
1308
			"}\n"
1309
		);
1310
		createFile(
1311
			"/P/p/Misc.java",
1312
			"package p;\n" + 
1313
			"enum Bob {\n" + 
1314
			"	CHARLIE;\n" + 
1315
			"}\n"
1316
		);
1317
		
1318
		// find secondary enum
1319
		IType type = project.findType("p.Bob", new NullProgressMonitor());
1320
		assertElementEquals("We should have found the secondary enum 'Bob'!",
1321
			"Bob [in Misc.java [in p [in <project root> [in P]]]]",
1322
			type
1323
		);
1324
	} finally {
1325
		deleteProject("P");
1326
	}
1327
}
1292
}
1328
}

Return to bug 306477