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 13307 Details for
Bug 43587
Searching for references to default constructors reports questionable results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Other proposal: without new match class but using existing one
v01.txt (text/plain), 12.59 KB, created by
Frederic Fusier
on 2004-07-15 12:23:57 EDT
(
hide
)
Description:
Other proposal: without new match class but using existing one
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2004-07-15 12:23:57 EDT
Size:
12.59 KB
patch
obsolete
>Index: search/org/eclipse/jdt/core/search/MethodReferenceMatch.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/MethodReferenceMatch.java,v >retrieving revision 1.10 >diff -u -r1.10 MethodReferenceMatch.java >--- search/org/eclipse/jdt/core/search/MethodReferenceMatch.java 27 May 2004 10:12:33 -0000 1.10 >+++ search/org/eclipse/jdt/core/search/MethodReferenceMatch.java 14 Jul 2004 18:20:26 -0000 >@@ -23,6 +23,8 @@ > * @since 3.0 > */ > public class MethodReferenceMatch extends SearchMatch { >+ private boolean constructor; >+ private boolean synthetic; > > /** > * Creates a new method reference match. >@@ -31,13 +33,37 @@ > * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE} > * @param offset the offset the match starts at, or -1 if unknown > * @param length the length of the match, or -1 if unknown >- * @param insideDocComment <code>true</code> if this search match is inside a doc > * comment, and <code>false</code> otherwise >+ * @param constructor <code>true</code> if this search match is a constructor >+ * <code>false</code> otherwise >+ * @param synthetic <code>true</code> if this search match is a synthetic element >+ * <code>false</code> otherwise >+ * @param insideDocComment <code>true</code> if this search match is inside a doc > * @param participant the search participant that created the match > * @param resource the resource of the element > */ >- public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) { >+ public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean constructor, boolean synthetic, boolean insideDocComment, SearchParticipant participant, IResource resource) { > super(enclosingElement, accuracy, offset, length, participant, resource); > setInsideDocComment(insideDocComment); >+ this.constructor = constructor; >+ this.synthetic = synthetic; >+ } >+ >+ /** >+ * @return Returns whether the reference is on a constructor or not. >+ */ >+ public final boolean isConstructor() { >+ return this.constructor; >+ } >+ >+ /** >+ * Returns whether the reference is on a synthetic element. >+ * Note that for a constructor reference, it can be synthetic when default constructor >+ * declaration is used or implicit super constructor is called. >+ * >+ * @return whether the reference is synthetic or not. >+ */ >+ public final boolean isSynthetic() { >+ return this.synthetic; > } > } >Index: search/org/eclipse/jdt/internal/core/search/matching/ConstructorLocator.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorLocator.java,v >retrieving revision 1.11 >diff -u -r1.11 ConstructorLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/ConstructorLocator.java 1 Jul 2004 09:31:54 -0000 1.11 >+++ search/org/eclipse/jdt/internal/core/search/matching/ConstructorLocator.java 14 Jul 2004 18:20:27 -0000 >@@ -11,6 +11,7 @@ > package org.eclipse.jdt.internal.core.search.matching; > > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.search.SearchMatch; > import org.eclipse.jdt.internal.compiler.ast.*; > import org.eclipse.jdt.internal.compiler.lookup.Binding; > import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; >@@ -114,6 +115,33 @@ > } > > return ((InternalSearchPattern)this.pattern).mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; >+} >+public SearchMatch newDeclarationMatch(ASTNode reference, IJavaElement element, int accuracy, int length, MatchLocator locator) { >+ SearchMatch match = null; >+ int offset = reference.sourceStart; >+ if (this.pattern.findReferences) { >+ if (reference instanceof TypeDeclaration) { >+ TypeDeclaration type = (TypeDeclaration) reference; >+ AbstractMethodDeclaration[] methods = type.methods; >+ if (methods != null) { >+ for (int i = 0, max = methods.length; i < max; i++) { >+ AbstractMethodDeclaration method = methods[i]; >+ boolean synthetic = method.isDefaultConstructor() && method.sourceStart < type.bodyStart; >+ match = locator.newMethodReferenceMatch(element, accuracy, offset, length, method.isConstructor(), synthetic, method); >+ } >+ } >+ } else if (reference instanceof ConstructorDeclaration) { >+ ConstructorDeclaration constructor = (ConstructorDeclaration) reference; >+ ExplicitConstructorCall call = constructor.constructorCall; >+ boolean synthetic = call != null && call.isSuperAccess(); >+ match = locator.newMethodReferenceMatch(element, accuracy, offset, length, constructor.isConstructor(), synthetic, constructor); >+ } >+ } >+ if (match != null) { >+ return match; >+ } >+ // super implementation... >+ return locator.newDeclarationMatch(element, accuracy, reference.sourceStart, length); > } > public int resolveLevel(ASTNode node) { > if (this.pattern.findReferences) { >Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v >retrieving revision 1.188 >diff -u -r1.188 MatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 7 Jul 2004 15:35:34 -0000 1.188 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 14 Jul 2004 18:20:32 -0000 >@@ -994,6 +994,20 @@ > if (type.exists()) return type; > return null; > } >+/* >+public SearchMatch newConstructorReferenceMatch( >+ IJavaElement enclosingElement, >+ int accuracy, >+ int offset, >+ int length, >+ ASTNode reference, >+ boolean synthetic) { >+ SearchParticipant participant = getParticipant(); >+ IResource resource = this.currentPossibleMatch.resource; >+ boolean insideDocComment = (reference.bits & ASTNode.InsideJavadoc) != 0; >+ return new ConstructorReferenceMatch(enclosingElement, accuracy, offset, length, insideDocComment, synthetic, participant, resource); >+} >+*/ > public SearchMatch newDeclarationMatch( > IJavaElement element, > int accuracy, >@@ -1064,11 +1078,13 @@ > int accuracy, > int offset, > int length, >+ boolean isConstructor, >+ boolean isSynthetic, > ASTNode reference) { > SearchParticipant participant = getParticipant(); > IResource resource = this.currentPossibleMatch.resource; > boolean insideDocComment = (reference.bits & ASTNode.InsideJavadoc) != 0; >- return new MethodReferenceMatch(enclosingElement, accuracy, offset, length, insideDocComment, participant, resource); >+ return new MethodReferenceMatch(enclosingElement, accuracy, offset, length, isConstructor, isSynthetic, insideDocComment, participant, resource); > } > > public SearchMatch newPackageReferenceMatch( >@@ -1342,7 +1358,8 @@ > } > if (encloses(enclosingElement)) { > int length = scanner.currentPosition - nameSourceStart; >- SearchMatch match = newDeclarationMatch(enclosingElement, accuracy, nameSourceStart, length); >+// SearchMatch match = newDeclarationMatch(enclosingElement, accuracy, nameSourceStart, length); >+ SearchMatch match = this.patternLocator.newDeclarationMatch(method, enclosingElement, accuracy, length, this); > report(match); > } > } >@@ -1534,7 +1551,8 @@ > // report the type declaration > if (accuracy > -1 && encloses(enclosingElement)) { > int offset = type.sourceStart; >- SearchMatch match = newDeclarationMatch(enclosingElement, accuracy, offset, type.sourceEnd-offset+1); >+// SearchMatch match = newDeclarationMatch(enclosingElement, accuracy, offset, type.sourceEnd-offset+1); >+ SearchMatch match = this.patternLocator.newDeclarationMatch(type, enclosingElement, accuracy, type.sourceEnd-offset+1, this); > report(match); > } > >Index: search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java,v >retrieving revision 1.21 >diff -u -r1.21 MethodLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 1 Jul 2004 09:31:54 -0000 1.21 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 14 Jul 2004 18:20:34 -0000 >@@ -145,11 +145,11 @@ > reportDeclaration(((MessageSend) reference).binding, locator, declPattern.knownMethods); > } else if (this.pattern.findReferences && reference instanceof MessageSend) { > int offset = (int) (((MessageSend) reference).nameSourcePosition >>> 32); >- SearchMatch match = locator.newMethodReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, reference); >+ SearchMatch match = locator.newMethodReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, false /*not constructor*/, false/*not synthetic*/, reference); > locator.report(match); > } else { > int offset = reference.sourceStart; >- SearchMatch match = locator.newMethodReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, reference); >+ SearchMatch match = locator.newMethodReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, false /*not constructor*/, false/*not synthetic*/, reference); > locator.report(match); > } > } >Index: search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java,v >retrieving revision 1.11 >diff -u -r1.11 OrLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java 1 Mar 2004 18:02:56 -0000 1.11 >+++ search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java 14 Jul 2004 18:20:36 -0000 >@@ -193,6 +193,24 @@ > if (closestPattern != null) > closestPattern.matchReportReference(reference, element, accuracy, locator); > } >+public SearchMatch newDeclarationMatch(ASTNode reference, IJavaElement element, int accuracy, int length, MatchLocator locator) { >+ PatternLocator closestPattern = null; >+ int level = IMPOSSIBLE_MATCH; >+ for (int i = 0, pl = this.patternLocators.length; i < pl; i++) { >+ PatternLocator patternLocator = this.patternLocators[i]; >+ int newLevel = patternLocator.referenceType() == 0 ? IMPOSSIBLE_MATCH : patternLocator.resolveLevel(reference); >+ if (newLevel > level) { >+ closestPattern = patternLocator; >+ if (newLevel == ACCURATE_MATCH) break; >+ level = newLevel; >+ } >+ } >+ if (closestPattern != null) { >+ return closestPattern.newDeclarationMatch(reference, element, accuracy, length, locator); >+ } >+ // super implementation... >+ return locator.newDeclarationMatch(element, accuracy, reference.sourceStart, length); >+} > public int resolveLevel(ASTNode node) { > int level = IMPOSSIBLE_MATCH; > for (int i = 0, length = this.patternLocators.length; i < length; i++) { >Index: search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java,v >retrieving revision 1.24 >diff -u -r1.24 PatternLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 27 Apr 2004 16:21:42 -0000 1.24 >+++ search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 14 Jul 2004 18:20:37 -0000 >@@ -241,7 +241,7 @@ > match = locator.newFieldReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, reference); > break; > case IJavaElement.METHOD: >- match = locator.newMethodReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, reference); >+ match = locator.newMethodReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, reference instanceof ExplicitConstructorCall, false/*not synthetic*/, reference); > break; > case IJavaElement.LOCAL_VARIABLE: > match = locator.newLocalVariableReferenceMatch(element, accuracy, offset, reference.sourceEnd-offset+1, reference); >@@ -250,6 +250,9 @@ > if (match != null) { > locator.report(match); > } >+} >+public SearchMatch newDeclarationMatch(ASTNode reference, IJavaElement element, int accuracy, int length, MatchLocator locator) { >+ return locator.newDeclarationMatch(element, accuracy, reference.sourceStart, length); > } > protected int referenceType() { > return 0; // defaults to unknown (a generic JavaSearchMatch will be created)
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 43587
:
13195
|
13196
| 13307