diff options
author | Frederic Fusier | 2005-03-01 17:27:49 +0000 |
---|---|---|
committer | Frederic Fusier | 2005-03-01 17:27:49 +0000 |
commit | c79af2ee01d3f2093b2668c0a663bf8f76d7429f (patch) | |
tree | e24284853d3601a0d4698b7ddbf8e0f69d72b215 /org.eclipse.jdt.core | |
parent | c87dd117aac30a89b6ea22519637d9f69471ec0b (diff) | |
download | eclipse.jdt.core-c79af2ee01d3f2093b2668c0a663bf8f76d7429f.tar.gz eclipse.jdt.core-c79af2ee01d3f2093b2668c0a663bf8f76d7429f.tar.xz eclipse.jdt.core-c79af2ee01d3f2093b2668c0a663bf8f76d7429f.zip |
86901
Diffstat (limited to 'org.eclipse.jdt.core')
9 files changed, 47 insertions, 34 deletions
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html index af4da42922..c970ed936d 100644 --- a/org.eclipse.jdt.core/buildnotes_jdt-core.html +++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html @@ -50,7 +50,8 @@ What's new in this drop</h2> </ul> <h3>Problem Reports Fixed</h3> - +<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=86901">86901</a> +[1.5][search] Static import method references not found in unused import <a name="v_539"></a> <p><hr><h1> diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java index 302b5e945e..4f8f9fb6a8 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java @@ -449,7 +449,12 @@ protected void consumeSingleStaticImportDeclarationName() { // => accept unknown ref on identifier int length = impt.tokens.length-1; int start = (int) (impt.sourcePositions[length] >>> 32); - requestor.acceptUnknownReference(impt.tokens[length], start); + char[] last = impt.tokens[length]; + // accept all possible kind for last name, index users will have to select the right one... + // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=86901 + requestor.acceptFieldReference(last, start); + requestor.acceptMethodReference(last, 0,start); + requestor.acceptTypeReference(last, start); // accept type name if (length > 0) { char[][] compoundName = new char[length][]; diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java index a5de8c6976..347b54700b 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java @@ -696,7 +696,6 @@ public abstract class SearchPattern extends InternalSearchPattern { parameterTypeQualifications, parameterTypeSimpleNames, parameterTypeSignatures, - false, typeArguments, matchRule); } else { @@ -713,7 +712,6 @@ public abstract class SearchPattern extends InternalSearchPattern { parameterTypeQualifications, parameterTypeSimpleNames, parameterTypeSignatures, - false, typeArguments, matchRule); } @@ -1018,7 +1016,6 @@ public abstract class SearchPattern extends InternalSearchPattern { char[] selector = method.getElementName().toCharArray(); char[] returnSimpleName; char[] returnQualification; - boolean varargs = false; String returnSignature; try { returnSignature = method.getReturnType(); @@ -1036,7 +1033,6 @@ public abstract class SearchPattern extends InternalSearchPattern { CharOperation.concat(IIndexConstants.ONE_STAR, returnQualification); } } - varargs = Flags.isVarargs(method.getFlags()); } catch (JavaModelException e) { return null; } @@ -1087,7 +1083,6 @@ public abstract class SearchPattern extends InternalSearchPattern { parameterSimpleNames, parameterSignatures, method, - varargs, matchRule); } else { searchPattern = @@ -1103,7 +1098,6 @@ public abstract class SearchPattern extends InternalSearchPattern { parameterQualifications, parameterSimpleNames, parameterSignatures, - varargs, method, matchRule); } diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DiskIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DiskIndex.java index ca6ef7734d..f1db06f803 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DiskIndex.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DiskIndex.java @@ -13,6 +13,7 @@ package org.eclipse.jdt.internal.core.index; import java.io.*; import org.eclipse.jdt.core.search.*; +import org.eclipse.jdt.internal.core.search.matching.JavaSearchPattern; import org.eclipse.jdt.internal.core.util.*; import org.eclipse.jdt.internal.compiler.util.HashtableOfIntValues; import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; @@ -140,7 +141,8 @@ HashtableOfObject addQueryResults(char[][] categories, char[] key, int matchRule if (this.categoryOffsets == null) return results; // file is empty - if (matchRule == SearchPattern.R_EXACT_MATCH + SearchPattern.R_CASE_SENSITIVE) { + int rule = matchRule & JavaSearchPattern.MATCH_RULE_INDEX_MASK; + if (rule == SearchPattern.R_EXACT_MATCH + SearchPattern.R_CASE_SENSITIVE) { for (int i = 0, l = categories.length; i < l; i++) { HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false); if (wordsToDocNumbers != null && wordsToDocNumbers.containsKey(key)) diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorLocator.java index 12d80696ca..431b63cd62 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorLocator.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorLocator.java @@ -35,7 +35,7 @@ public int match(ASTNode node, MatchingNodeSet nodeSet) { // interested in Expli if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; if (!(node instanceof ExplicitConstructorCall)) return IMPOSSIBLE_MATCH; - if (this.pattern.parameterSimpleNames != null && !this.pattern.varargs) { + if (this.pattern.parameterSimpleNames != null && this.pattern.shouldCountParameter()) { int length = this.pattern.parameterSimpleNames.length; Expression[] args = ((ExplicitConstructorCall) node).arguments; int argsLength = args == null ? 0 : args.length; @@ -60,7 +60,7 @@ public int match(Expression node, MatchingNodeSet nodeSet) { // interested in Al if (this.pattern.declaringSimpleName != null && !matchesName(this.pattern.declaringSimpleName, typeName[typeName.length-1])) return IMPOSSIBLE_MATCH; - if (this.pattern.parameterSimpleNames != null && !this.pattern.varargs) { + if (this.pattern.parameterSimpleNames != null && this.pattern.shouldCountParameter()) { int length = this.pattern.parameterSimpleNames.length; Expression[] args = allocation.arguments; int argsLength = args == null ? 0 : args.length; @@ -80,7 +80,7 @@ public int match(FieldDeclaration field, MatchingNodeSet nodeSet) { return IMPOSSIBLE_MATCH; } - if (this.pattern.parameterSimpleNames != null && !this.pattern.varargs) { + if (this.pattern.parameterSimpleNames != null && this.pattern.shouldCountParameter()) { int length = this.pattern.parameterSimpleNames.length; Expression[] args = allocation.arguments; int argsLength = args == null ? 0 : args.length; diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java index 2c13fb49d0..1e6c055092 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java @@ -13,7 +13,9 @@ package org.eclipse.jdt.internal.core.search.matching; import java.io.IOException; import org.eclipse.jdt.core.BindingKey; +import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IMethod; +import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.search.SearchPattern; import org.eclipse.jdt.internal.core.index.EntryResult; @@ -32,7 +34,7 @@ public char[] declaringSimpleName; public char[][] parameterQualifications; public char[][] parameterSimpleNames; public int parameterCount; -public boolean varargs; +public int flags = 0; // Signatures and arguments for generic search char[][][] parametersTypeSignatures; @@ -65,7 +67,6 @@ public ConstructorPattern( char[] declaringQualification, char[][] parameterQualifications, char[][] parameterSimpleNames, - boolean varargs, int matchRule) { this(matchRule); @@ -86,7 +87,6 @@ public ConstructorPattern( } else { this.parameterCount = -1; } - this.varargs = varargs; ((InternalSearchPattern)this).mustResolve = mustResolve(); } /* @@ -101,7 +101,7 @@ public ConstructorPattern( char[][] parameterSimpleNames, String[] parameterSignatures, IMethod method, - boolean varargs, +// boolean varargs, int matchRule) { this(findDeclarations, @@ -110,9 +110,15 @@ public ConstructorPattern( declaringQualification, parameterQualifications, parameterSimpleNames, - varargs, matchRule); + // Set flags + try { + this.flags = method.getFlags(); + } catch (JavaModelException e) { + // do nothing + } + // Get unique key for parameterized constructors String genericDeclaringTypeSignature = null; BindingKey key; @@ -159,7 +165,6 @@ public ConstructorPattern( char[][] parameterQualifications, char[][] parameterSimpleNames, String[] parameterSignatures, - boolean varargs, char[][] arguments, int matchRule) { @@ -169,7 +174,6 @@ public ConstructorPattern( declaringQualification, parameterQualifications, parameterSimpleNames, - varargs, matchRule); // Store type signature and arguments for declaring type @@ -226,7 +230,7 @@ boolean hasConstructorParameters() { public boolean matchesDecodedKey(SearchPattern decodedPattern) { ConstructorPattern pattern = (ConstructorPattern) decodedPattern; - return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs) + return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || !shouldCountParameter()) && matchesName(this.declaringSimpleName, pattern.declaringSimpleName); } protected boolean mustResolve() { @@ -244,7 +248,7 @@ EntryResult[] queryIn(Index index) throws IOException { switch(getMatchMode()) { case R_EXACT_MATCH : - if (!this.varargs && this.declaringSimpleName != null && this.parameterCount >= 0) + if (shouldCountParameter() && this.declaringSimpleName != null && this.parameterCount >= 0) key = createIndexKey(this.declaringSimpleName, this.parameterCount); else // do a prefix query with the declaringSimpleName matchRule = matchRule - R_EXACT_MATCH + R_PREFIX_MATCH; @@ -253,7 +257,7 @@ EntryResult[] queryIn(Index index) throws IOException { // do a prefix query with the declaringSimpleName break; case R_PATTERN_MATCH : - if (!this.varargs && this.parameterCount >= 0) + if (shouldCountParameter() && this.parameterCount >= 0) key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount); else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*') key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR); @@ -291,4 +295,7 @@ protected StringBuffer print(StringBuffer output) { output.append(')'); return super.print(output); } +boolean shouldCountParameter() { + return (this.flags & Flags.AccStatic) == 0 && (this.flags & Flags.AccVarargs) == 0; +} } diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedMethodsPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedMethodsPattern.java index 1bf123481c..fe58552024 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedMethodsPattern.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedMethodsPattern.java @@ -21,7 +21,7 @@ protected IJavaElement enclosingElement; protected SimpleSet knownMethods; public DeclarationOfReferencedMethodsPattern(IJavaElement enclosingElement) { - super(false, true, null, null, null, null, null, null, null, false, null, R_PATTERN_MATCH); + super(false, true, null, null, null, null, null, null, null, null, R_PATTERN_MATCH); this.enclosingElement = enclosingElement; this.knownMethods = new SimpleSet(); diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java index 13663bf350..43d8e9cf4f 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java @@ -110,7 +110,7 @@ public int match(MessageSend node, MatchingNodeSet nodeSet) { if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; if (!matchesName(this.pattern.selector, node.selector)) return IMPOSSIBLE_MATCH; - if (this.pattern.parameterSimpleNames != null && !this.pattern.varargs) { + if (this.pattern.parameterSimpleNames != null && this.pattern.shouldCountParameter()) { int length = this.pattern.parameterSimpleNames.length; ASTNode[] args = node.arguments; int argsLength = args == null ? 0 : args.length; diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java index 7eb12b03db..14497dc582 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java @@ -35,7 +35,7 @@ public char[] returnSimpleName; public char[][] parameterQualifications; public char[][] parameterSimpleNames; public int parameterCount; -public boolean varargs; +public int flags = 0; // extra reference info protected IType declaringType; @@ -76,7 +76,6 @@ public MethodPattern( char[] returnSimpleName, char[][] parameterQualifications, char[][] parameterSimpleNames, - boolean varargs, IType declaringType, int matchRule) { @@ -101,7 +100,6 @@ public MethodPattern( } else { this.parameterCount = -1; } - this.varargs = varargs; this.declaringType = declaringType; ((InternalSearchPattern)this).mustResolve = mustResolve(); } @@ -120,7 +118,6 @@ public MethodPattern( char[][] parameterQualifications, char[][] parameterSimpleNames, String[] parameterSignatures, - boolean varargs, IMethod method, int matchRule) { @@ -133,9 +130,15 @@ public MethodPattern( returnSimpleName, parameterQualifications, parameterSimpleNames, - varargs, method.getDeclaringType(), matchRule); + + // Set flags + try { + this.flags = method.getFlags(); + } catch (JavaModelException e) { + // do nothing + } // Get unique key for parameterized constructors String genericDeclaringTypeSignature = null; @@ -194,7 +197,6 @@ public MethodPattern( char[][] parameterQualifications, char[][] parameterSimpleNames, String[] parameterSignatures, - boolean varargs, char[][] arguments, int matchRule) { @@ -207,7 +209,6 @@ public MethodPattern( returnSimpleName, parameterQualifications, parameterSimpleNames, - varargs, null, matchRule); @@ -269,7 +270,7 @@ boolean isPolymorphicSearch() { public boolean matchesDecodedKey(SearchPattern decodedPattern) { MethodPattern pattern = (MethodPattern) decodedPattern; - return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs) + return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || !shouldCountParameter()) && matchesName(this.selector, pattern.selector); } /** @@ -297,7 +298,7 @@ EntryResult[] queryIn(Index index) throws IOException { switch(getMatchMode()) { case R_EXACT_MATCH : - if (!this.varargs && this.selector != null && this.parameterCount >= 0) + if (shouldCountParameter() && this.selector != null && this.parameterCount >= 0) key = createIndexKey(this.selector, this.parameterCount); else // do a prefix query with the selector matchRule = matchRule - R_EXACT_MATCH + R_PREFIX_MATCH; @@ -306,7 +307,7 @@ EntryResult[] queryIn(Index index) throws IOException { // do a prefix query with the selector break; case R_PATTERN_MATCH : - if (!this.varargs && this.parameterCount >= 0) + if (shouldCountParameter() && this.parameterCount >= 0) key = createIndexKey(this.selector == null ? ONE_STAR : this.selector, this.parameterCount); else if (this.selector != null && this.selector[this.selector.length - 1] != '*') key = CharOperation.concat(this.selector, ONE_STAR, SEPARATOR); @@ -356,4 +357,7 @@ protected StringBuffer print(StringBuffer output) { output.append("*"); //$NON-NLS-1$ return super.print(output); } +boolean shouldCountParameter() { + return (this.flags & Flags.AccStatic) == 0 && (this.flags & Flags.AccVarargs) == 0; +} } |