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 21157 Details for
Bug 79990
[1.5][search] Search for method declaration doesn't find method with instantiated type parameters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to implement this fix without time penalty
v02.txt (text/plain), 7.87 KB, created by
Frederic Fusier
on 2005-05-14 10:15:02 EDT
(
hide
)
Description:
Patch to implement this fix without time penalty
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2005-05-14 10:15:02 EDT
Size:
7.87 KB
patch
obsolete
>Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v >retrieving revision 1.242 >diff -u -r1.242 MatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 11 May 2005 21:08:37 -0000 1.242 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 14 May 2005 10:27:49 -0000 >@@ -1449,11 +1449,15 @@ > System.out.println("Reporting match"); //$NON-NLS-1$ > System.out.println("\tResource: " + match.getResource()); //$NON-NLS-2$//$NON-NLS-1$ > System.out.println("\tPositions: [offset=" + match.getOffset() + ", length=" + match.getLength() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- if (this.parser != null && match.getOffset() > 0 && match.getLength() > 0 && !(match.getElement() instanceof BinaryMember)) { >- String selection = new String(this.parser.scanner.source, match.getOffset(), match.getLength()); >- System.out.println("\tSelection: -->" + selection + "<--"); //$NON-NLS-1$ //$NON-NLS-2$ >+ try { >+ if (this.parser != null && match.getOffset() > 0 && match.getLength() > 0 && !(match.getElement() instanceof BinaryMember)) { >+ String selection = new String(this.parser.scanner.source, match.getOffset(), match.getLength()); >+ System.out.println("\tSelection: -->" + selection + "<--"); //$NON-NLS-1$ //$NON-NLS-2$ >+ System.out.println("\tJava element: " + ((JavaElement)match.getElement()).toStringWithAncestors()); //$NON-NLS-1$ >+ } >+ } catch (Exception e) { >+ // it's just for debug purposes... ignore all exceptions in this area > } >- System.out.println("\tJava element: " + ((JavaElement)match.getElement()).toStringWithAncestors()); //$NON-NLS-1$ > System.out.println(match.getAccuracy() == SearchMatch.A_ACCURATE > ? "\tAccuracy: EXACT_MATCH" //$NON-NLS-1$ > : "\tAccuracy: POTENTIAL_MATCH"); //$NON-NLS-1$ >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.51 >diff -u -r1.51 MethodLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 9 May 2005 13:19:30 -0000 1.51 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 14 May 2005 10:27:49 -0000 >@@ -91,8 +91,12 @@ > ASTNode[] args = node.arguments; > int argsLength = args == null ? 0 : args.length; > if (length != argsLength) return IMPOSSIBLE_MATCH; >- for (int i = 0; i < argsLength; i++) { >- if (!matchesTypeReference(this.pattern.parameterSimpleNames[i], ((Argument) args[i]).type)) return IMPOSSIBLE_MATCH; >+ // Disable filter on argument syntax to allow generic type search. >+ // (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=79990) >+ if (!this.pattern.mustResolveGeneric) { >+ for (int i = 0; i < argsLength; i++) { >+ if (!matchesTypeReference(this.pattern.parameterSimpleNames[i], ((Argument) args[i]).type)) return IMPOSSIBLE_MATCH; >+ } > } > } > >@@ -215,6 +219,54 @@ > return level; > } > /** >+ * Return if pattern method may override a method in super classes >+ * or or implement one in super interfaces of given type. >+ * @param type >+ * @return level >+ */ >+int matchOverriddenMethod(ReferenceBinding type) { >+ if (type == null) return INACCURATE_MATCH; >+ int level = IMPOSSIBLE_MATCH; >+ >+ // matches superclass >+ if (!type.isInterface() && !CharOperation.equals(type.compoundName, TypeConstants.JAVA_LANG_OBJECT)) { >+ if (type.superclass().isParameterizedType()) { >+ TypeBinding erasure = ((ParameterizedTypeBinding)type.superclass()).erasure(); >+ if (erasure instanceof ReferenceBinding) { >+ MethodBinding[] methods = ((ReferenceBinding)erasure).getMethods(this.pattern.selector); >+ int length = methods.length; >+ for (int i = 0; i<length && level == IMPOSSIBLE_MATCH; i++) { >+ level = matchMethod(methods[i]); >+ } >+ if (level != IMPOSSIBLE_MATCH) return level; >+ } >+ } >+ level = matchOverriddenMethod(type.superclass()); >+ if (level != IMPOSSIBLE_MATCH) return level; >+ } >+ >+ // matches interfaces >+ ReferenceBinding[] interfaces = type.superInterfaces(); >+ if (interfaces == null) return INACCURATE_MATCH; >+ int iLength = interfaces.length; >+ for (int i = 0; i<iLength; i++) { >+ if (interfaces[i].isParameterizedType()) { >+ TypeBinding erasure = ((ParameterizedTypeBinding)interfaces[i]).erasure(); >+ if (erasure instanceof ReferenceBinding) { >+ MethodBinding[] methods = ((ReferenceBinding)erasure).getMethods(this.pattern.selector); >+ int mLength = methods.length; >+ for (int j = 0; j<mLength && level == IMPOSSIBLE_MATCH; j++) { >+ level = matchMethod(methods[j]); >+ } >+ if (level != IMPOSSIBLE_MATCH) return level; >+ } >+ } >+ level = matchOverriddenMethod(interfaces[i]); >+ if (level != IMPOSSIBLE_MATCH) return level; >+ } >+ return IMPOSSIBLE_MATCH; >+} >+/** > * @see org.eclipse.jdt.internal.core.search.matching.PatternLocator#matchReportReference(org.eclipse.jdt.internal.compiler.ast.ASTNode, org.eclipse.jdt.core.IJavaElement, Binding, int, org.eclipse.jdt.internal.core.search.matching.MatchLocator) > */ > protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException { >@@ -415,8 +467,12 @@ > int methodLevel = matchMethod(method); > if (methodLevel == IMPOSSIBLE_MATCH) { > if (method != method.original()) methodLevel = matchMethod(method.original()); >- if (methodLevel == IMPOSSIBLE_MATCH) return IMPOSSIBLE_MATCH; >- method = method.original(); >+ if (methodLevel == IMPOSSIBLE_MATCH && this.pattern.findDeclarations && this.pattern.mustResolveGeneric) { >+ methodLevel = matchOverriddenMethod(method.declaringClass); >+ if (methodLevel == IMPOSSIBLE_MATCH) return IMPOSSIBLE_MATCH; >+ } else { >+ method = method.original(); >+ } > } > > // declaring type >Index: search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java,v >retrieving revision 1.51 >diff -u -r1.51 MethodPattern.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java 2 May 2005 13:33:11 -0000 1.51 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java 14 May 2005 10:27:50 -0000 >@@ -36,6 +36,7 @@ > public char[][] parameterSimpleNames; > public int parameterCount; > public int flags = 0; >+public boolean mustResolveGeneric = false; > > // extra reference info > protected IType declaringType; >@@ -180,6 +181,26 @@ > // Store type signatures and arguments for method > methodArguments = extractMethodArguments(method); > if (hasMethodArguments()) ((InternalSearchPattern)this).mustResolve = true; >+ >+ // See if we must resolve specifically for generics >+ if (parameterSimpleNames != null && parameterSimpleNames.length > 0) { >+ int psLength = parameterSimpleNames.length; >+ try { >+ ITypeParameter[] typeParameters = this.declaringType.getTypeParameters(); >+ if (typeParameters != null && typeParameters.length > 0) { >+ int tpLength = typeParameters.length; >+ for (int i=0; i<psLength && !this.mustResolveGeneric; i++) { >+ for (int j=0; j<tpLength && !this.mustResolveGeneric; j++) { >+ if (CharOperation.equals(parameterSimpleNames[i], typeParameters[j].getElementName().toCharArray())) { >+ this.mustResolveGeneric = true; >+ } >+ } >+ } >+ } >+ } catch (JavaModelException e) { >+ // ignore >+ } >+ } > } > /* > * Instanciate a method pattern with signatures for generics search
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 79990
:
21125
| 21157