### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core 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.278 diff -u -r1.278 MatchLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 8 Jun 2006 13:08:57 -0000 1.278 +++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 7 Sep 2006 07:25:10 -0000 @@ -332,10 +332,6 @@ return element; } -public static boolean isPolymorphicSearch(InternalSearchPattern pattern) { - return pattern.isPolymorphicSearch(); -} - public static IJavaElement projectOrJarFocus(InternalSearchPattern pattern) { return pattern == null || pattern.focus == null ? null : getProjectOrJar(pattern.focus); } Index: search/org/eclipse/jdt/internal/core/search/IndexSelector.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java,v retrieving revision 1.34 diff -u -r1.34 IndexSelector.java --- search/org/eclipse/jdt/internal/core/search/IndexSelector.java 13 Jun 2006 13:00:43 -0000 1.34 +++ search/org/eclipse/jdt/internal/core/search/IndexSelector.java 7 Sep 2006 07:25:09 -0000 @@ -25,6 +25,7 @@ import org.eclipse.jdt.internal.core.JavaProject; import org.eclipse.jdt.internal.core.search.indexing.IndexManager; import org.eclipse.jdt.internal.core.search.matching.MatchLocator; +import org.eclipse.jdt.internal.core.search.matching.MethodPattern; /** * Selects the indexes that correspond to projects in a given search scope @@ -135,7 +136,7 @@ int projectIndex = 0; SimpleSet jarsToCheck = new SimpleSet(length); IClasspathEntry[] focusEntries = null; - if (this.pattern != null && MatchLocator.isPolymorphicSearch(this.pattern)) { // isPolymorphicSearch + if (this.pattern instanceof MethodPattern) { // should consider polymorphic search for method patterns JavaProject focusProject = focus instanceof JarPackageFragmentRoot ? (JavaProject) focus.getParent() : (JavaProject) focus; focusEntries = focusProject.getExpandedClasspath(); } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java,v retrieving revision 1.36 diff -u -r1.36 JavaSearchMultipleProjectsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java 13 Jun 2006 13:01:06 -0000 1.36 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java 7 Sep 2006 07:25:14 -0000 @@ -24,6 +24,7 @@ * Tests the Java search engine accross multiple projects. */ public class JavaSearchMultipleProjectsTests extends ModifyingResourceTests implements IJavaSearchConstants { + private final static int UI_DECLARATIONS = DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE; public JavaSearchMultipleProjectsTests(String name) { super(name); } @@ -664,4 +665,132 @@ deleteProject("P2"); } } + +/** + * Bug 151189: [search] Declaration search does not find all matches + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=151189" + */ +public void testBug151189_Workspace() throws CoreException { + try { + // setup project P1 + /*IJavaProject p1 = */createJavaProject("P1"); + createFolder("/P1/pack"); + createFile( + "/P1/pack/Declaration.java", + "package pack;\n" + + "public class Declaration implements Interface {\n" + + " public void doOperation(int val) {}\n" + + "}\n" + ); + createFile( + "/P1/pack/Interface.java", + "package pack;\n" + + "public interface Interface {\n" + + " void doOperation(int val);\n" + + "}\n" + ); + + // setup project P2 + createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, ""); + createFolder("/P2/test"); + createFile( + "/P2/test/Declaration_bis.java", + "package test;\n" + + "import pack.Interface;\n" + + "public class Declaration_bis implements Interface {\n" + + " public void doOperation(int val) {}\n" + + "}\n" + ); + + // Get method + IMethod method = getCompilationUnit("/P2/test/Declaration_bis.java").getType("Declaration_bis").getMethod("doOperation", new String[] {"I"}); + + // search method declaration in workspace scope + IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); //JavaSearchScope(new IJavaElement[] {p1, p2}); + JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); + resultCollector.showProject = true; + search( + method, + DECLARATIONS, + scope, + resultCollector); + assertSearchResults( + "Unexpected declarations of method test.Declaration_bis.doOperation(int)", + "test/Declaration_bis.java [in P2] void test.Declaration_bis.doOperation(int) [doOperation]", + resultCollector); + + // search method declaration in workspace scope with JDT-UI flags + resultCollector = new JavaSearchResultCollector(); + resultCollector.showProject = true; + search( + method, + UI_DECLARATIONS, + scope, + resultCollector); + assertSearchResults( + "Unexpected declarations of method test.Declaration_bis.doOperation(int)", + "pack/Declaration.java [in P1] void pack.Declaration.doOperation(int) [doOperation]\n" + + "pack/Interface.java [in P1] void pack.Interface.doOperation(int) [doOperation]\n" + + "test/Declaration_bis.java [in P2] void test.Declaration_bis.doOperation(int) [doOperation]", + resultCollector); + } finally { + deleteProject("P1"); + deleteProject("P2"); + } +} +public void testBug151189_Project() throws CoreException { + try { + // setup project P1 + createJavaProject("P1"); + createFolder("/P1/pack"); + createFile( + "/P1/pack/Declaration.java", + "package pack;\n" + + "public class Declaration implements Interface {\n" + + " public void doOperation(int val) {}\n" + + "}\n" + ); + createFile( + "/P1/pack/Interface.java", + "package pack;\n" + + "public interface Interface {\n" + + " void doOperation(int val);\n" + + "}\n" + ); + + // setup project P2 + IJavaProject p2 = createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, ""); + createFolder("/P2/test"); + createFile( + "/P2/test/Declaration_bis.java", + "package test;\n" + + "import pack.Interface;\n" + + "public class Declaration_bis implements Interface {\n" + + " public void doOperation(int val) {}\n" + + "}\n" + ); + + // Get method + IMethod method = getCompilationUnit("/P2/test/Declaration_bis.java").getType("Declaration_bis").getMethod("doOperation", new String[] {"I"}); + + // search method declaration in project scope + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2}); + JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); + resultCollector.showProject = true; + search( + method, + UI_DECLARATIONS, + scope, + resultCollector); + assertSearchResults( + "Unexpected declarations of method test.Declaration_bis.doOperation(int)", + "pack/Declaration.java [in P1] void pack.Declaration.doOperation(int) [doOperation]\n" + + "pack/Interface.java [in P1] void pack.Interface.doOperation(int) [doOperation]\n" + + "test/Declaration_bis.java [in P2] void test.Declaration_bis.doOperation(int) [doOperation]", + resultCollector); + } finally { + deleteProject("P1"); + deleteProject("P2"); + } +} } 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.82 diff -u -r1.82 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 4 Aug 2006 15:11:11 -0000 1.82 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 7 Sep 2006 07:25:14 -0000 @@ -5680,6 +5680,41 @@ } /** + * Bug 113671: [search] AIOOBE in SearchEngine#searchAllTypeNames + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=113671" + */ +public void testBug113671() throws CoreException { + TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); + new SearchEngine().searchAllTypeNames( + "java.lang".toCharArray(), + SearchPattern.R_EXACT_MATCH, + CharOperation.NO_CHAR, + SearchPattern.R_PREFIX_MATCH, + IJavaSearchConstants.TYPE, + getJavaSearchScopeBugs(), + requestor, + WAIT_UNTIL_READY_TO_SEARCH, + null + ); + assertSearchResults( + "Unexpected all type names", + "java.lang.CharSequence\n" + + "java.lang.Class\n" + + "java.lang.CloneNotSupportedException\n" + + "java.lang.Comparable\n" + + "java.lang.Enum\n" + + "java.lang.Error\n" + + "java.lang.Exception\n" + + "java.lang.IllegalMonitorStateException\n" + + "java.lang.InterruptedException\n" + + "java.lang.Object\n" + + "java.lang.RuntimeException\n" + + "java.lang.String\n" + + "java.lang.Throwable", + requestor); +} + +/** * @test Bug 114539: [search] Internal error when refactoring code with errors * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=114539" */ Index: src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java,v retrieving revision 1.152 diff -u -r1.152 JavaSearchTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 18 Apr 2006 16:28:01 -0000 1.152 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 7 Sep 2006 07:25:16 -0000 @@ -19,10 +19,8 @@ import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; import org.eclipse.jdt.core.*; -import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.search.*; import org.eclipse.jdt.internal.core.JavaModelStatus; -import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; /** * Tests the Java search engine where results are JavaElements and source positions. @@ -3689,60 +3687,4 @@ "q1.AA", requestor); } - -/** - * Bug 113671: [search] AIOOBE in SearchEngine#searchAllTypeNames - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=113671" - */ -public void testBug113671a() throws CoreException { - TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); - new SearchEngine(this.workingCopies).searchAllTypeNames( - null, - CharOperation.NO_CHAR, - SearchPattern.R_CAMELCASE_MATCH, - TYPE, - getJavaSearchScope(), - requestor, - IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, - null - ); - assertSearchResults( - "Unexpected all type names", - "", - requestor); -} -public void testBug113671b() throws CoreException { - TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); - new SearchEngine(this.workingCopies).searchAllTypeNames( - CharOperation.NO_CHAR, - CharOperation.NO_CHAR, - SearchPattern.R_CAMELCASE_MATCH, - TYPE, - getJavaSearchScope(), - requestor, - IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, - null - ); - assertSearchResults( - "Unexpected all type names", - "", - requestor); -} -public void testBug113671c() throws CoreException { - TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); - new SearchEngine(this.workingCopies).searchAllTypeNames( - IIndexConstants.ONE_STAR, - CharOperation.NO_CHAR, - SearchPattern.R_CAMELCASE_MATCH, - TYPE, - getJavaSearchScope(), - requestor, - IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, - null - ); - assertSearchResults( - "Unexpected all type names", - "", - requestor); -} }