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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java (-1 / +7 lines)
Lines 468-475 Link Here
468
		}		
468
		}		
469
	};
469
	};
470
470
471
	int superRefKind;
472
	try {
473
		superRefKind = type.isClass() ? SuperTypeReferencePattern.ONLY_SUPER_CLASSES : SuperTypeReferencePattern.ALL_SUPER_TYPES;
474
	} catch (JavaModelException e) {
475
		superRefKind = SuperTypeReferencePattern.ALL_SUPER_TYPES;
476
	}
471
	SuperTypeReferencePattern pattern =
477
	SuperTypeReferencePattern pattern =
472
		new SuperTypeReferencePattern(null, null, false, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
478
		new SuperTypeReferencePattern(null, null, superRefKind, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
473
	MatchLocator.setFocus(pattern, type);
479
	MatchLocator.setFocus(pattern, type);
474
	SubTypeSearchJob job = new SubTypeSearchJob(
480
	SubTypeSearchJob job = new SubTypeSearchJob(
475
		pattern, 
481
		pattern, 
(-)search/org/eclipse/jdt/core/search/SearchPattern.java (-2 / +2 lines)
Lines 1252-1258 Link Here
1252
				return new SuperTypeReferencePattern(
1252
				return new SuperTypeReferencePattern(
1253
					CharOperation.concatWith(packageName, enclosingTypeNames, '.'), 
1253
					CharOperation.concatWith(packageName, enclosingTypeNames, '.'), 
1254
					simpleName,
1254
					simpleName,
1255
					true,
1255
					SuperTypeReferencePattern.ONLY_SUPER_INTERFACES,
1256
					matchRule);
1256
					matchRule);
1257
			case IJavaSearchConstants.ALL_OCCURRENCES :
1257
			case IJavaSearchConstants.ALL_OCCURRENCES :
1258
				return new OrPattern(
1258
				return new OrPattern(
Lines 1376-1382 Link Here
1376
			case IJavaSearchConstants.REFERENCES :
1376
			case IJavaSearchConstants.REFERENCES :
1377
				return new TypeReferencePattern(qualificationChars, typeChars, typeSignature, matchRule);
1377
				return new TypeReferencePattern(qualificationChars, typeChars, typeSignature, matchRule);
1378
			case IJavaSearchConstants.IMPLEMENTORS : 
1378
			case IJavaSearchConstants.IMPLEMENTORS : 
1379
				return new SuperTypeReferencePattern(qualificationChars, typeChars, true, matchRule);
1379
				return new SuperTypeReferencePattern(qualificationChars, typeChars, SuperTypeReferencePattern.ONLY_SUPER_INTERFACES, matchRule);
1380
			case IJavaSearchConstants.ALL_OCCURRENCES :
1380
			case IJavaSearchConstants.ALL_OCCURRENCES :
1381
				return new OrPattern(
1381
				return new OrPattern(
1382
					new QualifiedTypeDeclarationPattern(qualificationChars, typeChars, indexSuffix, matchRule),// cannot search for explicit member types
1382
					new QualifiedTypeDeclarationPattern(qualificationChars, typeChars, indexSuffix, matchRule),// cannot search for explicit member types
(-)search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java (-7 / +9 lines)
Lines 212-218 Link Here
212
	if (!(binaryInfo instanceof IBinaryType)) return false;
212
	if (!(binaryInfo instanceof IBinaryType)) return false;
213
213
214
	IBinaryType type = (IBinaryType) binaryInfo;
214
	IBinaryType type = (IBinaryType) binaryInfo;
215
	if (!pattern.checkOnlySuperinterfaces) {
215
	if (pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_INTERFACES) {
216
		char[] vmName = type.getSuperclassName();
216
		char[] vmName = type.getSuperclassName();
217
		if (vmName != null) {
217
		if (vmName != null) {
218
			char[] superclassName = convertClassFileFormat(vmName);
218
			char[] superclassName = convertClassFileFormat(vmName);
Lines 221-232 Link Here
221
		}
221
		}
222
	}
222
	}
223
223
224
	char[][] superInterfaces = type.getInterfaceNames();
224
	if (pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_CLASSES) {
225
	if (superInterfaces != null) {
225
		char[][] superInterfaces = type.getInterfaceNames();
226
		for (int i = 0, max = superInterfaces.length; i < max; i++) {
226
		if (superInterfaces != null) {
227
			char[] superInterfaceName = convertClassFileFormat(superInterfaces[i]);
227
			for (int i = 0, max = superInterfaces.length; i < max; i++) {
228
			if (checkTypeName(pattern.superSimpleName, pattern.superQualification, superInterfaceName, pattern.isCaseSensitive()))
228
				char[] superInterfaceName = convertClassFileFormat(superInterfaces[i]);
229
				return true;
229
				if (checkTypeName(pattern.superSimpleName, pattern.superQualification, superInterfaceName, pattern.isCaseSensitive()))
230
					return true;
231
			}
230
		}
232
		}
231
	}
233
	}
232
	return false;
234
	return false;
(-)search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java (-7 / +9 lines)
Lines 68-84 Link Here
68
68
69
	ReferenceBinding type = (ReferenceBinding) binding;
69
	ReferenceBinding type = (ReferenceBinding) binding;
70
	int level = IMPOSSIBLE_MATCH;
70
	int level = IMPOSSIBLE_MATCH;
71
	if (!this.pattern.checkOnlySuperinterfaces) {
71
	if (this.pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_INTERFACES) {
72
		level = resolveLevelForType(this.pattern.superSimpleName, this.pattern.superQualification, type.superclass());
72
		level = resolveLevelForType(this.pattern.superSimpleName, this.pattern.superQualification, type.superclass());
73
		if (level == ACCURATE_MATCH) return ACCURATE_MATCH;
73
		if (level == ACCURATE_MATCH) return ACCURATE_MATCH;
74
	}
74
	}
75
75
76
	ReferenceBinding[] superInterfaces = type.superInterfaces();
76
	if (this.pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_CLASSES) {
77
	for (int i = 0, max = superInterfaces.length; i < max; i++) {
77
		ReferenceBinding[] superInterfaces = type.superInterfaces();
78
		int newLevel = resolveLevelForType(this.pattern.superSimpleName, this.pattern.superQualification, superInterfaces[i]);
78
		for (int i = 0, max = superInterfaces.length; i < max; i++) {
79
		if (newLevel > level) {
79
			int newLevel = resolveLevelForType(this.pattern.superSimpleName, this.pattern.superQualification, superInterfaces[i]);
80
			if (newLevel == ACCURATE_MATCH) return ACCURATE_MATCH;
80
			if (newLevel > level) {
81
			level = newLevel;
81
				if (newLevel == ACCURATE_MATCH) return ACCURATE_MATCH;
82
				level = newLevel;
83
			}
82
		}
84
		}
83
	}
85
	}
84
	return level;
86
	return level;
(-)search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java (-8 / +23 lines)
Lines 30-36 Link Here
30
public int modifiers;
30
public int modifiers;
31
public char[][] typeParameterSignatures;
31
public char[][] typeParameterSignatures;
32
32
33
protected boolean checkOnlySuperinterfaces; // used for IMPLEMENTORS
33
protected int superRefKind;
34
public static final int ALL_SUPER_TYPES = 0;
35
public static final int ONLY_SUPER_INTERFACES = 1; // used for IMPLEMENTORS
36
public static final int ONLY_SUPER_CLASSES = 2; // used for hierarachy with a class focus
34
37
35
protected static char[][] CATEGORIES = { SUPER_REF };
38
protected static char[][] CATEGORIES = { SUPER_REF };
36
39
Lines 139-145 Link Here
139
public SuperTypeReferencePattern(
142
public SuperTypeReferencePattern(
140
	char[] superQualification,
143
	char[] superQualification,
141
	char[] superSimpleName,
144
	char[] superSimpleName,
142
	boolean checkOnlySuperinterfaces,
145
	int superRefKind,
143
	int matchRule) {
146
	int matchRule) {
144
147
145
	this(matchRule);
148
	this(matchRule);
Lines 147-153 Link Here
147
	this.superQualification = isCaseSensitive() ? superQualification : CharOperation.toLowerCase(superQualification);
150
	this.superQualification = isCaseSensitive() ? superQualification : CharOperation.toLowerCase(superQualification);
148
	this.superSimpleName = isCaseSensitive() ? superSimpleName : CharOperation.toLowerCase(superSimpleName);
151
	this.superSimpleName = isCaseSensitive() ? superSimpleName : CharOperation.toLowerCase(superSimpleName);
149
	((InternalSearchPattern)this).mustResolve = superQualification != null;
152
	((InternalSearchPattern)this).mustResolve = superQualification != null;
150
	this.checkOnlySuperinterfaces = checkOnlySuperinterfaces; // ie. skip the superclass
153
	this.superRefKind = superRefKind;
151
}
154
}
152
SuperTypeReferencePattern(int matchRule) {
155
SuperTypeReferencePattern(int matchRule) {
153
	super(SUPER_REF_PATTERN, matchRule);
156
	super(SUPER_REF_PATTERN, matchRule);
Lines 203-210 Link Here
203
}
206
}
204
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
207
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
205
	SuperTypeReferencePattern pattern = (SuperTypeReferencePattern) decodedPattern;
208
	SuperTypeReferencePattern pattern = (SuperTypeReferencePattern) decodedPattern;
206
	if (this.checkOnlySuperinterfaces)
209
	if (this.superRefKind == ONLY_SUPER_INTERFACES)
207
		if (pattern.superClassOrInterface != IIndexConstants.INTERFACE_SUFFIX) return false;
210
		if (pattern.superClassOrInterface != IIndexConstants.INTERFACE_SUFFIX) return false;
211
	if (this.superRefKind == ONLY_SUPER_CLASSES && pattern.enclosingTypeName != IIndexConstants.ONE_ZERO/*not an anonymous*/) 
212
		// consider enumerations as classes, reject interfaces and annotations
213
		if (pattern.superClassOrInterface == IIndexConstants.INTERFACE_SUFFIX 
214
			|| pattern.superClassOrInterface == IIndexConstants.ANNOTATION_TYPE_SUFFIX) 
215
			return false;
208
216
209
	if (pattern.superQualification != null)
217
	if (pattern.superQualification != null)
210
		if (!matchesName(this.superQualification, pattern.superQualification)) return false;
218
		if (!matchesName(this.superQualification, pattern.superQualification)) return false;
Lines 234-243 Link Here
234
	return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
242
	return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
235
}
243
}
236
protected StringBuffer print(StringBuffer output) {
244
protected StringBuffer print(StringBuffer output) {
237
	output.append(
245
	switch (this.superRefKind) {
238
		this.checkOnlySuperinterfaces
246
		case ALL_SUPER_TYPES:
239
			? "SuperInterfaceReferencePattern: <" //$NON-NLS-1$
247
			output.append("SuperTypeReferencePattern: <"); //$NON-NLS-1$
240
			: "SuperTypeReferencePattern: <"); //$NON-NLS-1$
248
			break;
249
		case ONLY_SUPER_INTERFACES:
250
			output.append("SuperInterfaceReferencePattern: <"); //$NON-NLS-1$
251
			break;
252
		case ONLY_SUPER_CLASSES:
253
			output.append("SuperClassReferencePattern: <"); //$NON-NLS-1$
254
			break;
255
	}
241
	if (superSimpleName != null) 
256
	if (superSimpleName != null) 
242
		output.append(superSimpleName);
257
		output.append(superSimpleName);
243
	else
258
	else

Return to bug 108820