### 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 30 Aug 2010 09:52:21 -0000 @@ -51,6 +51,11 @@ this.patternLocators[i].initializePolymorphicSearch(locator); } } +public void setMatchLocator(MatchLocator locator) { + for (int i = 0, length = this.patternLocators.length; i < length; i++) { + this.patternLocators[i].setMatchLocator(locator); + } +} public int match(Annotation node, MatchingNodeSet nodeSet) { int level = IMPOSSIBLE_MATCH; for (int i = 0, length = this.patternLocators.length; i < length; i++) { Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v retrieving revision 1.335 diff -u -r1.335 MatchLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 25 Aug 2010 10:53:57 -0000 1.335 +++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 30 Aug 2010 09:52:24 -0000 @@ -146,6 +146,12 @@ HashSet methodHandles; private final boolean searchPackageDeclaration; +public int parseContext; + +public final static int PARSE_STATE_UNKNOWN = 0; +public final static int PARSE_INTERFACE_TYPE = 1; +public final static int PARSE_EXTENDS_TYPE = 2; +public final static int PARSE_ANONYMOUS_BODY = 3; public static class WorkingCopyDocument extends JavaSearchDocument { public org.eclipse.jdt.core.ICompilationUnit workingCopy; @@ -1171,7 +1177,7 @@ if (this.progressMonitor != null) { this.progressMonitor.beginTask("", searchDocuments.length); //$NON-NLS-1$ } - + this.patternLocator.setMatchLocator(this); // initialize pattern for polymorphic search (i.e. method reference pattern) this.patternLocator.initializePolymorphicSearch(this); 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 30 Aug 2010 09:52:26 -0000 @@ -26,6 +26,7 @@ PatternLocator patternLocator; private ASTVisitor localDeclarationVisitor; final int patternFineGrain; + private MatchLocator locator; public static MatchLocatorParser createParser(ProblemReporter problemReporter, MatchLocator locator) { if ((locator.matchContainer & PatternLocator.COMPILATION_UNIT_CONTAINER) != 0) { @@ -93,6 +94,7 @@ protected MatchLocatorParser(ProblemReporter problemReporter, MatchLocator locator) { super(problemReporter, true); this.reportOnlyOneSyntaxError = true; + this.locator = locator; this.patternLocator = locator.patternLocator; if ((locator.matchContainer & PatternLocator.CLASS_CONTAINER) != 0) { this.localDeclarationVisitor = (locator.matchContainer & PatternLocator.METHOD_CONTAINER) != 0 @@ -209,6 +211,12 @@ } } +protected void consumeEnterAnonymousClassBody(boolean qualified) { + this.locator.parseContext = MatchLocator.PARSE_ANONYMOUS_BODY; + super.consumeEnterAnonymousClassBody(qualified); + this.locator.parseContext = MatchLocator.PARSE_STATE_UNKNOWN; +} + protected void consumeCastExpressionLL1() { super.consumeCastExpressionLL1(); if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) { @@ -256,11 +264,13 @@ } protected void consumeClassHeaderExtends() { + this.locator.parseContext = MatchLocator.PARSE_EXTENDS_TYPE; 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.locator.parseContext = MatchLocator.PARSE_STATE_UNKNOWN; } protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() { @@ -337,11 +347,13 @@ } } protected void consumeInterfaceType() { + this.locator.parseContext = MatchLocator.PARSE_INTERFACE_TYPE; super.consumeInterfaceType(); if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) { TypeReference typeReference = (TypeReference) this.astStack[this.astPtr]; this.patternLocator.match(typeReference, this.nodeSet); } + this.locator.parseContext = MatchLocator.PARSE_STATE_UNKNOWN; } 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 30 Aug 2010 09:52:26 -0000 @@ -50,6 +50,11 @@ for (int i = 0, length = this.patternLocators.length; i < length; i++) this.patternLocators[i].initializePolymorphicSearch(locator); } +public void setMatchLocator(MatchLocator locator) { + for (int i = 0, length = this.patternLocators.length; i < length; i++) { + this.patternLocators[i].setMatchLocator(locator); + } +} public int match(Annotation node, MatchingNodeSet nodeSet) { 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: /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 30 Aug 2010 09:52:27 -0000 @@ -30,6 +30,7 @@ // match to report SearchMatch match = null; +MatchLocator matchLocator; /* match levels */ public static final int IMPOSSIBLE_MATCH = 0; @@ -956,4 +957,7 @@ public String toString(){ return "SearchPattern"; //$NON-NLS-1$ } +public void setMatchLocator(MatchLocator locator) { + this.matchLocator = locator; +} } 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 30 Aug 2010 09:52:27 -0000 @@ -34,6 +34,15 @@ //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) { + switch(this.matchLocator.parseContext) { + case MatchLocator.PARSE_INTERFACE_TYPE: + case MatchLocator.PARSE_ANONYMOUS_BODY: + case MatchLocator.PARSE_EXTENDS_TYPE: + break; + default: + 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/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.204 diff -u -r1.204 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 25 Aug 2010 11:11:31 -0000 1.204 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 30 Aug 2010 09:52:53 -0000 @@ -61,7 +61,7 @@ // Debug static { // org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true; -// TESTS_NAMES = new String[] {"testBug306223"}; +// TESTS_NAMES = new String[] {"testBug122442d"}; } public JavaSearchBugsTests(String name) { @@ -12071,4 +12071,24 @@ deleteProject("P"); } } + +public void testBug322979() throws CoreException { + try + { + IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5"); + createFile("/P/Test.java", + "public class Test implements Comparable{\n"+ + "public int compareTo(Object o) {\n"+ + "return 0;\n"+ + "}\n"+ + "}\n"); + waitUntilIndexesReady(); + int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); + search("Object", TYPE, IMPLEMENTORS, scope, this.resultCollector); + assertSearchResults("", this.resultCollector); + } finally { + deleteProject("P"); + } +} } \ No newline at end of file