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 18378 Details for
Bug 83319
[1.5][search] Search does not find references to statically imported methods
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for the implementation of this functionality
v00.txt (text/plain), 6.79 KB, created by
Frederic Fusier
on 2005-03-01 07:30:54 EST
(
hide
)
Description:
Patch for the implementation of this functionality
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2005-03-01 07:30:54 EST
Size:
6.79 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.37 >diff -u -r1.37 MethodLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 28 Feb 2005 14:20:47 -0000 1.37 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 1 Mar 2005 10:38:11 -0000 >@@ -56,7 +56,25 @@ > protected boolean isVirtualInvoke(MethodBinding method, MessageSend messageSend) { > return !method.isStatic() && !method.isPrivate() && !messageSend.isSuperAccess(); > } >-//public int match(ASTNode node, MatchingNodeSet nodeSet) - SKIP IT >+public int match(ASTNode node, MatchingNodeSet nodeSet) { >+ int declarationsLevel = IMPOSSIBLE_MATCH; >+ if (this.pattern.findReferences) { >+ if (node instanceof ImportReference) { >+ // With static import, we can have static method reference in import reference >+ ImportReference importRef = (ImportReference) node; >+ int length = importRef.tokens.length-1; >+ if (importRef.isStatic() && !importRef.onDemand && matchesName(this.pattern.selector, importRef.tokens[length])) { >+ char[][] compoundName = new char[length][]; >+ System.arraycopy(importRef.tokens, 0, compoundName, 0, length); >+ char[] declaringType = CharOperation.concat(pattern.declaringQualification, pattern.declaringSimpleName, '.'); >+ if (matchesName(declaringType, CharOperation.concatWith(compoundName, '.'))) { >+ declarationsLevel = ((InternalSearchPattern)this.pattern).mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; >+ } >+ } >+ } >+ } >+ return nodeSet.addMatch(node, declarationsLevel); >+} > //public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) - SKIP IT > //public int match(Expression node, MatchingNodeSet nodeSet) - SKIP IT > //public int match(FieldDeclaration node, MatchingNodeSet nodeSet) - SKIP IT >@@ -107,10 +125,19 @@ > > protected int matchContainer() { > if (this.pattern.findReferences) { >- // need to look almost everywhere to find in javadocs >- return CLASS_CONTAINER | METHOD_CONTAINER | FIELD_CONTAINER; >+ // need to look almost everywhere to find in javadocs and static import >+ return ALL_CONTAINER; > } > return CLASS_CONTAINER; >+} >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.core.search.matching.PatternLocator#matchLevelAndReportImportRef(org.eclipse.jdt.internal.compiler.ast.ImportReference, org.eclipse.jdt.internal.compiler.lookup.Binding, org.eclipse.jdt.internal.core.search.matching.MatchLocator) >+ * Accept to report match of static field on static import >+ */ >+protected void matchLevelAndReportImportRef(ImportReference importRef, Binding binding, MatchLocator locator) throws CoreException { >+ if (importRef.isStatic() && binding instanceof MethodBinding) { >+ super.matchLevelAndReportImportRef(importRef, binding, locator); >+ } > } > protected int matchMethod(MethodBinding method) { > if (!matchesName(this.pattern.selector, method.selector)) return IMPOSSIBLE_MATCH; >Index: search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java,v >retrieving revision 1.24 >diff -u -r1.24 PackageReferenceLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java 27 Feb 2005 23:00:11 -0000 1.24 >+++ search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java 1 Mar 2005 10:38:12 -0000 >@@ -129,6 +129,10 @@ > FieldBinding fieldBinding = (FieldBinding) binding; > if (!fieldBinding.isStatic()) return; > refBinding = fieldBinding.declaringClass; >+ } else if (binding instanceof MethodBinding) { >+ MethodBinding methodBinding = (MethodBinding) binding; >+ if (!methodBinding.isStatic()) return; >+ refBinding = methodBinding.declaringClass; > } else if (binding instanceof MemberTypeBinding) { > MemberTypeBinding memberBinding = (MemberTypeBinding) binding; > if (!memberBinding.isStatic()) return; >Index: search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java,v >retrieving revision 1.38 >diff -u -r1.38 TypeReferenceLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java 28 Feb 2005 14:20:56 -0000 1.38 >+++ search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java 1 Mar 2005 10:38:14 -0000 >@@ -123,10 +123,27 @@ > FieldBinding fieldBinding = (FieldBinding) binding; > if (!fieldBinding.isStatic()) return; > refBinding = fieldBinding.declaringClass; >+ } else if (binding instanceof MethodBinding) { >+ MethodBinding methodBinding = (MethodBinding) binding; >+ if (!methodBinding.isStatic()) return; >+ refBinding = methodBinding.declaringClass; > } else if (binding instanceof MemberTypeBinding) { > MemberTypeBinding memberBinding = (MemberTypeBinding) binding; > if (!memberBinding.isStatic()) return; > } >+ // resolve and report >+ int level = resolveLevel(refBinding); >+ if (level >= INACCURATE_MATCH) { >+ matchReportImportRef( >+ importRef, >+ binding, >+ locator.createImportHandle(importRef), >+ level == ACCURATE_MATCH >+ ? SearchMatch.A_ACCURATE >+ : SearchMatch.A_INACCURATE, >+ locator); >+ } >+ return; > } > super.matchLevelAndReportImportRef(importRef, refBinding, locator); > } >@@ -159,11 +176,21 @@ > } > > // Try to find best selection for match >+ ReferenceBinding typeBinding = null; >+ boolean lastButOne = false; > if (binding instanceof ReferenceBinding) { >- ReferenceBinding typeBinding = (ReferenceBinding) binding; >+ typeBinding = (ReferenceBinding) binding; >+ } else if (binding instanceof FieldBinding) { // may happen for static import >+ typeBinding = ((FieldBinding)binding).declaringClass; >+ lastButOne = importRef.isStatic() && !importRef.onDemand; >+ } else if (binding instanceof MethodBinding) { // may happen for static import >+ typeBinding = ((MethodBinding)binding).declaringClass; >+ lastButOne = importRef.isStatic() && !importRef.onDemand; >+ } >+ if (typeBinding != null) { > int lastIndex = importRef.tokens.length - 1; >- if (importRef.isStatic() && !importRef.onDemand && !typeBinding.isMemberType()) { >- // for field static import, do not use last token >+ if (lastButOne) { >+ // for field or method static import, use last but one token > lastIndex--; > } > if (typeBinding instanceof ProblemReferenceBinding) {
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 83319
: 18378