### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/core/search/SearchEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java,v retrieving revision 1.131 diff -u -r1.131 SearchEngine.java --- search/org/eclipse/jdt/core/search/SearchEngine.java 22 Jun 2006 14:12:26 -0000 1.131 +++ search/org/eclipse/jdt/core/search/SearchEngine.java 22 Sep 2006 17:24:33 -0000 @@ -588,6 +588,8 @@ *
+ * SearchRequestor needs to be provided to this method. It will accept a specific search match
+ * ({@link TypeDeclarationNameMatch}) which may compute model operation as resolving the type.
+ * Note that this operation should be used carefully as it will consume more memory than
+ * searchAllTypeNames
with {@link TypeNameRequestor} (a match for each type
+ * found will be created).
+ *
+ * @param packageName the full name of the package of the searched types, or a prefix for this
+ * package, or a wild-carded string for this package.
+ * @param typeName the dot-separated qualified name of the searched type (the qualification include
+ * the enclosing types if the searched type is a member type), or a prefix
+ * for this type, or a wild-carded string for this type.
+ * @param packageMatchRule one of
+ *
null
if no progress
+ * monitor is provided
+ * @exception JavaModelException if the search failed. Reasons include:
+ * null
if unable to associate the given file
+ * with a Java element.
+ *
+ * The file must be one of:
ICompilationUnit
.class
file - the element returned is the corresponding IClassFile
.jar
file - the element returned is the corresponding IPackageFragmentRoot
+ * Creating a Java element has the side effect of creating and opening all of the
+ * element's parents if they are not yet open.
+ *
+ * @param file the given file
+ * @return the Java element corresponding to the given file, or
+ * null
if unable to associate the given file
+ * with a Java element
+ * @since 3.3
+ */
+ public static IJavaElement create(IFile file, IJavaProject project) {
+ return JavaModelManager.create(file, project);
+ }
+ /**
* Returns the package fragment or package fragment root corresponding to the given folder, or
* null
if unable to associate the given folder with a Java element.
*
@@ -2857,6 +2882,7 @@
try {
engine.searchAllTypeNames(
null,
+ SearchPattern.R_EXACT_MATCH,
"!@$#!@".toCharArray(), //$NON-NLS-1$
SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
IJavaSearchConstants.CLASS,
Index: search/org/eclipse/jdt/core/search/TypeDeclarationNameMatch.java
===================================================================
RCS file: search/org/eclipse/jdt/core/search/TypeDeclarationNameMatch.java
diff -N search/org/eclipse/jdt/core/search/TypeDeclarationNameMatch.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ search/org/eclipse/jdt/core/search/TypeDeclarationNameMatch.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.search;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
+
+/**
+ * A Java search match that represents a type declaration name
+ * found in index files.
+ * The element is an IType
only initialized when
+ * requested by clients.
+ *
+ * This class is intended to be instantiated and subclassed by clients. + *
+ * + * @since 3.3 + */ +public class TypeDeclarationNameMatch extends SearchMatch { + +private int modifiers; +private char[] packageName; +private char[] typeName; +private char[][] enclosingTypeNames; +private String path; +private String projectPath; +private boolean initialized; + +/** + * Creates a new type declaration name match. + */ +public TypeDeclarationNameMatch(int modifiers, char[] packageName, char[] typeName, char[][] enclosingTypeNames, String path, String project) { + super(null, A_ACCURATE, -1, -1, null, null); + this.modifiers = modifiers; + this.packageName = packageName; + this.typeName = typeName; + this.enclosingTypeNames = enclosingTypeNames; + this.path = path; + this.projectPath = project; +} + +/** + * Returns the enclosing type names (if any) of the type as they were found in the index. + * + * @return the type enclosing type names + */ +public char[][] getEnclosingTypeNames() { + return enclosingTypeNames; +} + +/** + * Returns the modifiers of the type as they were found in the index. + * + * @return the type modifiers + */ +public int getModifiers() { + return modifiers; +} + +/** + * Returns the full path of the resource as it was found in the index. + * This path may include the jar file path following by '|' separator + * if the type is a binary included in a jar. + * + * @return the full path of the resource + */ +public String getPath() { + return path; +} + +/** + * Returns the project path of the type. + * + * @return the project path + */ +public String getProjectPath() { + return projectPath; +} + +/** + * Returns the package name of the type as it was found in the index. + * + * @return the package name + */ +public char[] getPackageName() { + return packageName; +} + +/** + * Returns the name of the type as it was found in the index. + * + * @return the type name + */ +public char[] getTypeName() { + return typeName; +} + +/** + * Returns the type of the java model corresponding to information found + * in index. + * + * @return the java model type + * @throws JavaModelException happens when index information are not valid + */ +public IType getType() throws JavaModelException { + if (!this.initialized) { + initialize(); + } + return (IType) getElement(); +} + +/* + * Initialize type. + */ +private void initialize() throws JavaModelException { + this.initialized = true; + + // Find resource and project + IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); + int index = path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR); + IResource resource = index == -1 ? root.findMember(path) : null; + if (resource == null && this.projectPath == null) return; // no enough stored information, cannot initialize + IProject project = this.projectPath == null ? getResource().getProject() : root.getProject(projectPath); + IJavaProject javaProject = JavaCore.create(project); + if (javaProject == null) return; // cannot initialize without a project + setResource(resource == null ? project : resource); + + // Find type in project + String packageNameString = new String(packageName); + String qualifiedTypeName = this.enclosingTypeNames == null + ? new String(this.typeName) + : new String(CharOperation.concatWith(this.typeName, enclosingTypeNames, '.')); + IType type = javaProject.findType(packageNameString, qualifiedTypeName); + setElement(type); +} +} Index: search/org/eclipse/jdt/internal/core/search/TypeNameSearchRequestor.java =================================================================== RCS file: search/org/eclipse/jdt/internal/core/search/TypeNameSearchRequestor.java diff -N search/org/eclipse/jdt/internal/core/search/TypeNameSearchRequestor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ search/org/eclipse/jdt/internal/core/search/TypeNameSearchRequestor.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.internal.core.search; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.search.IJavaSearchScope; +import org.eclipse.jdt.core.search.SearchRequestor; +import org.eclipse.jdt.core.search.TypeDeclarationNameMatch; +import org.eclipse.jdt.internal.compiler.env.AccessRestriction; + +/** + * Wrapper used to link {@link IRestrictedAccessTypeRequestor} with {@link SearchRequestor}. + * This wrapper specifically allows usage of internal method {@link BasicSearchEngine#searchAllTypeNames( + * char[] packageName, + * int packageMatchRule, + * char[] typeName, + * int typeMatchRule, + * int searchFor, + * org.eclipse.jdt.core.search.IJavaSearchScope scope, + * IRestrictedAccessTypeRequestor nameRequestor, + * int waitingPolicy, + * org.eclipse.core.runtime.IProgressMonitor monitor) }. + * from API method {@link org.eclipse.jdt.core.search.SearchEngine#searchAllTypeNames( + * char[] packageName, + * int packageMatchRule, + * char[] typeName, + * int matchRule, + * int searchFor, + * org.eclipse.jdt.core.search.IJavaSearchScope scope, + * SearchRequestor searchRequestor, + * int waitingPolicy, + * org.eclipse.core.runtime.IProgressMonitor monitor) }. + */ +public class TypeNameSearchRequestor implements IRestrictedAccessTypeRequestor { + SearchRequestor requestor; // need the search requestor to make the link + JavaSearchScope scope; // need a scope to get path of the project (not stored in index file) + + public TypeNameSearchRequestor(SearchRequestor requestor, IJavaSearchScope scope) { + this.requestor = requestor; + this.scope = (JavaSearchScope) scope; + } + + /** + * Accepting type from searchAllTypeNames query. + * Get project path from stored scope, create {@link TypeDeclarationNameMatch} and send it to search requestor. + */ + public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { + if (access == null) { + try { + String projectPath = this.scope.projectPathFor(path); + TypeDeclarationNameMatch match = new TypeDeclarationNameMatch(modifiers, packageName, simpleTypeName, enclosingTypeNames, path, projectPath); + this.requestor.acceptSearchMatch(match); + } + catch (CoreException e) { + // skip + } + } + } +} #P org.eclipse.jdt.core.tests.performance Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java,v retrieving revision 1.15 diff -u -r1.15 FullSourceWorkspaceModelTests.java --- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 27 Apr 2006 09:10:08 -0000 1.15 +++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 22 Sep 2006 17:24:35 -0000 @@ -229,6 +229,7 @@ TypeNameCounter requestor = new TypeNameCounter(); new SearchEngine().searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PREFIX_MATCH, // not case sensitive IJavaSearchConstants.TYPE, #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java,v retrieving revision 1.20 diff -u -r1.20 CodeCorrectionTests.java --- src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java 6 Sep 2006 08:32:44 -0000 1.20 +++ src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java 22 Sep 2006 17:24:38 -0000 @@ -62,6 +62,7 @@ try { engine.searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "!@$#!@".toCharArray(), SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE, IJavaSearchConstants.CLASS, Index: src/org/eclipse/jdt/core/tests/model/SearchTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java,v retrieving revision 1.37 diff -u -r1.37 SearchTests.java --- src/org/eclipse/jdt/core/tests/model/SearchTests.java 3 Aug 2006 17:23:24 -0000 1.37 +++ src/org/eclipse/jdt/core/tests/model/SearchTests.java 22 Sep 2006 17:24:44 -0000 @@ -148,6 +148,7 @@ SearchTypeNameRequestor requestor = new SearchTypeNameRequestor(); searchEngine.searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive TYPE, Index: src/org/eclipse/jdt/core/tests/model/ExistenceTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExistenceTests.java,v retrieving revision 1.23 diff -u -r1.23 ExistenceTests.java --- src/org/eclipse/jdt/core/tests/model/ExistenceTests.java 23 Jun 2006 09:26:27 -0000 1.23 +++ src/org/eclipse/jdt/core/tests/model/ExistenceTests.java 22 Sep 2006 17:24:38 -0000 @@ -12,14 +12,12 @@ import junit.framework.Test; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.*; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.tests.util.Util; public class ExistenceTests extends ModifyingResourceTests { public ExistenceTests(String name) { @@ -96,6 +94,41 @@ this.deleteProject("P"); } } +public void testClassFileInLibraryInOtherProject() throws CoreException { + try { + this.createJavaProject("P2", new String[] {}, "bin"); + this.createFolder("P2/lib"); + String path = "P2/lib/X.class"; + IFile file = this.createFile(path, ""); + IJavaProject p1 = createJavaProject("P1", new String[] {}, new String[] {"/P2/lib"}, "bin"); + IClassFile nonExistingFile = getClassFile(path); + assertFalse(nonExistingFile.exists()); + IClassFile existingFile = (IClassFile)JavaCore.create(file, p1); + assertTrue(existingFile.exists()); + } finally { + this.deleteProject("P1"); + this.deleteProject("P2"); + } +} +public void testJarFile() throws Exception { + try { + IJavaProject p2 = createJavaProject("P2"); + String[] pathsAndContents = new String[] { + "test/X.java", + "package test;\n" + + "public class X {\n" + + "}", + }; + addLibrary(p2, "lib.jar", "libsrc.zip", pathsAndContents, JavaCore.VERSION_1_5); + IJavaProject p1 = createJavaProject("P1", new String[] {}, new String[] {"/P2/lib.jar"}, "bin"); + IPackageFragmentRoot root2 = getPackageFragmentRoot("/P2/lib.jar"); + assertTrue(root2.exists()); + assertEquals(p1.getPackageFragmentRoots()[0], root2); + } finally { + this.deleteProject("P1"); + this.deleteProject("P2"); + } +} /* * Ensure that an IClassFile handle created on a .class file in a source folder * doesn't not exist. 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.85 diff -u -r1.85 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 14 Sep 2006 17:10:18 -0000 1.85 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 22 Sep 2006 17:24:41 -0000 @@ -3017,6 +3017,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive TYPE, @@ -3039,6 +3040,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, IIndexConstants.ONE_STAR, SearchPattern.R_PATTERN_MATCH, // case insensitive CLASS, @@ -3059,6 +3061,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive CLASS_AND_INTERFACE, @@ -3080,6 +3083,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive CLASS_AND_ENUM, @@ -3101,6 +3105,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive INTERFACE, @@ -3120,6 +3125,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive ENUM, @@ -3139,6 +3145,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive ANNOTATION_TYPE, @@ -3674,6 +3681,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "E*".toCharArray(), SearchPattern.R_PATTERN_MATCH, TYPE, @@ -4870,6 +4878,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "AA".toCharArray(), SearchPattern.R_CAMELCASE_MATCH, TYPE, @@ -4892,6 +4901,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "AA".toCharArray(), SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_PREFIX_MATCH, TYPE, @@ -4914,6 +4924,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "AA".toCharArray(), SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE, TYPE, @@ -4936,6 +4947,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "AA".toCharArray(), SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE, TYPE, @@ -4958,6 +4970,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "AA".toCharArray(), SearchPattern.R_PREFIX_MATCH, TYPE, @@ -4978,6 +4991,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "AA".toCharArray(), SearchPattern.R_CASE_SENSITIVE, TYPE, @@ -4997,6 +5011,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "AA".toCharArray(), SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE, TYPE, @@ -5017,6 +5032,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "aa".toCharArray(), SearchPattern.R_CAMELCASE_MATCH, TYPE, @@ -5037,6 +5053,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "aa".toCharArray(), SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_PREFIX_MATCH, TYPE, @@ -5057,6 +5074,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "aa".toCharArray(), SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE, TYPE, @@ -5076,6 +5094,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "aa".toCharArray(), SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE, TYPE, @@ -5095,6 +5114,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "aa".toCharArray(), SearchPattern.R_PREFIX_MATCH, TYPE, @@ -5115,6 +5135,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "aa".toCharArray(), SearchPattern.R_CASE_SENSITIVE, TYPE, @@ -5134,6 +5155,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, "aa".toCharArray(), SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE, TYPE, @@ -6339,6 +6361,7 @@ TypeNameRequestor requestor = new DeprecatedTypesRequestor(); new SearchEngine().searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive TYPE, @@ -6881,6 +6904,7 @@ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, + SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive INTERFACE_AND_ANNOTATION, @@ -6958,4 +6982,66 @@ "src/pack/Test.java void pack.Test.polymorphicSub(Sub) [toString()] EXACT_MATCH POLYMORPHIC" ); } + +/** + * Bug 156491: [1.5][search] interfaces and annotations could be found with only one requets of searchAllTypeName + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156491" + */ +public void _testSearchAllTypes_wc() throws CoreException { + resultCollector.showRule = true; + workingCopies = new ICompilationUnit[4]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/I.java", + "package pack;\n" + + "public interface I {}\n" + ); + workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/pack/X.java", + "package pack;\n" + + "public class X {}\n" + ); + workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/pack/Sub.java", + "package pack;\n" + + "public class Sub extends X {}\n" + ); + workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/pack/Y.java", + "package pack;\n" + + "public class Y {}\n" + ); + new SearchEngine(this.workingCopies).searchAllTypeNames( + null, SearchPattern.R_EXACT_MATCH, + null, SearchPattern.R_EXACT_MATCH, + IJavaSearchConstants.TYPE, + getJavaSearchScopeBugs(), + this.resultCollector, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null); + assertSearchResults( + "???" + ); +} +public void testONLY_SearchAllTypes_cu() throws CoreException { + SearchRequestor requestor = new SearchRequestor() { + public StringBuffer results = new StringBuffer(); + public void acceptSearchMatch(SearchMatch match) throws CoreException { + TypeDeclarationNameMatch nameMatch = (TypeDeclarationNameMatch) match; + if (results.length() > 0) results.append('\n'); + IType type = nameMatch.getType(); + results.append(type==null?"null":type.toString()); + } + public String toString() { + return this.results.toString(); + } + }; + new SearchEngine().searchAllTypeNames( + null, SearchPattern.R_EXACT_MATCH, + "Bug".toCharArray(), SearchPattern.R_PREFIX_MATCH, + IJavaSearchConstants.TYPE, + getJavaSearchScopeBugs(), + requestor, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null); + assertSearchResults( + "Bug148380 (not open) [in Bug148380.class [in