Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 245177 Details for
Bug 431357
[search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed Patch
Fix-for-Bug-431357-search-Search-API-got-wrong-resul.patch (text/plain), 3.96 KB, created by
Manoj N Palat
on 2014-07-18 04:20:08 EDT
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Manoj N Palat
Created:
2014-07-18 04:20:08 EDT
Size:
3.96 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java >index 04d010d..f76622f 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java >@@ -4425,6 +4425,55 @@ > this.resultCollector, > null); > } >+/** @bug 431357 >+ * [1.8][compiler] NPE when creating LambdaMethod element for lambda expressions with errors >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" >+ */ >+public void testBug431357() throws CoreException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", >+ "interface I { \n" + >+ " public void query(Foo.InnerKey key);// Search result of method query(Foo.InnerKey) returns the method query(Bar.InnerKey) too \n" + >+ " public void query(Bar.InnerKey key);\n" + >+ "}\n" + >+ "\n" + >+ "class Foo { \n" + >+ " static class InnerKey {}\n" + >+ "}\n" + >+ "class Bar {\n" + >+ " static class InnerKey {}\n" + >+ "}\n" + >+ "\n" + >+ "class X {\n" + >+ " public static void foo(I i, Foo.InnerKey key) {\n" + >+ " i.query(key);\n" + >+ " }\n" + >+ " public static void bar(I i, Bar.InnerKey key) {\n" + >+ " i.query(key);\n" + >+ " }\n" + >+ " public static I getInstance() {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n" >+ ); >+ >+ String str = this.workingCopies[0].getSource(); >+ String selection = "query"; >+ int start = str.indexOf(selection); >+ int length = selection.length(); >+ >+ IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); >+ MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], REFERENCES, EXACT_RULE | ERASURE_RULE); >+ >+ new SearchEngine(this.workingCopies).search(pattern, >+ new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >+ getJavaSearchWorkingCopiesScope(), >+ this.resultCollector, >+ null); >+ assertSearchResults( >+ "src/X.java void X.foo(I, Foo.InnerKey) [query(key)] EXACT_MATCH" >+ ); >+} > // Add new tests in JavaSearchBugs8Tests > } > >diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java >index 61bc89c..5b82f7b 100644 >--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java >+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java >@@ -314,10 +314,21 @@ > TypeBinding argType = method.parameters[i]; > int newLevel = IMPOSSIBLE_MATCH; > if (argType.isMemberType()) { >- // only compare source name for member type (bug 41018) >- newLevel = CharOperation.match(this.pattern.parameterSimpleNames[i], argType.sourceName(), this.isCaseSensitive) >- ? ACCURATE_MATCH >- : IMPOSSIBLE_MATCH; >+ boolean foundLevel = false; >+ MethodBinding focusMethodBinding = this.matchLocator.getMethodBinding(this.pattern); >+ if (focusMethodBinding != null) {// textual comparison insufficient >+ TypeBinding[] parameters = focusMethodBinding.parameters; >+ if (parameters.length >= parameterCount) { >+ newLevel = argType.isCompatibleWith((parameters[i])) ? ACCURATE_MATCH : IMPOSSIBLE_MATCH; >+ foundLevel = true; >+ } >+ } >+ if (!foundLevel) { // a safety net >+ // only compare source name for member type (bug 41018) >+ newLevel = CharOperation.match(this.pattern.parameterSimpleNames[i], argType.sourceName(), this.isCaseSensitive) >+ ? ACCURATE_MATCH >+ : IMPOSSIBLE_MATCH; >+ } > } else { > // TODO (frederic) use this call to refine accuracy on parameter types > // newLevel = resolveLevelForType(this.pattern.parameterSimpleNames[i], this.pattern.parameterQualifications[i], this.pattern.parametersTypeArguments[i], 0, argType);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 431357
:
245177
|
246151
|
246299
|
246984
|
247051
|
247094
|
248117