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

(-)model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java (+15 lines)
Lines 816-821 Link Here
816
	this.focusType = this.lookupEnvironment.getCachedType(compoundName);
816
	this.focusType = this.lookupEnvironment.getCachedType(compoundName);
817
	if (this.focusType == null) {
817
	if (this.focusType == null) {
818
		this.focusType = this.lookupEnvironment.askForType(compoundName);
818
		this.focusType = this.lookupEnvironment.askForType(compoundName);
819
		if (this.focusType == null) {
820
			int length = compoundName.length;
821
			char[] typeName = compoundName[length-1];
822
			int firstDollar = CharOperation.indexOf('$', typeName);
823
			if (firstDollar != -1) {
824
				compoundName[length-1] = CharOperation.subarray(typeName, 0, firstDollar);
825
				this.focusType = this.lookupEnvironment.askForType(compoundName);
826
				if (this.focusType != null) {
827
					char[][] memberTypeNames = CharOperation.splitOn('$', typeName, firstDollar+1, typeName.length);
828
					for (int i = 0; i < memberTypeNames.length; i++) {
829
						this.focusType = this.focusType.getMemberType(memberTypeNames[i]);
830
					}
831
				}
832
			}
833
		}
819
	}
834
	}
820
	return this.focusType;
835
	return this.focusType;
821
}
836
}
(-)src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java (+45 lines)
Lines 1712-1717 Link Here
1712
		deleteProject("P");
1712
		deleteProject("P");
1713
	}
1713
	}
1714
}
1714
}
1715
/*
1716
 * Ensures that a potential subtype in a dependent project doesn't appear in the hierarchy
1717
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=169678 )
1718
 */
1719
public void testPotentialSubtypeInDependentProject() throws Exception {
1720
	try {
1721
		createJavaProject("P1", new String[] {""}, new String[] {"JCL_LIB"}, "");
1722
		createFolder("/P1/p1");
1723
		createFile(
1724
			"/P1/p1/X169678.java",
1725
			"package p1;\n" +
1726
			"public class X169678 {\n" +
1727
			"  public static class Y169678 {\n" +
1728
			"  }\n" +
1729
			"}"
1730
		);
1731
		createFile(
1732
			"/P1/p1/Z169678.java",
1733
			"package p1;\n" +
1734
			"public class Z169678 extends X169678.Y169678 {\n" +
1735
			"}"
1736
		);
1737
		createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] {"/P1"}, "");
1738
		createFolder("/P2/p2");
1739
		createFile(
1740
			"/P2/p2/Y169678.java",
1741
			"package p2;\n" +
1742
			"public class Y169678 {\n" +
1743
			"}\n" +
1744
			"class Z169678 extends Y169678 {\n" +
1745
			"}"
1746
		);
1747
		IType type = getCompilationUnit("/P1/p1/X169678.java").getType("X169678").getType("Y169678");
1748
		ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1749
		IType[] allTypes = hierarchy.getAllTypes();
1750
		assertSortedElementsEqual(
1751
			"Unexpected types in hierarchy", 
1752
			"Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + 
1753
			"Y169678 [in X169678 [in X169678.java [in p1 [in <project root> [in P1]]]]]\n" + 
1754
			"Z169678 [in Z169678.java [in p1 [in <project root> [in P1]]]]",
1755
			allTypes);
1756
	} finally {
1757
		deleteProjects(new String[] {"P1", "P2"});
1758
	}
1759
}
1715
/**
1760
/**
1716
 * Ensures that a potential subtype that is not in the classpth is handle correctly.
1761
 * Ensures that a potential subtype that is not in the classpth is handle correctly.
1717
 * (Regression test for PR #1G4GL9R)
1762
 * (Regression test for PR #1G4GL9R)

Return to bug 169678