### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/SelectionRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java,v retrieving revision 1.61 diff -u -r1.61 SelectionRequestor.java --- model/org/eclipse/jdt/internal/core/SelectionRequestor.java 20 Oct 2005 13:26:44 -0000 1.61 +++ model/org/eclipse/jdt/internal/core/SelectionRequestor.java 12 Dec 2005 17:58:33 -0000 @@ -723,7 +723,7 @@ false); // iterate type lookup in each package fragment for (int i = 0, length = pkgs == null ? 0 : pkgs.length; i < length; i++) { - type= this.nameLookup.findType(new String(typeName), pkgs[i], false, acceptFlags); + type= this.nameLookup.findType(new String(typeName), pkgs[i], false, acceptFlags, true/*consider secondary types*/); if (type != null) break; } if (type == null) { @@ -803,7 +803,7 @@ false); // iterate type lookup in each package fragment for (int i = 0, length = pkgs == null ? 0 : pkgs.length; i < length; i++) { - type= this.nameLookup.findType(new String(typeName), pkgs[i], false, acceptFlags); + type= this.nameLookup.findType(new String(typeName), pkgs[i], false, acceptFlags, true/*consider secondary types*/); if (type != null) break; } if (type == null) { Index: model/org/eclipse/jdt/internal/core/NameLookup.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java,v retrieving revision 1.95 diff -u -r1.95 NameLookup.java --- model/org/eclipse/jdt/internal/core/NameLookup.java 5 Dec 2005 15:52:20 -0000 1.95 +++ model/org/eclipse/jdt/internal/core/NameLookup.java 12 Dec 2005 17:58:33 -0000 @@ -579,6 +579,13 @@ * @see #ACCEPT_ENUMS * @see #ACCEPT_ANNOTATIONS */ + public IType findType(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes) { + IType type = findType(name, pkg, partialMatch, acceptFlags); + if (type == null && considerSecondaryTypes) { + type = findSecondaryType(pkg.getElementName(), name, pkg.getJavaProject(), false, null); + } + return type; + } public IType findType(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags) { if (pkg == null) return null; Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v retrieving revision 1.263 diff -u -r1.263 MatchLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 8 Dec 2005 16:25:11 -0000 1.263 +++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 12 Dec 2005 17:58:35 -0000 @@ -1278,7 +1278,7 @@ acceptFlag = NameLookup.ACCEPT_CLASSES; } for (int i = 0, length = pkgs == null ? 0 : pkgs.length; i < length; i++) { - IType type = this.nameLookup.findType(typeName, pkgs[i], false, acceptFlag); + IType type = this.nameLookup.findType(typeName, pkgs[i], false, acceptFlag, true/*consider secondary types*/); if (type != null) return type; } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ResolveTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java,v retrieving revision 1.60 diff -u -r1.60 ResolveTests.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests.java 7 Sep 2005 10:54:55 -0000 1.60 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests.java 12 Dec 2005 17:58:40 -0000 @@ -19,13 +19,11 @@ ICompilationUnit wc = null; WorkingCopyOwner owner = null; +static { +// TESTS_NAMES = new String[] { "testSecondaryTypes" }; +} public static Test suite() { - if (false) { - TestSuite suite = new Suite(ResolveTests.class.getName()); - suite.addTest(new ResolveTests("testLocalNameForClassFile")); - return suite; - } - return new Suite(ResolveTests.class); + return buildTestSuite(ResolveTests.class); } public ResolveTests(String name) { @@ -1620,4 +1618,21 @@ } } } +/** + * Bug 120350: [model] Secondary type not found by code resolve + * @throws JavaModelException + */ +public void testSecondaryTypes() throws JavaModelException { + waitUntilIndexesReady(); + ICompilationUnit cu = getCompilationUnit("Resolve", "src", "b120350", "X.java"); + String str = cu.getSource(); + int start = str.indexOf("Secondary"); + int length = "Secondary".length(); + IJavaElement[] elements = cu.codeSelect(start, length); + assertElementsEqual( + "Unexpected elements", + "Secondary [in Test.java [in b120350 [in src [in Resolve]]]]", + elements + ); +} } Index: workspace/Resolve/src/b120350/X.java =================================================================== RCS file: workspace/Resolve/src/b120350/X.java diff -N workspace/Resolve/src/b120350/X.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Resolve/src/b120350/X.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,1 @@ +public class X extends Secondary {} Index: workspace/Resolve/src/b120350/Test.java =================================================================== RCS file: workspace/Resolve/src/b120350/Test.java diff -N workspace/Resolve/src/b120350/Test.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Resolve/src/b120350/Test.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ +public class Test { +} +class Secondary {}