### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java,v retrieving revision 1.84 diff -u -r1.84 HierarchyResolver.java --- model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 27 May 2008 23:40:22 -0000 1.84 +++ model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 16 Jun 2008 11:13:01 -0000 @@ -816,6 +816,21 @@ this.focusType = this.lookupEnvironment.getCachedType(compoundName); if (this.focusType == null) { this.focusType = this.lookupEnvironment.askForType(compoundName); + if (this.focusType == null) { + int length = compoundName.length; + char[] typeName = compoundName[length-1]; + int firstDollar = CharOperation.indexOf('$', typeName); + if (firstDollar != -1) { + compoundName[length-1] = CharOperation.subarray(typeName, 0, firstDollar); + this.focusType = this.lookupEnvironment.askForType(compoundName); + if (this.focusType != null) { + char[][] memberTypeNames = CharOperation.splitOn('$', typeName, firstDollar+1, typeName.length); + for (int i = 0; i < memberTypeNames.length; i++) { + this.focusType = this.focusType.getMemberType(memberTypeNames[i]); + } + } + } + } } return this.focusType; } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v retrieving revision 1.87 diff -u -r1.87 TypeHierarchyTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 27 May 2008 23:59:54 -0000 1.87 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 16 Jun 2008 11:13:02 -0000 @@ -1712,6 +1712,51 @@ deleteProject("P"); } } +/* + * Ensures that a potential subtype in a dependent project doesn't appear in the hierarchy + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=169678 ) + */ +public void testPotentialSubtypeInDependentProject() throws Exception { + try { + createJavaProject("P1", new String[] {""}, new String[] {"JCL_LIB"}, ""); + createFolder("/P1/p1"); + createFile( + "/P1/p1/X169678.java", + "package p1;\n" + + "public class X169678 {\n" + + " public static class Y169678 {\n" + + " }\n" + + "}" + ); + createFile( + "/P1/p1/Z169678.java", + "package p1;\n" + + "public class Z169678 extends X169678.Y169678 {\n" + + "}" + ); + createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] {"/P1"}, ""); + createFolder("/P2/p2"); + createFile( + "/P2/p2/Y169678.java", + "package p2;\n" + + "public class Y169678 {\n" + + "}\n" + + "class Z169678 extends Y169678 {\n" + + "}" + ); + IType type = getCompilationUnit("/P1/p1/X169678.java").getType("X169678").getType("Y169678"); + ITypeHierarchy hierarchy = type.newTypeHierarchy(null); + IType[] allTypes = hierarchy.getAllTypes(); + assertSortedElementsEqual( + "Unexpected types in hierarchy", + "Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + + "Y169678 [in X169678 [in X169678.java [in p1 [in [in P1]]]]]\n" + + "Z169678 [in Z169678.java [in p1 [in [in P1]]]]", + allTypes); + } finally { + deleteProjects(new String[] {"P1", "P2"}); + } +} /** * Ensures that a potential subtype that is not in the classpth is handle correctly. * (Regression test for PR #1G4GL9R)