### 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.416 diff -u -r1.416 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 23 Feb 2010 14:48:27 -0000 1.416 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 19 Mar 2010 12:42:18 -0000 @@ -3272,13 +3272,6 @@ enumConstant.modifiers = this.intStack[this.intPtr--]; enumConstant.declarationSourceStart = enumConstant.modifiersSourceStart; - // Store secondary info - if ((enumConstant.bits & ASTNode.IsMemberType) == 0 && (enumConstant.bits & ASTNode.IsLocalType) == 0) { - if (this.compilationUnit != null && !CharOperation.equals(enumConstant.name, this.compilationUnit.getMainTypeName())) { - enumConstant.bits |= ASTNode.IsSecondaryType; - } - } - // consume annotations int length; if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { @@ -3408,6 +3401,14 @@ if (enumDeclaration.modifiersSourceStart >= 0) { enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart; } + + // Store secondary info + if ((enumDeclaration.bits & ASTNode.IsMemberType) == 0 && (enumDeclaration.bits & ASTNode.IsLocalType) == 0) { + if (this.compilationUnit != null && !CharOperation.equals(enumDeclaration.name, this.compilationUnit.getMainTypeName())) { + enumDeclaration.bits |= ASTNode.IsSecondaryType; + } + } + // consume annotations int length; if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { @@ -3487,6 +3488,14 @@ if (enumDeclaration.modifiersSourceStart >= 0) { enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart; } + + // Store secondary info + if ((enumDeclaration.bits & ASTNode.IsMemberType) == 0 && (enumDeclaration.bits & ASTNode.IsLocalType) == 0) { + if (this.compilationUnit != null && !CharOperation.equals(enumDeclaration.name, this.compilationUnit.getMainTypeName())) { + enumDeclaration.bits |= ASTNode.IsSecondaryType; + } + } + // consume annotations if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { System.arraycopy( #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ClassNameTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassNameTests.java,v retrieving revision 1.19 diff -u -r1.19 ClassNameTests.java --- src/org/eclipse/jdt/core/tests/model/ClassNameTests.java 15 Feb 2010 20:20:44 -0000 1.19 +++ src/org/eclipse/jdt/core/tests/model/ClassNameTests.java 19 Mar 2010 12:42:21 -0000 @@ -1289,4 +1289,40 @@ deleteProject("P"); } } + +/** + * @bug 306477: Indexer(?) fails to recognise enum as a type + * @test Ensure that enum secondary type are well indexed + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=306477" + */ +public void testBug306477() throws Exception { + try { + // create test case + IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5"); + createFolder("/P/p"); + createFile( + "/P/p/Alice.java", + "package p;\n" + + "class Alice {\n" + + " Object j = Bob.CHARLIE;\n" + + "}\n" + ); + createFile( + "/P/p/Misc.java", + "package p;\n" + + "enum Bob {\n" + + " CHARLIE;\n" + + "}\n" + ); + + // find secondary enum + IType type = project.findType("p.Bob", new NullProgressMonitor()); + assertElementEquals("We should have found the secondary enum 'Bob'!", + "Bob [in Misc.java [in p [in [in P]]]]", + type + ); + } finally { + deleteProject("P"); + } +} }