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 23641 Details for
Bug 100772
[1.5][search] Search for declarations in hierarchy reports too many matches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to fix this issue
v00.txt (text/plain), 5.62 KB, created by
Frederic Fusier
on 2005-06-21 12:28:25 EDT
(
hide
)
Description:
Patch to fix this issue
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2005-06-21 12:28:25 EDT
Size:
5.62 KB
patch
obsolete
>Index: search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java,v >retrieving revision 1.56 >diff -u -r1.56 MethodLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 15 Jun 2005 06:30:08 -0000 1.56 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 21 Jun 2005 16:19:52 -0000 >@@ -50,49 +50,61 @@ > } > } > /* >- * Return whether a method may override a method in super classes erasures or not. >+ * Return possible type hierarchy method which may override a given method binding. > */ >-private boolean isErasureMethodOverride(ReferenceBinding type, MethodBinding method) { >- if (type == null) return false; >+private MethodBinding possibleOverriddenMethod(ReferenceBinding type, MethodBinding method) { >+ if (type == null) return null; > > // matches superclass > if (!type.isInterface() && !CharOperation.equals(type.compoundName, TypeConstants.JAVA_LANG_OBJECT)) { > ReferenceBinding superClass = type.superclass(); > if (superClass.isParameterizedType()) { >+ MethodBinding[] methods = superClass.getMethods(this.pattern.selector); >+ int length = methods.length; >+ for (int i = 0; i<length; i++) { >+ if (methods[i].areParametersEqual(method)) return methods[i]; >+ } > TypeBinding erasure = ((ParameterizedTypeBinding)superClass).erasure(); > if (erasure instanceof ReferenceBinding) { >- MethodBinding[] methods = superClass.getMethods(this.pattern.selector); >- int length = methods.length; >+ methods = ((ReferenceBinding)erasure).getMethods(this.pattern.selector); >+ length = methods.length; > for (int i = 0; i<length; i++) { >- if (methods[i].areParametersEqual(method)) return true; >+ if (methods[i].areParametersEqual(method)) return methods[i]; > } > } > } >- if (isErasureMethodOverride(superClass, method)) { >- return true; >+ MethodBinding possibleMethod = possibleOverriddenMethod(superClass, method); >+ if (possibleMethod != null) { >+ return possibleMethod; > } > } > > // matches interfaces > ReferenceBinding[] interfaces = type.superInterfaces(); >- if (interfaces == null) return false; >+ if (interfaces == null) return null; > int iLength = interfaces.length; > for (int i = 0; i<iLength; i++) { > if (interfaces[i].isParameterizedType()) { >+ MethodBinding[] methods = interfaces[i].getMethods(this.pattern.selector); >+ int length = methods.length; >+ for (int j = 0; j<length; j++) { >+ if (methods[i].areParametersEqual(method)) return methods[i]; >+ } > TypeBinding erasure = ((ParameterizedTypeBinding)interfaces[i]).erasure(); > if (erasure instanceof ReferenceBinding) { >- MethodBinding[] methods = ((ReferenceBinding)erasure).getMethods(this.pattern.selector); >- int length = methods.length; >+ methods = ((ReferenceBinding)erasure).getMethods(this.pattern.selector); >+ length = methods.length; > for (int j = 0; j<length; j++) { >- if (methods[i].areParametersEqual(method)) return true; >+ if (methods[i].areParametersEqual(method)) return methods[i]; > } > } > } >- if (isErasureMethodOverride(interfaces[i], method)) { >- return true; >+ MethodBinding possibleMethod = possibleOverriddenMethod(interfaces[i], method); >+ if (possibleMethod != null) { >+ return possibleMethod; > } > } >- return false; >+ return null; > } > /* > * Return whether a type name is in pattern all super declaring types names. >@@ -423,14 +435,16 @@ > } > // If arguments are not equals then try to see if method arguments can match erasures in hierarchy > if (!equals && this.pattern.findDeclarations && this.mayBeGeneric) { >- if (isErasureMethodOverride(methodBinding.declaringClass, methodBinding)) { >+ MethodBinding possibleMethod = possibleOverriddenMethod(methodBinding.declaringClass, methodBinding); >+ if (possibleMethod != null && methodsParametersEqual(methodBinding, possibleMethod)) { > return super.newDeclarationMatch(reference, element, elementBinding, accuracy, length, locator); > } > if (isTypeInSuperDeclaringTypeNames(methodBinding.declaringClass.compoundName)) { > MethodBinding patternBinding = locator.getMethodBinding(this.pattern); > if (patternBinding != null) { > patternBinding = patternBinding.original(); >- if (!isErasureMethodOverride(patternBinding.declaringClass, patternBinding)) { >+ possibleMethod = possibleOverriddenMethod(patternBinding.declaringClass, patternBinding); >+ if (possibleMethod == null || !methodsParametersEqual(possibleMethod, patternBinding)) { > return null; > } > } >@@ -441,6 +455,21 @@ > } > return super.newDeclarationMatch(reference, element, elementBinding, accuracy, length, locator); > } >+/* >+ * Return whether 2 methods parameters are equals or not. >+ */ >+private boolean methodsParametersEqual(MethodBinding first, MethodBinding second) { >+ TypeBinding[] firstParameters = first.parameters; >+ TypeBinding[] secondParameters = second.parameters; >+ if (firstParameters == secondParameters) return true; >+ >+ int length = firstParameters.length; >+ if (length != secondParameters.length) return false; >+ >+ for (int i = 0; i < length; i++) >+ if (firstParameters[i] != secondParameters[i]) return false; >+ return true; >+} > protected void reportDeclaration(MethodBinding methodBinding, MatchLocator locator, SimpleSet knownMethods) throws CoreException { > ReferenceBinding declaringClass = methodBinding.declaringClass; > IType type = locator.lookupType(declaringClass);
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 100772
:
23641
|
24462
|
24463
|
24476
|
24477