diff options
| author | Tomasz Zarna | 2012-07-05 13:51:47 +0000 |
|---|---|---|
| committer | Jayaprakash Arthanareeswaran | 2012-08-10 06:55:43 +0000 |
| commit | b7bd88d9bc859369d4d17c37d109bd3331837ba7 (patch) | |
| tree | 1c86ab350b9244616a4b827a01680a75b3afccd9 | |
| parent | 04423947d8d7bb07b422b48e36dce13f3a6590fc (diff) | |
| download | eclipse.jdt.core-b7bd88d9bc859369d4d17c37d109bd3331837ba7.tar.gz eclipse.jdt.core-b7bd88d9bc859369d4d17c37d109bd3331837ba7.tar.xz eclipse.jdt.core-b7bd88d9bc859369d4d17c37d109bd3331837ba7.zip | |
Fixed bug 381567: [search] Unexpected results from SearchEngine#search
Conflicts:
5 files changed, 76 insertions, 9 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java index c45d50f8d7..bf0958e983 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java @@ -1224,4 +1224,70 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests { deleteProject("P"); } } + // search for constructor declarations in javadoc + public void testBug381567a() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFolder("/P/src/b381567"); + createFile("/P/src/b381567/A.java", + "package b381567;\n" + + "/**\n" + + "* {@link B#equals(java.lang.Object)}\n" + + "*/\n" + + "public class A {\n" + + " A() {}\n" + + "}"); + createFile("/P/src/b381567/B.java", + "package b381567;\n" + + "public class B {\n" + + "}"); + waitUntilIndexesReady(); + IJavaSearchScope scope = SearchEngine + .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); + SearchPattern pattern = SearchPattern.createPattern("*", CONSTRUCTOR, DECLARATIONS, SearchPattern.R_PATTERN_MATCH); + this.resultCollector.showInsideDoc(); + + search(pattern, scope, this.resultCollector); + + assertSearchResults("src/b381567/A.java b381567.A() [A] EXACT_MATCH OUTSIDE_JAVADOC"); + } finally { + deleteProject("P"); + } + } + // search for all constructor occurrences (declarations and references) in javadoc + public void testBug381567b() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFolder("/P/src/b381567"); + createFile("/P/src/b381567/A.java", + "package b381567;\n" + + "class A {\n" + + " A(Exception ex) {}\n" + + " class B { \n" + + " /**\n" + + " * Link {@link #A(Exception)} OK\n" + + " */\n" + + " public B(String str) {}\n" + + " }\n" + + "}" + ); + waitUntilIndexesReady(); + IMethod[] methods = getCompilationUnit("/P/src/b381567/A.java") + .getType("A").getMethods(); + assertEquals("Invalid number of methods", 1, methods.length); + assertTrue(methods[0].isConstructor()); + IJavaSearchScope scope = SearchEngine + .createJavaSearchScope(new IJavaElement[] { p }); + this.resultCollector.showInsideDoc(); + + search(methods[0], ALL_OCCURRENCES, scope); + + assertSearchResults("src/b381567/A.java b381567.A(Exception) [A] EXACT_MATCH OUTSIDE_JAVADOC\n" + + "src/b381567/A.java b381567.A$B(String) [A(Exception)] EXACT_MATCH INSIDE_JAVADOC"); + } finally { + deleteProject("P"); + } + } } diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchParticipant.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchParticipant.java index 2a87b52959..15155e4116 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchParticipant.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchParticipant.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 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 @@ -86,7 +86,7 @@ public abstract class SearchParticipant { * Returns a displayable name of this search participant. * <p> * This method should be re-implemented in subclasses that need to - * display a meaningfull name. + * display a meaningful name. * </p> * * @return the displayable name of this search participant @@ -135,14 +135,14 @@ public abstract class SearchParticipant { /** * Locates the matches in the given documents using the given search pattern - * and search scope, and reports them to the givenn search requestor. This + * and search scope, and reports them to the given search requestor. This * method is called by the search engine once it has search documents * matching the given pattern in the given search scope. * <p> * Note that a participant (e.g. a JSP participant) can pre-process the contents of the given documents, * create its own documents whose contents are Java compilation units and delegate the match location * to the default participant (see {@link SearchEngine#getDefaultSearchParticipant()}). Passing its own - * {@link SearchRequestor} this particpant can then map the match positions back to the original + * {@link SearchRequestor} this participant can then map the match positions back to the original * contents, create its own matches and report them to the original requestor. * </p><p> * Implementors of this method should check the progress monitor diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchRequestor.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchRequestor.java index 1bd1f043eb..72841e66f5 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchRequestor.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchRequestor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2012 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 @@ -55,7 +55,7 @@ public abstract class SearchRequestor { /** * Notification sent after having completed the search action. * Typically, this would tell a search requestor collector that no more - * results will be forthcomping in this search. + * results will be forthcoming in this search. * <p> * The default implementation of this method does nothing. Subclasses * may override. 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 bcc0dd3677..8342e17612 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2012 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 @@ -77,11 +77,12 @@ public int match(FieldDeclaration field, MatchingNodeSet nodeSet) { } //public int match(MethodDeclaration node, MatchingNodeSet nodeSet) - SKIP IT /** - * Special case for message send in javadoc comment. They can be in fact bound to a contructor. + * Special case for message send in javadoc comment. They can be in fact bound to a constructor. * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=83285" */ public int match(MessageSend msgSend, MatchingNodeSet nodeSet) { if ((msgSend.bits & ASTNode.InsideJavadoc) == 0) return IMPOSSIBLE_MATCH; + if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; if (this.pattern.declaringSimpleName == null || CharOperation.equals(msgSend.selector, this.pattern.declaringSimpleName)) { return nodeSet.addMatch(msgSend, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); } 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 d8beb8c6de..0a9a458f76 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 @@ -548,7 +548,7 @@ IMethod createBinaryMethodHandle(IType type, char[] methodSelector, char[][] arg } /* * Create method handle. - * Store occurences for create handle to retrieve possible duplicate ones. + * Store occurrences for create handle to retrieve possible duplicate ones. */ private IJavaElement createMethodHandle(IType type, String methodName, String[] parameterTypeSignatures) { IMethod methodHandle = type.getMethod(methodName, parameterTypeSignatures); |
