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 139636 Details for
Bug 221065
[search] Search still finds overridden method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 5.31 KB, created by
Frederic Fusier
on 2009-06-19 10:35:57 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2009-06-19 10:35:57 EDT
Size:
5.31 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.172 >diff -u -r1.172 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 15 Apr 2009 08:01:48 -0000 1.172 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 19 Jun 2009 14:13:32 -0000 >@@ -10197,6 +10197,42 @@ > } > > /** >+ * @bug 221065: [search] Search still finds overridden method >+ * @test Ensure that correct number of method references are found >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=221065" >+ */ >+public void testBug221065() throws CoreException { >+ this.resultCollector.showRule(); >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", >+ "public class Test {\n" + >+ " abstract class A {\n" + >+ " void foo() {}\n" + >+ " void bar() {\n" + >+ " foo();\n" + >+ " }\n" + >+ " }\n" + >+ " class B extends A {\n" + >+ " void foo() {}\n" + >+ " void bar() {\n" + >+ " foo();\n" + >+ " }\n" + >+ " }\n" + >+ " class C extends B {\n" + >+ " void method() {\n" + >+ " foo();\n" + >+ " }\n" + >+ " }\n" + >+ "}" >+ ); >+ IMethod method = this.workingCopies[0].getType("Test").getType("A").getMethod("foo", new String[0]); >+ search(method, REFERENCES); >+ assertSearchResults( >+ "src/Test.java void Test$A.bar() [foo()] EXACT_MATCH" >+ ); >+} >+ >+/** > * @bug 222284: [search] ZipException while searching if linked jar doesn't exist any longer > * @test Ensure that no exception is raised while searching for a type of the missing jar file > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=222284" >#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.88 >diff -u -r1.88 MethodLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 7 Mar 2009 00:59:00 -0000 1.88 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 19 Jun 2009 14:13:33 -0000 >@@ -49,6 +49,25 @@ > protected int fineGrain() { > return this.pattern.fineGrain; > } >+ >+private MethodBinding getMethodBinding(ReferenceBinding type, TypeBinding[] argumentTypes) { >+ MethodBinding[] methods = type.getMethods(this.pattern.selector); >+ MethodBinding method = null; >+ methodsLoop: for (int i=0, length=methods.length; i<length; i++) { >+ method = methods[i]; >+ TypeBinding[] parameters = method.parameters; >+ if (argumentTypes.length == parameters.length) { >+ for (int j=0,l=parameters.length; j<l; j++) { >+ if (parameters[j].erasure() != argumentTypes[j].erasure()) { >+ continue methodsLoop; >+ } >+ } >+ return method; >+ } >+ } >+ return null; >+} >+ > public void initializePolymorphicSearch(MatchLocator locator) { > long start = 0; > if (BasicSearchEngine.VERBOSE) { >@@ -662,7 +681,8 @@ > > int level = resolveLevelForType(qualifiedPattern, type); > if (level != IMPOSSIBLE_MATCH) { >- if (!type.isAbstract() && !type.isInterface()) { // if concrete class, then method is overridden >+ MethodBinding method = argumentTypes == null ? null : getMethodBinding(type, argumentTypes); >+ if ((method != null && !method.isAbstract() || !type.isAbstract()) && !type.isInterface()) { // if concrete, then method is overridden > level |= OVERRIDDEN_METHOD_FLAVOR; > } > return level; >@@ -674,28 +694,15 @@ > if (level != IMPOSSIBLE_MATCH) { > if (argumentTypes != null) { > // need to verify if method may be overridden >- MethodBinding[] methods = type.getMethods(this.pattern.selector); >- for (int i=0, length=methods.length; i<length; i++) { >- MethodBinding method = methods[i]; >- TypeBinding[] parameters = method.parameters; >- if (argumentTypes.length == parameters.length) { >- boolean found = true; >- for (int j=0,l=parameters.length; j<l; j++) { >- if (parameters[j].erasure() != argumentTypes[j].erasure()) { >- found = false; >- break; >- } >- } >- if (found) { // one method match in hierarchy >- if ((level & OVERRIDDEN_METHOD_FLAVOR) != 0) { >- // this method is already overridden on a super class, current match is impossible >- return IMPOSSIBLE_MATCH; >- } >- if (!method.isAbstract() && !type.isInterface()) { >- // store the fact that the method is overridden >- level |= OVERRIDDEN_METHOD_FLAVOR; >- } >- } >+ MethodBinding method = getMethodBinding(type, argumentTypes); >+ if (method != null) { // one method match in hierarchy >+ if ((level & OVERRIDDEN_METHOD_FLAVOR) != 0) { >+ // this method is already overridden on a super class, current match is impossible >+ return IMPOSSIBLE_MATCH; >+ } >+ if (!method.isAbstract() && !type.isInterface()) { >+ // store the fact that the method is overridden >+ level |= OVERRIDDEN_METHOD_FLAVOR; > } > } > }
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 221065
: 139636