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 13195 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]
Proposed implementation for additional implicit info
(text/plain), 10.07 KB, created by
Frederic Fusier
on 2004-07-13 10:16:52 EDT
(
hide
)
Description:
Proposed implementation for additional implicit info
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2004-07-13 10:16:52 EDT
Size:
10.07 KB
patch
obsolete
>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 13 Jul 2004 13:55:36 -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.newConstructorReferenceMatch(element, accuracy, offset, length, type, synthetic); >+ } >+ } >+ } else if (reference instanceof ConstructorDeclaration) { >+ ConstructorDeclaration constructor = (ConstructorDeclaration) reference; >+ ExplicitConstructorCall call = constructor.constructorCall; >+ boolean synthetic = call != null && call.isSuperAccess(); >+ match = locator.newConstructorReferenceMatch(element, accuracy, offset, length, constructor, synthetic); >+ } >+ } >+ 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 13 Jul 2004 13:55:36 -0000 >@@ -994,6 +994,18 @@ > 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, >@@ -1342,7 +1354,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 +1547,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/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 13 Jul 2004 13:55: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 13 Jul 2004 13:55:36 -0000 >@@ -251,6 +251,9 @@ > 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) > } >Index: search/org/eclipse/jdt/core/search/ConstructorReferenceMatch.java >=================================================================== >RCS file: search/org/eclipse/jdt/core/search/ConstructorReferenceMatch.java >diff -N search/org/eclipse/jdt/core/search/ConstructorReferenceMatch.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/jdt/core/search/ConstructorReferenceMatch.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.search; >+ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.jdt.core.IJavaElement; >+ >+/** >+ * A Java search match that represents a constructor reference. >+ * The element is the inner-most enclosing member that references this method. >+ * <p> >+ * This class is intended to be instantiated and subclassed by clients. >+ * </p> >+ * >+ * @since 3.1 >+ */ >+public class ConstructorReferenceMatch extends SearchMatch { >+ >+ private boolean synthetic; >+ >+ /** >+ * Creates a new method reference match. >+ * >+ * @param enclosingElement the inner-most enclosing member that references this method >+ * @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 synthetic <code>true</code> if this search match is a synthetic constructor >+ * <code>false</code> otherwise >+ * @param participant the search participant that created the match >+ * @param resource the resource of the element >+ */ >+ public ConstructorReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, boolean synthetic, SearchParticipant participant, IResource resource) { >+ super(enclosingElement, accuracy, offset, length, participant, resource); >+ setInsideDocComment(insideDocComment); >+ this.synthetic = synthetic; >+ } >+ >+ /** >+ * Returns whether the constructor reference is synthetic or not. >+ * Note that a constructor reference can be synthetic when default constructor declaration is used >+ * or imlicit super constructor is called. >+ * >+ * @return whether the constructor reference is synthetic or not. >+ */ >+ public final boolean isSynthetic() { >+ return this.synthetic; >+ } >+}
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