diff options
| author | Manoj Palat | 2013-02-27 16:58:38 +0000 |
|---|---|---|
| committer | ssankaran | 2013-02-27 16:58:38 +0000 |
| commit | 4005c370e6cbaf5fe897eaa7c9410e92ff25148d (patch) | |
| tree | 7b10807bc2ed11fa16608b99f79730d89fbae128 | |
| parent | 1aef615a23a262f5caabd6f48d0a4c046ef230b8 (diff) | |
| download | eclipse.jdt.core-4005c370e6cbaf5fe897eaa7c9410e92ff25148d.tar.gz eclipse.jdt.core-4005c370e6cbaf5fe897eaa7c9410e92ff25148d.tar.xz eclipse.jdt.core-4005c370e6cbaf5fe897eaa7c9410e92ff25148d.zip | |
Fixed Bug 400902 - [1.8][search] Search engine fails to annotation
matches in extends/implements clauses
2 files changed, 60 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java index 4ab96d20bf..9bb92fc3d5 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -13743,5 +13747,46 @@ public void testBug241834() throws CoreException { } } + /** + * @bug 402902: [1.8][search] Search engine fails to annotation matches in extends/implements clauses + * @test Ensures that the search for type use annotation finds matches + * in extends and implements clauses. + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=402902" + */ +public void testBug400902a() throws CoreException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b400902/X.java", + "import java.lang.annotation.ElementType;\n" + + "import java.lang.annotation.Target;\n" + + "import java.io.Serializable;\n" + + "@Marker1 @Marker public class X extends @Marker Object implements @Marker Serializable {\n" + + " private static final long serialVersionUID = 1L;\n" + + " int x = (@Marker int) 0;\n" + + " @Marker public class Y {}\n" + + "}\n" + + "@Target(ElementType.TYPE_USE)\n" + + "@interface Marker {}\n" + + "@Target(ElementType.TYPE)\n" + + "@interface Marker1 {}" + ); + SearchPattern pattern = SearchPattern.createPattern( + "Marker", + ANNOTATION_TYPE, + REFERENCES, + EXACT_RULE); + new SearchEngine(this.workingCopies).search(pattern, + new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, + getJavaSearchWorkingCopiesScope(), + this.resultCollector, + null); + assertSearchResults( + "src/b400902/X.java b400902.X [Marker] EXACT_MATCH\n" + + "src/b400902/X.java b400902.X [Marker] EXACT_MATCH\n" + + "src/b400902/X.java b400902.X [Marker] EXACT_MATCH\n" + + "src/b400902/X.java b400902.X.x [Marker] EXACT_MATCH\n" + + "src/b400902/X.java b400902.X$Y [Marker] EXACT_MATCH" + ); +} // Add new tests in JavaSearchBugsTests2 }
\ No newline at end of file diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java index 5585ae9fa4..e30fb80e0b 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java @@ -1,9 +1,13 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. * * Contributors: * IBM Corporation - initial API and implementation @@ -2696,11 +2700,20 @@ protected void reportMatching(TypeDeclaration type, IJavaElement parent, int acc TypeReference superClass = type.superclass; if (superClass != null) { reportMatchingSuper(superClass, enclosingElement, type.binding, nodeSet, matchedClassContainer); + for (int i = 0, length = superClass.annotations == null ? 0 : superClass.annotations.length; i < length; i++) { + reportMatching(superClass.annotations[i], enclosingElement, null, type.binding, nodeSet, matchedClassContainer, enclosesElement); + } } TypeReference[] superInterfaces = type.superInterfaces; if (superInterfaces != null) { for (int i = 0, l = superInterfaces.length; i < l; i++) { reportMatchingSuper(superInterfaces[i], enclosingElement, type.binding, nodeSet, matchedClassContainer); + TypeReference typeReference = type.superInterfaces[i]; + if (typeReference != null && typeReference.annotations != null) { + for (int j = 0, length = typeReference.annotations.length; j < length; j++) { + reportMatching(typeReference.annotations[j], enclosingElement, null, type.binding, nodeSet, matchedClassContainer, enclosesElement); + } + } } } } |
