Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 431357 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java (+49 lines)
Lines 4425-4430 Link Here
4425
this.resultCollector,
4425
this.resultCollector,
4426
null);
4426
null);
4427
}
4427
}
4428
/** @bug 431357
4429
 * [1.8][compiler] NPE when creating LambdaMethod element for lambda expressions with errors
4430
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357"
4431
 */
4432
public void testBug431357() throws CoreException {
4433
	this.workingCopies = new ICompilationUnit[1];
4434
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
4435
			"interface I { \n" +
4436
			"    public void query(Foo.InnerKey key);// Search result of method query(Foo.InnerKey) returns the method query(Bar.InnerKey) too \n" +
4437
			"    public void query(Bar.InnerKey key);\n" +
4438
			"}\n" +
4439
			"\n" +
4440
			"class Foo { \n" +
4441
			"    static class InnerKey  {}\n" +
4442
			"}\n" +
4443
			"class Bar {\n" +
4444
			"    static class InnerKey {}\n" +
4445
			"}\n" +
4446
			"\n" +
4447
			"class X {\n" +
4448
			"	public static void foo(I i, Foo.InnerKey key) {\n" +
4449
			"		i.query(key);\n" +
4450
			"	}\n" +
4451
			"	public static void bar(I i, Bar.InnerKey key) {\n" +
4452
			"		i.query(key);\n" +
4453
			"	}\n" +
4454
			"	public static I getInstance() {\n" +
4455
			"		return null;\n" +
4456
			"	}\n" +
4457
			"}\n"
4458
	);
4459
4460
	String str = this.workingCopies[0].getSource();
4461
	String selection = "query";
4462
	int start = str.indexOf(selection);
4463
	int length = selection.length();
4464
4465
	IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length);
4466
	MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], REFERENCES, EXACT_RULE | ERASURE_RULE);
4467
4468
	new SearchEngine(this.workingCopies).search(pattern,
4469
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
4470
			getJavaSearchWorkingCopiesScope(),
4471
			this.resultCollector,
4472
			null);
4473
	assertSearchResults(
4474
			"src/X.java void X.foo(I, Foo.InnerKey) [query(key)] EXACT_MATCH"
4475
	);
4476
}
4428
// Add new tests in JavaSearchBugs8Tests
4477
// Add new tests in JavaSearchBugs8Tests
4429
}
4478
}
4430
4479
(-)a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java (-4 / +15 lines)
Lines 314-323 Link Here
314
			TypeBinding argType = method.parameters[i];
314
			TypeBinding argType = method.parameters[i];
315
			int newLevel = IMPOSSIBLE_MATCH;
315
			int newLevel = IMPOSSIBLE_MATCH;
316
			if (argType.isMemberType()) {
316
			if (argType.isMemberType()) {
317
				// only compare source name for member type (bug 41018)
317
				boolean foundLevel = false;
318
				newLevel = CharOperation.match(this.pattern.parameterSimpleNames[i], argType.sourceName(), this.isCaseSensitive)
318
				MethodBinding focusMethodBinding = this.matchLocator.getMethodBinding(this.pattern);
319
					? ACCURATE_MATCH
319
				if (focusMethodBinding != null) {// textual comparison insufficient
320
					: IMPOSSIBLE_MATCH;
320
					TypeBinding[] parameters = focusMethodBinding.parameters;
321
					if (parameters.length >= parameterCount) {
322
						newLevel = argType.isCompatibleWith((parameters[i])) ? ACCURATE_MATCH : IMPOSSIBLE_MATCH;
323
						foundLevel = true;
324
					}
325
				}
326
				if (!foundLevel) { // a safety net
327
					// only compare source name for member type (bug 41018)
328
					newLevel = CharOperation.match(this.pattern.parameterSimpleNames[i], argType.sourceName(), this.isCaseSensitive)
329
							? ACCURATE_MATCH
330
							: IMPOSSIBLE_MATCH;
331
				}
321
			} else {
332
			} else {
322
				// TODO (frederic) use this call to refine accuracy on parameter types
333
				// TODO (frederic) use this call to refine accuracy on parameter types
323
//				 newLevel = resolveLevelForType(this.pattern.parameterSimpleNames[i], this.pattern.parameterQualifications[i], this.pattern.parametersTypeArguments[i], 0, argType);
334
//				 newLevel = resolveLevelForType(this.pattern.parameterSimpleNames[i], this.pattern.parameterQualifications[i], this.pattern.parametersTypeArguments[i], 0, argType);

Return to bug 431357