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 82186 Details for
Bug 178596
[search] Search for method references does not find references to interface method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v02.txt (text/plain), 5.95 KB, created by
Frederic Fusier
on 2007-11-06 06:02:16 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-11-06 06:02:16 EST
Size:
5.95 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java,v >retrieving revision 1.76 >diff -u -r1.76 MethodLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 19 Jul 2007 15:11:17 -0000 1.76 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 6 Nov 2007 10:56:53 -0000 >@@ -635,21 +635,10 @@ > if (method.declaringClass == null || this.allSuperDeclaringTypeNames == null) { > declaringLevel = INACCURATE_MATCH; > } else { >- char[][] compoundName = methodReceiverType.compoundName; >- for (int i = 0, max = this.allSuperDeclaringTypeNames.length; i < max; i++) { >- if (CharOperation.equals(this.allSuperDeclaringTypeNames[i], compoundName)) { >- return methodLevel // since this is an ACCURATE_MATCH so return the possibly weaker match >- | SUPER_INVOCATION_FLAVOR; // this is an overridden method => add flavor to returned level >- } >- } >- /* Do not return interfaces potential matches >- * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=157814#c8" >- if (methodReceiverType.isInterface()) { >- // all methods interface with same name and parameters are potential matches >- // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=156491 >- return INACCURATE_MATCH | POLYMORPHIC_FLAVOR; >+ if (resolveLevelAsSuperInvocation(methodReceiverType)) { >+ declaringLevel = methodLevel // since this is an ACCURATE_MATCH so return the possibly weaker match >+ | SUPER_INVOCATION_FLAVOR; // this is an overridden method => add flavor to returned level > } >- */ > } > } > if ((declaringLevel & FLAVORS_MASK) != 0) { >@@ -661,6 +650,7 @@ > } > return methodLevel > declaringLevel ? declaringLevel : methodLevel; // return the weaker match > } >+ > /** > * Returns whether the given reference type binding matches or is a subtype of a type > * that matches the given qualified pattern. >@@ -728,6 +718,31 @@ > } > return IMPOSSIBLE_MATCH; > } >+ >+/* >+ * Return whether the given type binding or one of its possible super interfaces >+ * matches a type in the declaring type names hierarchy. >+ */ >+protected boolean resolveLevelAsSuperInvocation(ReferenceBinding type) { >+ char[][] compoundName = type.compoundName; >+ for (int i = 0, max = this.allSuperDeclaringTypeNames.length; i < max; i++) { >+ if (CharOperation.equals(this.allSuperDeclaringTypeNames[i], compoundName)) { >+ return true; >+ } >+ } >+ >+ // maybe super interfaces? >+ if (type.isInterface()) { >+ ReferenceBinding[] interfaces = type.superInterfaces(); >+ if (interfaces == null) return false; >+ for (int i = 0; i < interfaces.length; i++) { >+ if (resolveLevelAsSuperInvocation(interfaces[i])) { >+ return true; >+ } >+ } >+ } >+ return false; >+} > public String toString() { > return "Locator for " + this.pattern.toString(); //$NON-NLS-1$ > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v >retrieving revision 1.127 >diff -u -r1.127 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 17 Oct 2007 13:55:52 -0000 1.127 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 6 Nov 2007 10:56:57 -0000 >@@ -8372,6 +8372,57 @@ > } > > /** >+ * @bug 178596: [search] Search for method references does not find references to interface method >+ * @test Ensure that searching method reference finds the interface method reference >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=178596" >+ */ >+public void testBug178596() throws CoreException { >+ workingCopies = new ICompilationUnit[5]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/ClassA.java", >+ "public class ClassA implements InterfaceA {\n" + >+ " public void setValue(int aValue) {\n" + >+ " }\n" + >+ "}\n" >+ ); >+ workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/ClassB.java", >+ "public class ClassB extends ClassA implements InterfaceB {}\n" >+ ); >+ workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/InterfaceA.java", >+ "public interface InterfaceA {\n" + >+ " public void setValue(int aValue);\n" + >+ "}\n" >+ ); >+ workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/InterfaceB.java", >+ "public interface InterfaceB extends InterfaceA {}\n" >+ ); >+ workingCopies[4] = getWorkingCopy("/JavaSearchBugs/src/Main.java", >+ "public class Main {\n" + >+ " public static void main(String[] args) {\n" + >+ " new Main().run();\n" + >+ " }\n" + >+ " private void run() {\n" + >+ " InterfaceB anB = new ClassB();\n" + >+ " anB.setValue(123);\n" + >+ " }\n" + >+ "}\n" >+ ); >+ JavaSearchResultCollector testCollector = new JavaSearchResultCollector() { >+ public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { >+ super.acceptSearchMatch(searchMatch); >+ assertTrue("Method reference match should be super invocation one!", ((MethodReferenceMatch)searchMatch).isSuperInvocation()); >+ } >+ >+ }; >+ testCollector.showAccuracy = true; >+ IMethod method = workingCopies[0].getType("ClassA").getMethod("setValue", new String[] { "I" }); >+ search(method, REFERENCES, getJavaSearchScope(), testCollector); >+ assertSearchResults( >+ "src/Main.java void Main.run() [setValue(123)] EXACT_MATCH", >+ testCollector >+ ); >+} >+ >+/** > * @bug 178847 [search] Potential matches found when searching references to IJavaElement#getResource() > * @test Ensure that accurate matches are found > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=178847"
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 178596
: 82186 |
82753