View | Details | Raw Unified | Return to bug 136095 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java (-8 / +47 lines)
Lines 974-980 Link Here
974
/*
974
/*
975
 * Ensures that a hierarchy on a generic type can be opened
975
 * Ensures that a hierarchy on a generic type can be opened
976
 */
976
 */
977
public void testGeneric1() throws JavaModelException {
977
public void testGeneric01() throws JavaModelException {
978
	IType type = getCompilationUnit("/TypeHierarchy15/src/X.java").getType("X");
978
	IType type = getCompilationUnit("/TypeHierarchy15/src/X.java").getType("X");
979
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
979
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
980
	assertHierarchyEquals(
980
	assertHierarchyEquals(
Lines 992-998 Link Here
992
/*
992
/*
993
 * Ensures that a hierarchy on a generic type can be opened
993
 * Ensures that a hierarchy on a generic type can be opened
994
 */
994
 */
995
public void testGeneric2() throws JavaModelException {
995
public void testGeneric02() throws JavaModelException {
996
	IType type = getPackageFragmentRoot("/TypeHierarchy15/lib15.jar").getPackageFragment("util").getClassFile("ArrayList.class").getType();
996
	IType type = getPackageFragmentRoot("/TypeHierarchy15/lib15.jar").getPackageFragment("util").getClassFile("ArrayList.class").getType();
997
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
997
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
998
	assertHierarchyEquals(
998
	assertHierarchyEquals(
Lines 1010-1016 Link Here
1010
/*
1010
/*
1011
 * Ensures that a hierarchy on a generic type can be opened
1011
 * Ensures that a hierarchy on a generic type can be opened
1012
 */
1012
 */
1013
public void testGeneric3() throws JavaModelException {
1013
public void testGeneric03() throws JavaModelException {
1014
	IType type = getCompilationUnit("/TypeHierarchy15/src/Y.java").getType("Y");
1014
	IType type = getCompilationUnit("/TypeHierarchy15/src/Y.java").getType("Y");
1015
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1015
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1016
	assertHierarchyEquals(
1016
	assertHierarchyEquals(
Lines 1029-1035 Link Here
1029
 * Ensures that a super type hierarchy on a generic type can be opened
1029
 * Ensures that a super type hierarchy on a generic type can be opened
1030
 * (regression test for bug 72348 [1.5][Type Hierarchy] Super type hierarchy of class extending generic type is empty)
1030
 * (regression test for bug 72348 [1.5][Type Hierarchy] Super type hierarchy of class extending generic type is empty)
1031
 */
1031
 */
1032
public void testGeneric4() throws JavaModelException {
1032
public void testGeneric04() throws JavaModelException {
1033
	IType type = getCompilationUnit("/TypeHierarchy15/src/X.java").getType("X");
1033
	IType type = getCompilationUnit("/TypeHierarchy15/src/X.java").getType("X");
1034
	ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
1034
	ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
1035
	assertHierarchyEquals(
1035
	assertHierarchyEquals(
Lines 1049-1055 Link Here
1049
 * Ensures that a hierarchy on a generic interface can be opened
1049
 * Ensures that a hierarchy on a generic interface can be opened
1050
 * (regression test for bug 82004 [model][5.0] 3.1M4 type hierarchy for generic interface)
1050
 * (regression test for bug 82004 [model][5.0] 3.1M4 type hierarchy for generic interface)
1051
 */
1051
 */
1052
public void testGeneric5() throws JavaModelException {
1052
public void testGeneric05() throws JavaModelException {
1053
	IType type = getCompilationUnit("/TypeHierarchy15/src/I.java").getType("I");
1053
	IType type = getCompilationUnit("/TypeHierarchy15/src/I.java").getType("I");
1054
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1054
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1055
	assertHierarchyEquals(
1055
	assertHierarchyEquals(
Lines 1064-1070 Link Here
1064
 * Ensure that the key of a binary type in a hierarchy is correct when this type is not part of the Java model cache.
1064
 * Ensure that the key of a binary type in a hierarchy is correct when this type is not part of the Java model cache.
1065
 * (regression test for bug 93854 IAE in Util.scanTypeSignature when scanning a signature retrieved from a binding key)
1065
 * (regression test for bug 93854 IAE in Util.scanTypeSignature when scanning a signature retrieved from a binding key)
1066
 */
1066
 */
1067
public void testGeneric6() throws CoreException {
1067
public void testGeneric06() throws CoreException {
1068
	getJavaProject("TypeHierarcht15").close();
1068
	getJavaProject("TypeHierarcht15").close();
1069
	IType type = getClassFile("TypeHierarchy15","lib15.jar", "util", "AbstractList.class").getType();
1069
	IType type = getClassFile("TypeHierarchy15","lib15.jar", "util", "AbstractList.class").getType();
1070
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1070
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
Lines 1075-1081 Link Here
1075
 * Ensures that a hierarchy on a generic type that is extended using a member as a type parameter can be opened
1075
 * Ensures that a hierarchy on a generic type that is extended using a member as a type parameter can be opened
1076
 * (regression test for bug 99606 Subtype not found if parameterized on inner class)
1076
 * (regression test for bug 99606 Subtype not found if parameterized on inner class)
1077
 */
1077
 */
1078
public void testGeneric7() throws JavaModelException {
1078
public void testGeneric07() throws JavaModelException {
1079
	IType type = getCompilationUnit("/TypeHierarchy15/src/Y99606.java").getType("Y99606");
1079
	IType type = getCompilationUnit("/TypeHierarchy15/src/Y99606.java").getType("Y99606");
1080
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1080
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1081
	assertHierarchyEquals(
1081
	assertHierarchyEquals(
Lines 1088-1094 Link Here
1088
	);
1088
	);
1089
}
1089
}
1090
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=108740
1090
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=108740
1091
public void testGeneric8() throws JavaModelException {
1091
public void testGeneric08() throws JavaModelException {
1092
	IType type = getCompilationUnit("/TypeHierarchy15/src/D108740.java").getType("D108740");
1092
	IType type = getCompilationUnit("/TypeHierarchy15/src/D108740.java").getType("D108740");
1093
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1093
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1094
	assertHierarchyEquals(
1094
	assertHierarchyEquals(
Lines 1101-1106 Link Here
1101
		hierarchy
1101
		hierarchy
1102
	);
1102
	);
1103
}
1103
}
1104
/*
1105
 * Ensures that a hierarchy is where a type inherits conflicting paratemerized types is still correctly reported
1106
 * (regression test for bug 136095 Type Hierarchy incomplete with illegally parameterized superinterfaces)
1107
 */
1108
public void testGeneric09() throws CoreException {
1109
	try {
1110
		createFile(
1111
			"/TypeHierarchy15/src/I1_136095.java", 
1112
			"public interface I1_136095<E> {\n" + 
1113
			"}"
1114
		);
1115
		createFile(
1116
			"/TypeHierarchy15/src/I2_136095.java", 
1117
			"public interface I2_136095 extends I1_136095<String>{\n" + 
1118
			"}"
1119
		);
1120
		createFile(
1121
			"/TypeHierarchy15/src/X_136095.java", 
1122
			"public abstract class X_136095 implements I1_136095<Integer>, I2_136095 {\n" + 
1123
			"}"
1124
		);
1125
		IType type = getCompilationUnit("/TypeHierarchy15/src/X_136095.java").getType("X_136095");
1126
		ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
1127
		assertHierarchyEquals(
1128
			"Focus: X_136095 [in X_136095.java [in <default> [in src [in TypeHierarchy15]]]]\n" + 
1129
			"Super types:\n" + 
1130
			"  I1_136095 [in I1_136095.java [in <default> [in src [in TypeHierarchy15]]]]\n" + 
1131
			"  I2_136095 [in I2_136095.java [in <default> [in src [in TypeHierarchy15]]]]\n" + 
1132
			"    I1_136095 [in I1_136095.java [in <default> [in src [in TypeHierarchy15]]]]\n" + 
1133
			"  Object [in Object.class [in java.lang [in "+ getExternalJCLPathString("1.5") + " [in TypeHierarchy15]]]]\n" + 
1134
			"Sub types:\n",
1135
			hierarchy
1136
		);
1137
	} finally {
1138
		deleteFile("/TypeHierarchy15/src/I1_136095.java");
1139
		deleteFile("/TypeHierarchy15/src/I2_136095.java");
1140
		deleteFile("/TypeHierarchy15/src/X_136095.java");
1141
	}
1142
}
1104
/**
1143
/**
1105
 * Ensures the correctness of all classes in a type hierarchy based on a region.
1144
 * Ensures the correctness of all classes in a type hierarchy based on a region.
1106
 */
1145
 */
(-)model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java (+21 lines)
Lines 233-238 Link Here
233
	}
233
	}
234
	
234
	
235
	ReferenceBinding[] interfaceBindings = typeBinding.superInterfaces();
235
	ReferenceBinding[] interfaceBindings = typeBinding.superInterfaces();
236
	ClassScope scope;
237
	if (typeBinding instanceof SourceTypeBinding && (scope = ((SourceTypeBinding) typeBinding).scope) != null) {
238
		TypeDeclaration typeDeclaration = scope.referenceContext;
239
		TypeReference[] superInterfaces = typeDeclaration == null ? null : typeDeclaration.superInterfaces;
240
		int length;
241
		if (superInterfaces != null && (length = superInterfaces.length) > interfaceBindings.length) {
242
			// bindings were removed while resolving (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=136095)
243
			interfaceBindings = new ReferenceBinding[length];
244
			int index = 0;
245
			for (int i = 0; i < length; i++) {
246
				ReferenceBinding superInterface = (ReferenceBinding) superInterfaces[i].resolvedType;
247
				if (superInterface instanceof ProblemReferenceBinding)
248
					superInterface = ((ProblemReferenceBinding) superInterface).closestMatch;
249
				if (superInterface != null)
250
					interfaceBindings[index++] = superInterface;
251
			}
252
			if (index < length)
253
				System.arraycopy(interfaceBindings, 0, interfaceBindings = new ReferenceBinding[index], 0 , index);
254
			((SourceTypeBinding) typeBinding).superInterfaces = interfaceBindings;
255
		}
256
	}
236
	int bindingIndex = 0;
257
	int bindingIndex = 0;
237
	int bindingLength = interfaceBindings == null ? 0 : interfaceBindings.length;
258
	int bindingLength = interfaceBindings == null ? 0 : interfaceBindings.length;
238
	int length = superInterfaceNames == null ? 0 : superInterfaceNames.length;
259
	int length = superInterfaceNames == null ? 0 : superInterfaceNames.length;

Return to bug 136095