### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java,v
retrieving revision 1.4
diff -u -r1.4 AndLocator.java
--- search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java 24 Jun 2008 15:23:48 -0000 1.4
+++ search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java 3 Sep 2010 11:27:51 -0000
@@ -255,4 +255,13 @@
}
return level;
}
+/* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.core.search.matching.PatternLocator#setFlavors(int)
+ */
+void setFlavors(int flavors) {
+ for (int i = 0, length = this.patternLocators.length; i < length; i++) {
+ this.patternLocators[i].setFlavors(flavors);
+ }
+}
+
}
Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java,v
retrieving revision 1.87
diff -u -r1.87 MatchLocatorParser.java
--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java 11 May 2010 18:47:10 -0000 1.87
+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java 3 Sep 2010 11:27:51 -0000
@@ -256,11 +256,13 @@
}
protected void consumeClassHeaderExtends() {
+ this.patternLocator.setFlavors(PatternLocator.SUPERTYPE_REF_FLAVOR);
super.consumeClassHeaderExtends();
if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) {
TypeDeclaration typeDeclaration = (TypeDeclaration) this.astStack[this.astPtr];
this.patternLocator.match(typeDeclaration.superclass, this.nodeSet);
}
+ this.patternLocator.setFlavors(PatternLocator.NO_FLAVOR);
}
protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() {
@@ -283,6 +285,12 @@
}
}
+protected void consumeEnterAnonymousClassBody(boolean qualified) {
+ this.patternLocator.setFlavors(PatternLocator.SUPERTYPE_REF_FLAVOR);
+ super.consumeEnterAnonymousClassBody(qualified);
+ this.patternLocator.setFlavors(PatternLocator.NO_FLAVOR);
+}
+
protected void consumeEnterVariable() {
boolean isLocalDeclaration = this.nestedMethod[this.nestedType] != 0;
super.consumeEnterVariable();
@@ -337,11 +345,13 @@
}
}
protected void consumeInterfaceType() {
+ this.patternLocator.setFlavors(PatternLocator.SUPERTYPE_REF_FLAVOR);
super.consumeInterfaceType();
if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) {
TypeReference typeReference = (TypeReference) this.astStack[this.astPtr];
this.patternLocator.match(typeReference, this.nodeSet);
}
+ this.patternLocator.setFlavors(PatternLocator.NO_FLAVOR);
}
protected void consumeLocalVariableDeclaration() {
Index: search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java,v
retrieving revision 1.23
diff -u -r1.23 OrLocator.java
--- search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java 24 Jun 2008 15:23:48 -0000 1.23
+++ search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java 3 Sep 2010 11:27:51 -0000
@@ -307,4 +307,13 @@
}
return level;
}
+/* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.core.search.matching.PatternLocator#setFlavors(int)
+ */
+void setFlavors(int flavors) {
+ for (int i = 0, length = this.patternLocators.length; i < length; i++) {
+ this.patternLocators[i].setFlavors(flavors);
+ }
+}
+
}
Index: search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java,v
retrieving revision 1.78
diff -u -r1.78 PatternLocator.java
--- search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 20 May 2010 14:12:00 -0000 1.78
+++ search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 3 Sep 2010 11:27:51 -0000
@@ -39,7 +39,9 @@
public static final int ERASURE_MATCH = 4;
// Possible rule match flavors
+int flavors = 0;
// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=79866
+public static final int NO_FLAVOR = 0x0000;
public static final int EXACT_FLAVOR = 0x0010;
public static final int PREFIX_FLAVOR = 0x0020;
public static final int PATTERN_FLAVOR = 0x0040;
@@ -48,6 +50,7 @@
public static final int SUPER_INVOCATION_FLAVOR = 0x0200;
public static final int SUB_INVOCATION_FLAVOR = 0x0400;
public static final int OVERRIDDEN_METHOD_FLAVOR = 0x0800;
+public static final int SUPERTYPE_REF_FLAVOR = 0x1000;
public static final int MATCH_LEVEL_MASK = 0x0F;
public static final int FLAVORS_MASK = ~MATCH_LEVEL_MASK;
@@ -436,6 +439,17 @@
// need to do instance of checks to find out exact type of ASTNode
return IMPOSSIBLE_MATCH;
}
+/**
+ * Set the flavors for which the locator has to be focused on.
+ * If not set, the locator will accept all matches with or without flavors.
+ * When set, the locator will only accept match having the corresponding flavors.
+ *
+ * @param flavors Bits mask specifying the flavors to be accepted or
+ * 0
to ignore the flavors while accepting matches.
+ */
+void setFlavors(int flavors) {
+ this.flavors = flavors;
+}
/*
* Update pattern locator match for parameterized top level types.
* Set match raw flag and recurse to enclosing types if any...
Index: search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java,v
retrieving revision 1.18
diff -u -r1.18 SuperTypeReferenceLocator.java
--- search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java 18 Sep 2008 15:24:57 -0000 1.18
+++ search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java 3 Sep 2010 11:27:51 -0000
@@ -34,6 +34,7 @@
//public int match(Reference node, MatchingNodeSet nodeSet) - SKIP IT
//public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
public int match(TypeReference node, MatchingNodeSet nodeSet) {
+ if (this.flavors != SUPERTYPE_REF_FLAVOR) return IMPOSSIBLE_MATCH;
if (this.pattern.superSimpleName == null)
return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
#P org.eclipse.jdt.core.tests.model
Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java,v
retrieving revision 1.40
diff -u -r1.40 AbstractJavaSearchTests.java
--- src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java 25 Nov 2009 12:26:50 -0000 1.40
+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java 3 Sep 2010 11:27:53 -0000
@@ -42,10 +42,10 @@
public static List JAVA_SEARCH_SUITES = null;
protected static IJavaProject JAVA_PROJECT;
protected static boolean COPY_DIRS = true;
- protected static int EXACT_RULE = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
- protected static int EQUIVALENT_RULE = EXACT_RULE | SearchPattern.R_EQUIVALENT_MATCH;
- protected static int ERASURE_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH;
- protected static int RAW_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH | SearchPattern.R_EQUIVALENT_MATCH;
+ protected final static int EXACT_RULE = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
+ protected final static int EQUIVALENT_RULE = EXACT_RULE | SearchPattern.R_EQUIVALENT_MATCH;
+ protected final static int ERASURE_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH;
+ protected final static int RAW_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH | SearchPattern.R_EQUIVALENT_MATCH;
// ICompilationUnit[] workingCopies;
// boolean discard;
Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v
retrieving revision 1.205
diff -u -r1.205 JavaSearchBugsTests.java
--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 2 Sep 2010 09:00:25 -0000 1.205
+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 3 Sep 2010 11:27:54 -0000
@@ -12073,6 +12073,246 @@
}
/**
+ * @bug 322979: [search] use of IJavaSearchConstants.IMPLEMENTORS yields surprising results
+ * @test search of implementors does no longer report matches in type arguments
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=322979"
+ */
+public void testBug322979a() throws CoreException {
+ try
+ {
+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+ createFile("/P/Test.java",
+ "public class Test extends Object implements Comparable