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

Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java (+5 lines)
Lines 51-56 Link Here
51
		this.patternLocators[i].initializePolymorphicSearch(locator);
51
		this.patternLocators[i].initializePolymorphicSearch(locator);
52
	}
52
	}
53
}
53
}
54
public void setMatchLocator(MatchLocator locator) {
55
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
56
		this.patternLocators[i].setMatchLocator(locator);
57
	}
58
}
54
public int match(Annotation node, MatchingNodeSet nodeSet) {
59
public int match(Annotation node, MatchingNodeSet nodeSet) {
55
	int level = IMPOSSIBLE_MATCH;
60
	int level = IMPOSSIBLE_MATCH;
56
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
61
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-1 / +7 lines)
Lines 146-151 Link Here
146
HashSet methodHandles;
146
HashSet methodHandles;
147
147
148
private final boolean searchPackageDeclaration;
148
private final boolean searchPackageDeclaration;
149
public int parseContext;
150
151
public final static int PARSE_STATE_UNKNOWN = 0;
152
public final static int PARSE_INTERFACE_TYPE = 1;
153
public final static int PARSE_EXTENDS_TYPE = 2;
154
public final static int PARSE_ANONYMOUS_BODY = 3;
149
155
150
public static class WorkingCopyDocument extends JavaSearchDocument {
156
public static class WorkingCopyDocument extends JavaSearchDocument {
151
	public org.eclipse.jdt.core.ICompilationUnit workingCopy;
157
	public org.eclipse.jdt.core.ICompilationUnit workingCopy;
Lines 1171-1177 Link Here
1171
		if (this.progressMonitor != null) {
1177
		if (this.progressMonitor != null) {
1172
			this.progressMonitor.beginTask("", searchDocuments.length); //$NON-NLS-1$
1178
			this.progressMonitor.beginTask("", searchDocuments.length); //$NON-NLS-1$
1173
		}
1179
		}
1174
1180
		this.patternLocator.setMatchLocator(this);
1175
		// initialize pattern for polymorphic search (i.e. method reference pattern)
1181
		// initialize pattern for polymorphic search (i.e. method reference pattern)
1176
		this.patternLocator.initializePolymorphicSearch(this);
1182
		this.patternLocator.initializePolymorphicSearch(this);
1177
1183
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java (+12 lines)
Lines 26-31 Link Here
26
	PatternLocator patternLocator;
26
	PatternLocator patternLocator;
27
	private ASTVisitor localDeclarationVisitor;
27
	private ASTVisitor localDeclarationVisitor;
28
	final int patternFineGrain;
28
	final int patternFineGrain;
29
	private MatchLocator locator;
29
30
30
public static MatchLocatorParser createParser(ProblemReporter problemReporter, MatchLocator locator) {
31
public static MatchLocatorParser createParser(ProblemReporter problemReporter, MatchLocator locator) {
31
	if ((locator.matchContainer & PatternLocator.COMPILATION_UNIT_CONTAINER) != 0) {
32
	if ((locator.matchContainer & PatternLocator.COMPILATION_UNIT_CONTAINER) != 0) {
Lines 93-98 Link Here
93
protected MatchLocatorParser(ProblemReporter problemReporter, MatchLocator locator) {
94
protected MatchLocatorParser(ProblemReporter problemReporter, MatchLocator locator) {
94
	super(problemReporter, true);
95
	super(problemReporter, true);
95
	this.reportOnlyOneSyntaxError = true;
96
	this.reportOnlyOneSyntaxError = true;
97
	this.locator = locator;
96
	this.patternLocator = locator.patternLocator;
98
	this.patternLocator = locator.patternLocator;
97
	if ((locator.matchContainer & PatternLocator.CLASS_CONTAINER) != 0) {
99
	if ((locator.matchContainer & PatternLocator.CLASS_CONTAINER) != 0) {
98
		this.localDeclarationVisitor = (locator.matchContainer & PatternLocator.METHOD_CONTAINER) != 0
100
		this.localDeclarationVisitor = (locator.matchContainer & PatternLocator.METHOD_CONTAINER) != 0
Lines 209-214 Link Here
209
	}
211
	}
210
}
212
}
211
213
214
protected void consumeEnterAnonymousClassBody(boolean qualified) {
215
	this.locator.parseContext = MatchLocator.PARSE_ANONYMOUS_BODY;
216
	super.consumeEnterAnonymousClassBody(qualified);
217
	this.locator.parseContext = MatchLocator.PARSE_STATE_UNKNOWN;
218
}
219
212
protected void consumeCastExpressionLL1() {
220
protected void consumeCastExpressionLL1() {
213
	super.consumeCastExpressionLL1();
221
	super.consumeCastExpressionLL1();
214
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
222
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
Lines 256-266 Link Here
256
}
264
}
257
265
258
protected void consumeClassHeaderExtends() {
266
protected void consumeClassHeaderExtends() {
267
	this.locator.parseContext = MatchLocator.PARSE_EXTENDS_TYPE;
259
	super.consumeClassHeaderExtends();
268
	super.consumeClassHeaderExtends();
260
	if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) {
269
	if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) {
261
		TypeDeclaration typeDeclaration = (TypeDeclaration) this.astStack[this.astPtr];
270
		TypeDeclaration typeDeclaration = (TypeDeclaration) this.astStack[this.astPtr];
262
		this.patternLocator.match(typeDeclaration.superclass, this.nodeSet);
271
		this.patternLocator.match(typeDeclaration.superclass, this.nodeSet);
263
	}
272
	}
273
	this.locator.parseContext = MatchLocator.PARSE_STATE_UNKNOWN;
264
}
274
}
265
275
266
protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() {
276
protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() {
Lines 337-347 Link Here
337
	}
347
	}
338
}
348
}
339
protected void consumeInterfaceType() {
349
protected void consumeInterfaceType() {
350
	this.locator.parseContext = MatchLocator.PARSE_INTERFACE_TYPE;
340
	super.consumeInterfaceType();
351
	super.consumeInterfaceType();
341
	if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) {
352
	if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) {
342
		TypeReference typeReference = (TypeReference) this.astStack[this.astPtr];
353
		TypeReference typeReference = (TypeReference) this.astStack[this.astPtr];
343
		this.patternLocator.match(typeReference, this.nodeSet);
354
		this.patternLocator.match(typeReference, this.nodeSet);
344
	}
355
	}
356
	this.locator.parseContext = MatchLocator.PARSE_STATE_UNKNOWN;
345
}
357
}
346
358
347
protected void consumeLocalVariableDeclaration() {
359
protected void consumeLocalVariableDeclaration() {
(-)search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java (+5 lines)
Lines 50-55 Link Here
50
	for (int i = 0, length = this.patternLocators.length; i < length; i++)
50
	for (int i = 0, length = this.patternLocators.length; i < length; i++)
51
		this.patternLocators[i].initializePolymorphicSearch(locator);
51
		this.patternLocators[i].initializePolymorphicSearch(locator);
52
}
52
}
53
public void setMatchLocator(MatchLocator locator) {
54
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
55
		this.patternLocators[i].setMatchLocator(locator);
56
	}
57
}
53
public int match(Annotation node, MatchingNodeSet nodeSet) {
58
public int match(Annotation node, MatchingNodeSet nodeSet) {
54
	int level = IMPOSSIBLE_MATCH;
59
	int level = IMPOSSIBLE_MATCH;
55
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
60
	for (int i = 0, length = this.patternLocators.length; i < length; i++) {
(-)search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java (+4 lines)
Lines 30-35 Link Here
30
30
31
// match to report
31
// match to report
32
SearchMatch match = null;
32
SearchMatch match = null;
33
MatchLocator matchLocator;
33
34
34
/* match levels */
35
/* match levels */
35
public static final int IMPOSSIBLE_MATCH = 0;
36
public static final int IMPOSSIBLE_MATCH = 0;
Lines 956-959 Link Here
956
public String toString(){
957
public String toString(){
957
	return "SearchPattern"; //$NON-NLS-1$
958
	return "SearchPattern"; //$NON-NLS-1$
958
}
959
}
960
public void setMatchLocator(MatchLocator locator) {
961
	this.matchLocator = locator;
962
}
959
}
963
}
(-)search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java (+9 lines)
Lines 34-39 Link Here
34
//public int match(Reference node, MatchingNodeSet nodeSet) - SKIP IT
34
//public int match(Reference node, MatchingNodeSet nodeSet) - SKIP IT
35
//public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
35
//public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
36
public int match(TypeReference node, MatchingNodeSet nodeSet) {
36
public int match(TypeReference node, MatchingNodeSet nodeSet) {
37
	switch(this.matchLocator.parseContext) {
38
		case MatchLocator.PARSE_INTERFACE_TYPE:
39
		case MatchLocator.PARSE_ANONYMOUS_BODY:
40
		case MatchLocator.PARSE_EXTENDS_TYPE:
41
			break;
42
		default:
43
			return IMPOSSIBLE_MATCH;
44
	}
45
	
37
	if (this.pattern.superSimpleName == null)
46
	if (this.pattern.superSimpleName == null)
38
		return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
47
		return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
39
48
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-1 / +21 lines)
Lines 61-67 Link Here
61
// Debug
61
// Debug
62
static {
62
static {
63
//	 org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
63
//	 org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
64
//	TESTS_NAMES = new String[] {"testBug306223"};
64
//	TESTS_NAMES = new String[] {"testBug122442d"};
65
}
65
}
66
66
67
public JavaSearchBugsTests(String name) {
67
public JavaSearchBugsTests(String name) {
Lines 12071-12074 Link Here
12071
		deleteProject("P");
12071
		deleteProject("P");
12072
	}
12072
	}
12073
}
12073
}
12074
12075
public void testBug322979() throws CoreException {
12076
	try
12077
	{
12078
		IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
12079
		createFile("/P/Test.java", 
12080
			"public class Test implements Comparable<Object>{\n"+
12081
		    "public int compareTo(Object o) {\n"+
12082
		        "return 0;\n"+
12083
		    "}\n"+
12084
			"}\n");
12085
		waitUntilIndexesReady();
12086
		int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
12087
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
12088
		search("Object", TYPE, IMPLEMENTORS, scope, this.resultCollector);
12089
		assertSearchResults("", this.resultCollector);
12090
	} finally {
12091
		deleteProject("P");
12092
	}
12093
}
12074
}
12094
}

Return to bug 322979