KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > search > SearchEngine


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.core.search;
12
13 import org.eclipse.core.resources.*;
14 import org.eclipse.core.runtime.*;
15
16 import org.eclipse.jdt.core.*;
17 import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
18 import org.eclipse.jdt.internal.core.search.*;
19 import org.eclipse.jdt.internal.core.search.matching.*;
20
21 /**
22  * A {@link SearchEngine} searches for Java elements following a search pattern.
23  * The search can be limited to a search scope.
24  * <p>
25  * Various search patterns can be created using the factory methods
26  * {@link SearchPattern#createPattern(String, int, int, int)}, {@link SearchPattern#createPattern(IJavaElement, int)},
27  * {@link SearchPattern#createOrPattern(SearchPattern, SearchPattern)}.
28  * </p>
29  * <p>For example, one can search for references to a method in the hierarchy of a type,
30  * or one can search for the declarations of types starting with "Abstract" in a project.
31  * </p>
32  * <p>
33  * This class may be instantiated; it is not intended to be subclassed.
34  * </p>
35  */

36 public class SearchEngine {
37
38     /**
39      * Internal adapter class.
40      * @deprecated marking deprecated as it uses deprecated ISearchPattern
41      */

42     static class SearchPatternAdapter implements ISearchPattern {
43         SearchPattern pattern;
44         SearchPatternAdapter(SearchPattern pattern) {
45             this.pattern = pattern;
46         }
47     }
48
49     /**
50      * Internal adapter class.
51      * @deprecated marking deprecated as it uses deprecated IJavaSearchResultCollector
52      */

53     static class ResultCollectorAdapter extends SearchRequestor {
54         IJavaSearchResultCollector resultCollector;
55         ResultCollectorAdapter(IJavaSearchResultCollector resultCollector) {
56             this.resultCollector = resultCollector;
57         }
58         /**
59          * @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch)
60          */

61         public void acceptSearchMatch(SearchMatch match) throws CoreException {
62             this.resultCollector.accept(
63                 match.getResource(),
64                 match.getOffset(),
65                 match.getOffset() + match.getLength(),
66                 (IJavaElement) match.getElement(),
67                 match.getAccuracy()
68             );
69         }
70         /**
71          * @see org.eclipse.jdt.core.search.SearchRequestor#beginReporting()
72          */

73         public void beginReporting() {
74             this.resultCollector.aboutToStart();
75         }
76         /**
77          * @see org.eclipse.jdt.core.search.SearchRequestor#endReporting()
78          */

79         public void endReporting() {
80             this.resultCollector.done();
81         }
82     }
83
84     /**
85      * Internal adapter class.
86      * @deprecated marking deprecated as it uses deprecated ITypeNameRequestor
87      */

88     static class TypeNameRequestorAdapter implements IRestrictedAccessTypeRequestor {
89         ITypeNameRequestor nameRequestor;
90         TypeNameRequestorAdapter(ITypeNameRequestor requestor) {
91             this.nameRequestor = requestor;
92         }
93         public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String JavaDoc path, AccessRestriction access) {
94             if (Flags.isInterface(modifiers)) {
95                 nameRequestor.acceptInterface(packageName, simpleTypeName, enclosingTypeNames, path);
96             } else {
97                 nameRequestor.acceptClass(packageName, simpleTypeName, enclosingTypeNames, path);
98             }
99         }
100     }
101         
102     // Search engine now uses basic engine functionalities
103
private BasicSearchEngine basicEngine;
104
105     /**
106      * Creates a new search engine.
107      */

108     public SearchEngine() {
109         this.basicEngine = new BasicSearchEngine();
110     }
111     
112     /**
113      * Creates a new search engine with a list of working copies that will take precedence over
114      * their original compilation units in the subsequent search operations.
115      * <p>
116      * Note that passing an empty working copy will be as if the original compilation
117      * unit had been deleted.</p>
118      * <p>
119      * Since 3.0 the given working copies take precedence over primary working copies (if any).
120      *
121      * @param workingCopies the working copies that take precedence over their original compilation units
122      * @since 3.0
123      */

124     public SearchEngine(ICompilationUnit[] workingCopies) {
125         this.basicEngine = new BasicSearchEngine(workingCopies);
126     }
127     /**
128      * Creates a new search engine with a list of working copies that will take precedence over
129      * their original compilation units in the subsequent search operations.
130      * <p>
131      * Note that passing an empty working copy will be as if the original compilation
132      * unit had been deleted.</p>
133      * <p>
134      * Since 3.0 the given working copies take precedence over primary working copies (if any).
135      *
136      * @param workingCopies the working copies that take precedence over their original compilation units
137      * @since 2.0
138      * @deprecated Use {@link #SearchEngine(ICompilationUnit[])} instead.
139      */

140     public SearchEngine(IWorkingCopy[] workingCopies) {
141         int length = workingCopies.length;
142         ICompilationUnit[] units = new ICompilationUnit[length];
143         System.arraycopy(workingCopies, 0, units, 0, length);
144         this.basicEngine = new BasicSearchEngine(units);
145     }
146     
147     /**
148      * Creates a new search engine with the given working copy owner.
149      * The working copies owned by this owner will take precedence over
150      * the primary compilation units in the subsequent search operations.
151      *
152      * @param workingCopyOwner the owner of the working copies that take precedence over their original compilation units
153      * @since 3.0
154      */

155     public SearchEngine(WorkingCopyOwner workingCopyOwner) {
156         this.basicEngine = new BasicSearchEngine(workingCopyOwner);
157     }
158
159     /**
160      * Returns a Java search scope limited to the hierarchy of the given type.
161      * The Java elements resulting from a search with this scope will
162      * be types in this hierarchy, or members of the types in this hierarchy.
163      *
164      * @param type the focus of the hierarchy scope
165      * @return a new hierarchy scope
166      * @exception JavaModelException if the hierarchy could not be computed on the given type
167      */

168     public static IJavaSearchScope createHierarchyScope(IType type) throws JavaModelException {
169         return BasicSearchEngine.createHierarchyScope(type);
170     }
171     
172     /**
173      * Returns a Java search scope limited to the hierarchy of the given type.
174      * When the hierarchy is computed, the types defined in the working copies owned
175      * by the given owner take precedence over the original compilation units.
176      * The Java elements resulting from a search with this scope will
177      * be types in this hierarchy, or members of the types in this hierarchy.
178      *
179      * @param type the focus of the hierarchy scope
180      * @param owner the owner of working copies that take precedence over original compilation units
181      * @return a new hierarchy scope
182      * @exception JavaModelException if the hierarchy could not be computed on the given type
183      * @since 3.0
184      */

185     public static IJavaSearchScope createHierarchyScope(IType type, WorkingCopyOwner owner) throws JavaModelException {
186         return BasicSearchEngine.createHierarchyScope(type, owner);
187     }
188
189     /**
190      * Returns a Java search scope limited to the given resources.
191      * The Java elements resulting from a search with this scope will
192      * have their underlying resource included in or equals to one of the given
193      * resources.
194      * <p>
195      * Resources must not overlap, for example, one cannot include a folder and its children.
196      * </p>
197      *
198      * @param resources the resources the scope is limited to
199      * @return a new Java search scope
200      * @deprecated Use {@link #createJavaSearchScope(IJavaElement[])} instead.
201      */

202     public static IJavaSearchScope createJavaSearchScope(IResource[] resources) {
203         int length = resources.length;
204         IJavaElement[] elements = new IJavaElement[length];
205         for (int i = 0; i < length; i++) {
206             elements[i] = JavaCore.create(resources[i]);
207         }
208         return createJavaSearchScope(elements);
209     }
210
211     /**
212      * Returns a Java search scope limited to the given Java elements.
213      * The Java elements resulting from a search with this scope will
214      * be children of the given elements.
215      * <p>
216      * If an element is an IJavaProject, then the project's source folders,
217      * its jars (external and internal) and its referenced projects (with their source
218      * folders and jars, recursively) will be included.
219      * If an element is an IPackageFragmentRoot, then only the package fragments of
220      * this package fragment root will be included.
221      * If an element is an IPackageFragment, then only the compilation unit and class
222      * files of this package fragment will be included. Subpackages will NOT be
223      * included.</p>
224      * <p>
225      * In other words, this is equivalent to using SearchEngine.createJavaSearchScope(elements, true).</p>
226      *
227      * @param elements the Java elements the scope is limited to
228      * @return a new Java search scope
229      * @since 2.0
230      */

231     public static IJavaSearchScope createJavaSearchScope(IJavaElement[] elements) {
232         return BasicSearchEngine.createJavaSearchScope(elements);
233     }
234
235     /**
236      * Returns a Java search scope limited to the given Java elements.
237      * The Java elements resulting from a search with this scope will
238      * be children of the given elements.
239      *
240      * If an element is an IJavaProject, then the project's source folders,
241      * its jars (external and internal) and - if specified - its referenced projects
242      * (with their source folders and jars, recursively) will be included.
243      * If an element is an IPackageFragmentRoot, then only the package fragments of
244      * this package fragment root will be included.
245      * If an element is an IPackageFragment, then only the compilation unit and class
246      * files of this package fragment will be included. Subpackages will NOT be
247      * included.
248      *
249      * @param elements the Java elements the scope is limited to
250      * @param includeReferencedProjects a flag indicating if referenced projects must be
251      * recursively included
252      * @return a new Java search scope
253      * @since 2.0
254      */

255     public static IJavaSearchScope createJavaSearchScope(IJavaElement[] elements, boolean includeReferencedProjects) {
256         return BasicSearchEngine.createJavaSearchScope(elements, includeReferencedProjects);
257     }
258
259     /**
260      * Returns a Java search scope limited to the given Java elements.
261      * The Java elements resulting from a search with this scope will
262      * be children of the given elements.
263      *
264      * If an element is an IJavaProject, then it includes:
265      * - its source folders if IJavaSearchScope.SOURCES is specified,
266      * - its application libraries (internal and external jars, class folders that are on the raw classpath,
267      * or the ones that are coming from a classpath path variable,
268      * or the ones that are coming from a classpath container with the K_APPLICATION kind)
269      * if IJavaSearchScope.APPLICATION_LIBRARIES is specified
270      * - its system libraries (internal and external jars, class folders that are coming from an
271      * IClasspathContainer with the K_SYSTEM kind)
272      * if IJavaSearchScope.APPLICATION_LIBRARIES is specified
273      * - its referenced projects (with their source folders and jars, recursively)
274      * if IJavaSearchScope.REFERENCED_PROJECTS is specified.
275      * If an element is an IPackageFragmentRoot, then only the package fragments of
276      * this package fragment root will be included.
277      * If an element is an IPackageFragment, then only the compilation unit and class
278      * files of this package fragment will be included. Subpackages will NOT be
279      * included.
280      *
281      * @param elements the Java elements the scope is limited to
282      * @param includeMask the bit-wise OR of all include types of interest
283      * @return a new Java search scope
284      * @see IJavaSearchScope#SOURCES
285      * @see IJavaSearchScope#APPLICATION_LIBRARIES
286      * @see IJavaSearchScope#SYSTEM_LIBRARIES
287      * @see IJavaSearchScope#REFERENCED_PROJECTS
288      * @since 3.0
289      */

290     public static IJavaSearchScope createJavaSearchScope(IJavaElement[] elements, int includeMask) {
291         return BasicSearchEngine.createJavaSearchScope(elements, includeMask);
292     }
293     
294     /**
295      * Returns a search pattern that combines the given two patterns into a "or" pattern.
296      * The search result will match either the left pattern or the right pattern.
297      *
298      * @param leftPattern the left pattern
299      * @param rightPattern the right pattern
300      * @return a "or" pattern
301      * @deprecated Use {@link SearchPattern#createOrPattern(SearchPattern, SearchPattern)} instead.
302      */

303     public static ISearchPattern createOrSearchPattern(ISearchPattern leftPattern, ISearchPattern rightPattern) {
304         SearchPattern left = ((SearchPatternAdapter) leftPattern).pattern;
305         SearchPattern right = ((SearchPatternAdapter) rightPattern).pattern;
306         SearchPattern pattern = SearchPattern.createOrPattern(left, right);
307         return new SearchPatternAdapter(pattern);
308     }
309     
310     /**
311      * Returns a search pattern based on a given string pattern. The string patterns support '*' wild-cards.
312      * The remaining parameters are used to narrow down the type of expected results.
313      *
314      * <br>
315      * Examples:
316      * <ul>
317      * <li>search for case insensitive references to <code>Object</code>:
318      * <code>createSearchPattern("Object", TYPE, REFERENCES, false);</code></li>
319      * <li>search for case sensitive references to exact <code>Object()</code> constructor:
320      * <code>createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true);</code></li>
321      * <li>search for implementers of <code>java.lang.Runnable</code>:
322      * <code>createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);</code></li>
323      * </ul>
324      * @param stringPattern the given pattern
325      * @param searchFor determines the nature of the searched elements
326      * <ul>
327      * <li>{@link IJavaSearchConstants#CLASS}: only look for classes</li>
328      * <li>{@link IJavaSearchConstants#INTERFACE}: only look for interfaces</li>
329      * <li>{@link IJavaSearchConstants#TYPE}: look for both classes and interfaces</li>
330      * <li>{@link IJavaSearchConstants#FIELD}: look for fields</li>
331      * <li>{@link IJavaSearchConstants#METHOD}: look for methods</li>
332      * <li>{@link IJavaSearchConstants#CONSTRUCTOR}: look for constructors</li>
333      * <li>{@link IJavaSearchConstants#PACKAGE}: look for packages</li>
334      * </ul>
335      * @param limitTo determines the nature of the expected matches
336      * <ul>
337      * <li>{@link IJavaSearchConstants#DECLARATIONS}: will search declarations matching with the corresponding
338      * element. In case the element is a method, declarations of matching methods in subtypes will also
339      * be found, allowing to find declarations of abstract methods, etc.</li>
340      *
341      * <li>{@link IJavaSearchConstants#REFERENCES}: will search references to the given element.</li>
342      *
343      * <li>{@link IJavaSearchConstants#ALL_OCCURRENCES}: will search for either declarations or references as specified
344      * above.</li>
345      *
346      * <li>{@link IJavaSearchConstants#IMPLEMENTORS}: for types, will find all types
347      * which directly implement/extend a given interface.
348      * Note that types may be only classes or only interfaces if {@link IJavaSearchConstants#CLASS } or
349      * {@link IJavaSearchConstants#INTERFACE} is respectively used instead of {@link IJavaSearchConstants#TYPE}.
350      * </li>
351      * </ul>
352      *
353      * @param isCaseSensitive indicates whether the search is case sensitive or not.
354      * @return a search pattern on the given string pattern, or <code>null</code> if the string pattern is ill-formed.
355      * @deprecated Use {@link SearchPattern#createPattern(String, int, int, int)} instead.
356      */

357     public static ISearchPattern createSearchPattern(String JavaDoc stringPattern, int searchFor, int limitTo, boolean isCaseSensitive) {
358         int matchMode = stringPattern.indexOf('*') != -1 || stringPattern.indexOf('?') != -1
359             ? SearchPattern.R_PATTERN_MATCH
360             : SearchPattern.R_EXACT_MATCH;
361         int matchRule = isCaseSensitive ? matchMode | SearchPattern.R_CASE_SENSITIVE : matchMode;
362         return new SearchPatternAdapter(SearchPattern.createPattern(stringPattern, searchFor, limitTo, matchRule));
363     }
364     
365     /**
366      * Returns a search pattern based on a given Java element.
367      * The pattern is used to trigger the appropriate search, and can be parameterized as follows:
368      *
369      * @param element the Java element the search pattern is based on
370      * @param limitTo determines the nature of the expected matches
371      * <ul>
372      * <li>{@link IJavaSearchConstants#DECLARATIONS}: will search declarations matching with the corresponding
373      * element. In case the element is a method, declarations of matching methods in subtypes will also
374      * be found, allowing to find declarations of abstract methods, etc.</li>
375      *
376      * <li>{@link IJavaSearchConstants#REFERENCES}: will search references to the given element.</li>
377      *
378      * <li>{@link IJavaSearchConstants#ALL_OCCURRENCES}: will search for either declarations or references as specified
379      * above.</li>
380      *
381      * <li>{@link IJavaSearchConstants#IMPLEMENTORS}: for types, will find all types
382      * which directly implement/extend a given interface.</li>
383      * </ul>
384      * @return a search pattern for a Java element or <code>null</code> if the given element is ill-formed
385      * @deprecated Use {@link SearchPattern#createPattern(IJavaElement, int)} instead.
386      */

387     public static ISearchPattern createSearchPattern(IJavaElement element, int limitTo) {
388         return new SearchPatternAdapter(SearchPattern.createPattern(element, limitTo));
389     }
390
391     /**
392      * Create a type name match on a given type with specific modifiers.
393      *
394      * @param type The java model handle of the type
395      * @param modifiers Modifiers of the type
396      * @return A non-null match on the given type.
397      * @since 3.3
398      */

399     public static TypeNameMatch createTypeNameMatch(IType type, int modifiers) {
400         return BasicSearchEngine.createTypeNameMatch(type, modifiers);
401     }
402
403     /**
404      * Returns a Java search scope with the workspace as the only limit.
405      *
406      * @return a new workspace scope
407      */

408     public static IJavaSearchScope createWorkspaceScope() {
409         return BasicSearchEngine.createWorkspaceScope();
410     }
411     /**
412      * Returns a new default Java search participant.
413      *
414      * @return a new default Java search participant
415      * @since 3.0
416      */

417     public static SearchParticipant getDefaultSearchParticipant() {
418         return BasicSearchEngine.getDefaultSearchParticipant();
419     }
420
421     /**
422      * Searches for the Java element determined by the given signature. The signature
423      * can be incomplete. For example, a call like
424      * <code>search(ws, "run()", METHOD,REFERENCES, col)</code>
425      * searches for all references to the method <code>run</code>.
426      *
427      * Note that by default the pattern will be case insensitive. For specifying case s
428      * sensitive search, use <code>search(workspace, createSearchPattern(patternString, searchFor, limitTo, true), scope, resultCollector);</code>
429      *
430      * @param workspace the workspace
431      * @param patternString the pattern to be searched for
432      * @param searchFor a hint what kind of Java element the string pattern represents.
433      * Look into {@link IJavaSearchConstants} for valid values
434      * @param limitTo one of the following values:
435      * <ul>
436      * <li>{@link IJavaSearchConstants#DECLARATIONS}: search
437      * for declarations only </li>
438      * <li>{@link IJavaSearchConstants#REFERENCES}: search
439      * for all references </li>
440      * <li>{@link IJavaSearchConstants#ALL_OCCURRENCES}: search
441      * for both declarations and all references </li>
442      * <li>{@link IJavaSearchConstants#IMPLEMENTORS}: for types, will find all types
443      * which directly implement/extend a given interface.<br>
444      * Note that types may be only classes or only interfaces if respectively {@link IJavaSearchConstants#CLASS} or
445      * {@link IJavaSearchConstants#INTERFACE} is used for searchFor parameter instead of {@link IJavaSearchConstants#TYPE}.
446      * </li>
447      * </ul>
448      * @param scope the search result has to be limited to the given scope
449      * @param resultCollector a callback object to which each match is reported
450      * @exception JavaModelException if the search failed. Reasons include:
451      * <ul>
452      * <li>the classpath is incorrectly set</li>
453      * </ul>
454      * @deprecated Use {@link #search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)} instead.
455      */

456     public void search(IWorkspace workspace, String JavaDoc patternString, int searchFor, int limitTo, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException {
457         try {
458             int matchMode = patternString.indexOf('*') != -1 || patternString.indexOf('?') != -1
459                 ? SearchPattern.R_PATTERN_MATCH
460                 : SearchPattern.R_EXACT_MATCH;
461             search(
462                 SearchPattern.createPattern(patternString, searchFor, limitTo, matchMode | SearchPattern.R_CASE_SENSITIVE),
463                 new SearchParticipant[] {getDefaultSearchParticipant()},
464                 scope,
465                 new ResultCollectorAdapter(resultCollector),
466                 resultCollector.getProgressMonitor());
467         } catch (CoreException e) {
468             if (e instanceof JavaModelException)
469                 throw (JavaModelException) e;
470             throw new JavaModelException(e);
471         }
472     }
473
474     /**
475      * Searches for the given Java element.
476      *
477      * @param workspace the workspace
478      * @param element the Java element to be searched for
479      * @param limitTo one of the following values:
480      * <ul>
481      * <li>{@link IJavaSearchConstants#DECLARATIONS}: search
482      * for declarations only </li>
483      * <li>{@link IJavaSearchConstants#REFERENCES}: search
484      * for all references </li>
485      * <li>{@link IJavaSearchConstants#ALL_OCCURRENCES}: search
486      * for both declarations and all references </li>
487      * <li>{@link IJavaSearchConstants#IMPLEMENTORS}: for types, will find all types
488      * which directly implement/extend a given interface.</li>
489      * </ul>
490      * @param scope the search result has to be limited to the given scope
491      * @param resultCollector a callback object to which each match is reported
492      * @exception JavaModelException if the search failed. Reasons include:
493      * <ul>
494      * <li>the element doesn't exist</li>
495      * <li>the classpath is incorrectly set</li>
496      * </ul>
497      * @deprecated Use {@link #search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)} instead.
498      */

499     public void search(IWorkspace workspace, IJavaElement element, int limitTo, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException {
500         search(workspace, createSearchPattern(element, limitTo), scope, resultCollector);
501     }
502
503     /**
504      * Searches for matches of a given search pattern. Search patterns can be created using helper
505      * methods (from a String pattern or a Java element) and encapsulate the description of what is
506      * being searched (for example, search method declarations in a case sensitive way).
507      *
508      * @param workspace the workspace
509      * @param searchPattern the pattern to be searched for
510      * @param scope the search result has to be limited to the given scope
511      * @param resultCollector a callback object to which each match is reported
512      * @exception JavaModelException if the search failed. Reasons include:
513      * <ul>
514      * <li>the classpath is incorrectly set</li>
515      * </ul>
516      * @deprecated Use {@link #search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)} instead.
517      */

518     public void search(IWorkspace workspace, ISearchPattern searchPattern, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException {
519         try {
520             search(
521                 ((SearchPatternAdapter)searchPattern).pattern,
522                 new SearchParticipant[] {getDefaultSearchParticipant()},
523                 scope,
524                 new ResultCollectorAdapter(resultCollector),
525                 resultCollector.getProgressMonitor());
526         } catch (CoreException e) {
527             if (e instanceof JavaModelException)
528                 throw (JavaModelException) e;
529             throw new JavaModelException(e);
530         }
531     }
532     
533     /**
534      * Searches for matches of a given search pattern. Search patterns can be created using helper
535      * methods (from a String pattern or a Java element) and encapsulate the description of what is
536      * being searched (for example, search method declarations in a case sensitive way).
537      *
538      * @param pattern the pattern to search
539      * @param participants the particpants in the search
540      * @param scope the search scope
541      * @param requestor the requestor to report the matches to
542      * @param monitor the progress monitor used to report progress
543      * @exception CoreException if the search failed. Reasons include:
544      * <ul>
545      * <li>the classpath is incorrectly set</li>
546      * </ul>
547      *@since 3.0
548      */

549     public void search(SearchPattern pattern, SearchParticipant[] participants, IJavaSearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException {
550         this.basicEngine.search(pattern, participants, scope, requestor, monitor);
551     }
552
553     /**
554      * Searches for all top-level types and member types in the given scope.
555      * The search can be selecting specific types (given a package exact full name or
556      * a type name with specific match mode).
557      *
558      * @param packageExactName the exact package full name of the searched types.<br>
559      * If you want to use a prefix or a wild-carded string for package, you need to use
560      * {@link #searchAllTypeNames(char[], int, char[], int, int, IJavaSearchScope, TypeNameRequestor, int, IProgressMonitor)}
561      * method instead. May be <code>null</code>, then any package name is accepted.
562      * @param typeName the dot-separated qualified name of the searched type (the qualification include
563      * the enclosing types if the searched type is a member type), or a prefix
564      * for this type, or a wild-carded string for this type.
565      * May be <code>null</code>, then any type name is accepted.
566      * @param matchRule type name match rule one of
567      * <ul>
568      * <li>{@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names
569      * of the searched types.</li>
570      * <li>{@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names
571      * of the searched types.</li>
572      * <li>{@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards.</li>
573      * <li>{@link SearchPattern#R_CAMELCASE_MATCH} if type name are camel case of the names of the searched types.</li>
574      * </ul>
575      * combined with {@link SearchPattern#R_CASE_SENSITIVE},
576      * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested,
577      * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested.
578      * @param searchFor determines the nature of the searched elements
579      * <ul>
580      * <li>{@link IJavaSearchConstants#CLASS}: only look for classes</li>
581      * <li>{@link IJavaSearchConstants#INTERFACE}: only look for interfaces</li>
582      * <li>{@link IJavaSearchConstants#ENUM}: only look for enumeration</li>
583      * <li>{@link IJavaSearchConstants#ANNOTATION_TYPE}: only look for annotation type</li>
584      * <li>{@link IJavaSearchConstants#CLASS_AND_ENUM}: only look for classes and enumerations</li>
585      * <li>{@link IJavaSearchConstants#CLASS_AND_INTERFACE}: only look for classes and interfaces</li>
586      * <li>{@link IJavaSearchConstants#TYPE}: look for all types (ie. classes, interfaces, enum and annotation types)</li>
587      * </ul>
588      * @param scope the scope to search in
589      * @param nameRequestor the requestor that collects the results of the search
590      * @param waitingPolicy one of
591      * <ul>
592      * <li>{@link IJavaSearchConstants#FORCE_IMMEDIATE_SEARCH} if the search should start immediately</li>
593      * <li>{@link IJavaSearchConstants#CANCEL_IF_NOT_READY_TO_SEARCH} if the search should be cancelled if the
594      * underlying indexer has not finished indexing the workspace</li>
595      * <li>{@link IJavaSearchConstants#WAIT_UNTIL_READY_TO_SEARCH} if the search should wait for the
596      * underlying indexer to finish indexing the workspace</li>
597      * </ul>
598      * @param progressMonitor the progress monitor to report progress to, or <code>null</code> if no progress
599      * monitor is provided
600      * @exception JavaModelException if the search failed. Reasons include:
601      * <ul>
602      * <li>the classpath is incorrectly set</li>
603      * </ul>
604      * @since 3.1
605      * @deprecated Use {@link #searchAllTypeNames(char[], int, char[], int, int, IJavaSearchScope, TypeNameRequestor, int, IProgressMonitor)}
606      * instead
607      */

608     public void searchAllTypeNames(
609         final char[] packageExactName,
610         final char[] typeName,
611         final int matchRule,
612         int searchFor,
613         IJavaSearchScope scope,
614         final TypeNameRequestor nameRequestor,
615         int waitingPolicy,
616         IProgressMonitor progressMonitor) throws JavaModelException {
617         
618         searchAllTypeNames(packageExactName, SearchPattern.R_EXACT_MATCH, typeName, matchRule, searchFor, scope, nameRequestor, waitingPolicy, progressMonitor);
619     }
620
621     /**
622      * Searches for all top-level types and member types in the given scope.
623      * The search can be selecting specific types (given a package name using specific match mode
624      * and/or a type name using another specific match mode).
625      *
626      * @param packageName the full name of the package of the searched types, or a prefix for this
627      * package, or a wild-carded string for this package.
628      * May be <code>null</code>, then any package name is accepted.
629      * @param typeName the dot-separated qualified name of the searched type (the qualification include
630      * the enclosing types if the searched type is a member type), or a prefix
631      * for this type, or a wild-carded string for this type.
632      * May be <code>null</code>, then any type name is accepted.
633      * @param packageMatchRule one of
634      * <ul>
635      * <li>{@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names
636      * of the searched types.</li>
637      * <li>{@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names
638      * of the searched types.</li>
639      * <li>{@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards.</li>
640      * <li>{@link SearchPattern#R_CAMELCASE_MATCH} if type name are camel case of the names of the searched types.</li>
641      * </ul>
642      * combined with {@link SearchPattern#R_CASE_SENSITIVE},
643      * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested,
644      * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested.
645      * @param typeMatchRule one of
646      * <ul>
647      * <li>{@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names
648      * of the searched types.</li>
649      * <li>{@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names
650      * of the searched types.</li>
651      * <li>{@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards.</li>
652      * <li>{@link SearchPattern#R_CAMELCASE_MATCH} if type name are camel case of the names of the searched types.</li>
653      * </ul>
654      * combined with {@link SearchPattern#R_CASE_SENSITIVE},
655      * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested,
656      * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested.
657      * @param searchFor determines the nature of the searched elements
658      * <ul>
659      * <li>{@link IJavaSearchConstants#CLASS}: only look for classes</li>
660      * <li>{@link IJavaSearchConstants#INTERFACE}: only look for interfaces</li>
661      * <li>{@link IJavaSearchConstants#ENUM}: only look for enumeration</li>
662      * <li>{@link IJavaSearchConstants#ANNOTATION_TYPE}: only look for annotation type</li>
663      * <li>{@link IJavaSearchConstants#CLASS_AND_ENUM}: only look for classes and enumerations</li>
664      * <li>{@link IJavaSearchConstants#CLASS_AND_INTERFACE}: only look for classes and interfaces</li>
665      * <li>{@link IJavaSearchConstants#TYPE}: look for all types (ie. classes, interfaces, enum and annotation types)</li>
666      * </ul>
667      * @param scope the scope to search in
668      * @param nameRequestor the requestor that collects the results of the search
669      * @param waitingPolicy one of
670      * <ul>
671      * <li>{@link IJavaSearchConstants#FORCE_IMMEDIATE_SEARCH} if the search should start immediately</li>
672      * <li>{@link IJavaSearchConstants#CANCEL_IF_NOT_READY_TO_SEARCH} if the search should be cancelled if the
673      * underlying indexer has not finished indexing the workspace</li>
674      * <li>{@link IJavaSearchConstants#WAIT_UNTIL_READY_TO_SEARCH} if the search should wait for the
675      * underlying indexer to finish indexing the workspace</li>
676      * </ul>
677      * @param progressMonitor the progress monitor to report progress to, or <code>null</code> if no progress
678      * monitor is provided
679      * @exception JavaModelException if the search failed. Reasons include:
680      * <ul>
681      * <li>the classpath is incorrectly set</li>
682      * </ul>
683      * @since 3.3
684      */

685     public void searchAllTypeNames(
686         final char[] packageName,
687         final int packageMatchRule,
688         final char[] typeName,
689         final int typeMatchRule,
690         int searchFor,
691         IJavaSearchScope scope,
692         final TypeNameRequestor nameRequestor,
693         int waitingPolicy,
694         IProgressMonitor progressMonitor) throws JavaModelException {
695         
696         TypeNameRequestorWrapper requestorWrapper = new TypeNameRequestorWrapper(nameRequestor);
697         this.basicEngine.searchAllTypeNames(packageName, packageMatchRule, typeName, typeMatchRule, searchFor, scope, requestorWrapper, waitingPolicy, progressMonitor);
698     }
699
700     /**
701      * Searches for all top-level types and member types in the given scope.
702      * The search can be selecting specific types (given a package name using specific match mode
703      * and/or a type name using another specific match mode).
704      * <p>
705      * Provided {@link TypeNameMatchRequestor} requestor will collect {@link TypeNameMatch}
706      * matches found during the search.
707      * </p>
708      *
709      * @param packageName the full name of the package of the searched types, or a prefix for this
710      * package, or a wild-carded string for this package.
711      * May be <code>null</code>, then any package name is accepted.
712      * @param packageMatchRule one of
713      * <ul>
714      * <li>{@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names
715      * of the searched types.</li>
716      * <li>{@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names
717      * of the searched types.</li>
718      * <li>{@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards.</li>
719      * <li>{@link SearchPattern#R_CAMELCASE_MATCH} if type name are camel case of the names of the searched types.</li>
720      * </ul>
721      * combined with {@link SearchPattern#R_CASE_SENSITIVE},
722      * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested,
723      * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested.
724      * @param typeName the dot-separated qualified name of the searched type (the qualification include
725      * the enclosing types if the searched type is a member type), or a prefix
726      * for this type, or a wild-carded string for this type.
727      * May be <code>null</code>, then any type name is accepted.
728      * @param typeMatchRule one of
729      * <ul>
730      * <li>{@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names
731      * of the searched types.</li>
732      * <li>{@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names
733      * of the searched types.</li>
734      * <li>{@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards.</li>
735      * <li>{@link SearchPattern#R_CAMELCASE_MATCH} if type name are camel case of the names of the searched types.</li>
736      * </ul>
737      * combined with {@link SearchPattern#R_CASE_SENSITIVE},
738      * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested,
739      * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested.
740      * @param searchFor determines the nature of the searched elements
741      * <ul>
742      * <li>{@link IJavaSearchConstants#CLASS}: only look for classes</li>
743      * <li>{@link IJavaSearchConstants#INTERFACE}: only look for interfaces</li>
744      * <li>{@link IJavaSearchConstants#ENUM}: only look for enumeration</li>
745      * <li>{@link IJavaSearchConstants#ANNOTATION_TYPE}: only look for annotation type</li>
746      * <li>{@link IJavaSearchConstants#CLASS_AND_ENUM}: only look for classes and enumerations</li>
747      * <li>{@link IJavaSearchConstants#CLASS_AND_INTERFACE}: only look for classes and interfaces</li>
748      * <li>{@link IJavaSearchConstants#TYPE}: look for all types (ie. classes, interfaces, enum and annotation types)</li>
749      * </ul>
750      * @param scope the scope to search in
751      * @param nameMatchRequestor the {@link TypeNameMatchRequestor requestor} that collects
752      * {@link TypeNameMatch matches} of the search.
753      * @param waitingPolicy one of
754      * <ul>
755      * <li>{@link IJavaSearchConstants#FORCE_IMMEDIATE_SEARCH} if the search should start immediately</li>
756      * <li>{@link IJavaSearchConstants#CANCEL_IF_NOT_READY_TO_SEARCH} if the search should be cancelled if the
757      * underlying indexer has not finished indexing the workspace</li>
758      * <li>{@link IJavaSearchConstants#WAIT_UNTIL_READY_TO_SEARCH} if the search should wait for the
759      * underlying indexer to finish indexing the workspace</li>
760      * </ul>
761      * @param progressMonitor the progress monitor to report progress to, or <code>null</code> if no progress
762      * monitor is provided
763      * @exception JavaModelException if the search failed. Reasons include:
764      * <ul>
765      * <li>the classpath is incorrectly set</li>
766      * </ul>
767      * @since 3.3
768      */

769     public void searchAllTypeNames(
770         final char[] packageName,
771         final int packageMatchRule,
772         final char[] typeName,
773         final int typeMatchRule,
774         int searchFor,
775         IJavaSearchScope scope,
776         final TypeNameMatchRequestor nameMatchRequestor,
777         int waitingPolicy,
778         IProgressMonitor progressMonitor) throws JavaModelException {
779         
780         TypeNameMatchRequestorWrapper requestorWrapper = new TypeNameMatchRequestorWrapper(nameMatchRequestor, scope);
781         this.basicEngine.searchAllTypeNames(packageName, packageMatchRule, typeName, typeMatchRule, searchFor, scope, requestorWrapper, waitingPolicy, progressMonitor);
782     }
783
784     /**
785      * Searches for all top-level types and member types in the given scope matching any of the given qualifications
786      * and type names in a case sensitive way.
787      *
788      * @param qualifications the qualified name of the package/enclosing type of the searched types.
789      * May be <code>null</code>, then any package name is accepted.
790      * @param typeNames the simple names of the searched types.
791      * If this parameter is <code>null</code>, then no type will be found.
792      * @param scope the scope to search in
793      * @param nameRequestor the requestor that collects the results of the search
794      * @param waitingPolicy one of
795      * <ul>
796      * <li>{@link IJavaSearchConstants#FORCE_IMMEDIATE_SEARCH} if the search should start immediately</li>
797      * <li>{@link IJavaSearchConstants#CANCEL_IF_NOT_READY_TO_SEARCH} if the search should be cancelled if the
798      * underlying indexer has not finished indexing the workspace</li>
799      * <li>{@link IJavaSearchConstants#WAIT_UNTIL_READY_TO_SEARCH} if the search should wait for the
800      * underlying indexer to finish indexing the workspace</li>
801      * </ul>
802      * @param progressMonitor the progress monitor to report progress to, or <code>null</code> if no progress
803      * monitor is provided
804      * @exception JavaModelException if the search failed. Reasons include:
805      * <ul>
806      * <li>the classpath is incorrectly set</li>
807      * </ul>
808      * @since 3.1
809      */

810     public void searchAllTypeNames(
811         final char[][] qualifications,
812         final char[][] typeNames,
813         IJavaSearchScope scope,
814         final TypeNameRequestor nameRequestor,
815         int waitingPolicy,
816         IProgressMonitor progressMonitor) throws JavaModelException {
817
818         TypeNameRequestorWrapper requestorWrapper = new TypeNameRequestorWrapper(nameRequestor);
819         this.basicEngine.searchAllTypeNames(
820             qualifications,
821             typeNames,
822             SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
823             IJavaSearchConstants.TYPE,
824             scope,
825             requestorWrapper,
826             waitingPolicy,
827             progressMonitor);
828     }
829
830     /**
831      * Searches for all top-level types and member types in the given scope matching any of the given qualifications
832      * and type names in a case sensitive way.
833      * <p>
834      * Provided {@link TypeNameMatchRequestor} requestor will collect {@link TypeNameMatch}
835      * matches found during the search.
836      * </p>
837      *
838      * @param qualifications the qualified name of the package/enclosing type of the searched types.
839      * May be <code>null</code>, then any package name is accepted.
840      * @param typeNames the simple names of the searched types.
841      * If this parameter is <code>null</code>, then no type will be found.
842      * @param scope the scope to search in
843      * @param nameMatchRequestor the {@link TypeNameMatchRequestor requestor} that collects
844      * {@link TypeNameMatch matches} of the search.
845      * @param waitingPolicy one of
846      * <ul>
847      * <li>{@link IJavaSearchConstants#FORCE_IMMEDIATE_SEARCH} if the search should start immediately</li>
848      * <li>{@link IJavaSearchConstants#CANCEL_IF_NOT_READY_TO_SEARCH} if the search should be cancelled if the
849      * underlying indexer has not finished indexing the workspace</li>
850      * <li>{@link IJavaSearchConstants#WAIT_UNTIL_READY_TO_SEARCH} if the search should wait for the
851      * underlying indexer to finish indexing the workspace</li>
852      * </ul>
853      * @param progressMonitor the progress monitor to report progress to, or <code>null</code> if no progress
854      * monitor is provided
855      * @exception JavaModelException if the search failed. Reasons include:
856      * <ul>
857      * <li>the classpath is incorrectly set</li>
858      * </ul>
859      * @since 3.3
860      */

861     public void searchAllTypeNames(
862         final char[][] qualifications,
863         final char[][] typeNames,
864         IJavaSearchScope scope,
865         final TypeNameMatchRequestor nameMatchRequestor,
866         int waitingPolicy,
867         IProgressMonitor progressMonitor) throws JavaModelException {
868
869         TypeNameMatchRequestorWrapper requestorWrapper = new TypeNameMatchRequestorWrapper(nameMatchRequestor, scope);
870         this.basicEngine.searchAllTypeNames(
871             qualifications,
872             typeNames,
873             SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
874             IJavaSearchConstants.TYPE,
875             scope,
876             requestorWrapper,
877             waitingPolicy,
878             progressMonitor);
879     }
880
881     /**
882      * Searches for all top-level types and member types in the given scope.
883      * The search can be selecting specific types (given a package or a type name
884      * prefix and match modes).
885      *
886      * @param packageName the full name of the package of the searched types, or a prefix for this
887      * package, or a wild-carded string for this package.
888      * @param typeName the dot-separated qualified name of the searched type (the qualification include
889      * the enclosing types if the searched type is a member type), or a prefix
890      * for this type, or a wild-carded string for this type.
891      * @param matchRule one of
892      * <ul>
893      * <li>{@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names
894      * of the searched types.</li>
895      * <li>{@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names
896      * of the searched types.</li>
897      * <li>{@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards.</li>
898      * </ul>
899      * combined with {@link SearchPattern#R_CASE_SENSITIVE},
900      * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested,
901      * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested.
902      * @param searchFor one of
903      * <ul>
904      * <li>{@link IJavaSearchConstants#CLASS} if searching for classes only</li>
905      * <li>{@link IJavaSearchConstants#INTERFACE} if searching for interfaces only</li>
906      * <li>{@link IJavaSearchConstants#TYPE} if searching for both classes and interfaces</li>
907      * </ul>
908      * @param scope the scope to search in
909      * @param nameRequestor the requestor that collects the results of the search
910      * @param waitingPolicy one of
911      * <ul>
912      * <li>{@link IJavaSearchConstants#FORCE_IMMEDIATE_SEARCH} if the search should start immediately</li>
913      * <li>{@link IJavaSearchConstants#CANCEL_IF_NOT_READY_TO_SEARCH} if the search should be cancelled if the
914      * underlying indexer has not finished indexing the workspace</li>
915      * <li>{@link IJavaSearchConstants#WAIT_UNTIL_READY_TO_SEARCH} if the search should wait for the
916      * underlying indexer to finish indexing the workspace</li>
917      * </ul>
918      * @param progressMonitor the progress monitor to report progress to, or <code>null</code> if no progress
919      * monitor is provided
920      * @exception JavaModelException if the search failed. Reasons include:
921      * <ul>
922      * <li>the classpath is incorrectly set</li>
923      * </ul>
924      * @since 3.0
925      *@deprecated Use {@link #searchAllTypeNames(char[], char[], int, int, IJavaSearchScope, TypeNameRequestor, int, IProgressMonitor)} instead
926      */

927     public void searchAllTypeNames(
928         final char[] packageName,
929         final char[] typeName,
930         final int matchRule,
931         int searchFor,
932         IJavaSearchScope scope,
933         final ITypeNameRequestor nameRequestor,
934         int waitingPolicy,
935         IProgressMonitor progressMonitor) throws JavaModelException {
936         
937         TypeNameRequestorAdapter requestorAdapter = new TypeNameRequestorAdapter(nameRequestor);
938         this.basicEngine.searchAllTypeNames(packageName, SearchPattern.R_EXACT_MATCH, typeName, matchRule, searchFor, scope, requestorAdapter, waitingPolicy, progressMonitor);
939     }
940
941     /**
942      * Searches for all top-level types and member types in the given scope.
943      * The search can be selecting specific types (given a package or a type name
944      * prefix and match modes).
945      *
946      * @param workspace the workspace to search in
947      * @param packageName the full name of the package of the searched types, or a prefix for this
948      * package, or a wild-carded string for this package.
949      * @param typeName the dot-separated qualified name of the searched type (the qualification include
950      * the enclosing types if the searched type is a member type), or a prefix
951      * for this type, or a wild-carded string for this type.
952      * @param matchMode one of
953      * <ul>
954      * <li>{@link IJavaSearchConstants#EXACT_MATCH} if the package name and type name are the full names
955      * of the searched types.</li>
956      * <li>{@link IJavaSearchConstants#PREFIX_MATCH} if the package name and type name are prefixes of the names
957      * of the searched types.</li>
958      * <li>{@link IJavaSearchConstants#PATTERN_MATCH} if the package name and type name contain wild-cards.</li>
959      * </ul>
960      * @param isCaseSensitive whether the search should be case sensitive
961      * @param searchFor one of
962      * <ul>
963      * <li>{@link IJavaSearchConstants#CLASS} if searching for classes only</li>
964      * <li>{@link IJavaSearchConstants#INTERFACE} if searching for interfaces only</li>
965      * <li>{@link IJavaSearchConstants#TYPE} if searching for both classes and interfaces</li>
966      * </ul>
967      * @param scope the scope to search in
968      * @param nameRequestor the requestor that collects the results of the search
969      * @param waitingPolicy one of
970      * <ul>
971      * <li>{@link IJavaSearchConstants#FORCE_IMMEDIATE_SEARCH} if the search should start immediately</li>
972      * <li>{@link IJavaSearchConstants#CANCEL_IF_NOT_READY_TO_SEARCH} if the search should be cancelled if the
973      * underlying indexer has not finished indexing the workspace</li>
974      * <li>{@link IJavaSearchConstants#WAIT_UNTIL_READY_TO_SEARCH} if the search should wait for the
975      * underlying indexer to finish indexing the workspace</li>
976      * </ul>
977      * @param progressMonitor the progress monitor to report progress to, or <code>null</code> if no progress
978      * monitor is provided
979      * @exception JavaModelException if the search failed. Reasons include:
980      * <ul>
981      * <li>the classpath is incorrectly set</li>
982      * </ul>
983      *@deprecated Use {@link #searchAllTypeNames(char[], char[], int, int, IJavaSearchScope, ITypeNameRequestor, int, IProgressMonitor)} instead
984      */

985     public void searchAllTypeNames(
986         IWorkspace workspace,
987         final char[] packageName,
988         final char[] typeName,
989         final int matchMode,
990         final boolean isCaseSensitive,
991         int searchFor,
992         IJavaSearchScope scope,
993         final ITypeNameRequestor nameRequestor,
994         int waitingPolicy,
995         IProgressMonitor progressMonitor) throws JavaModelException {
996         
997         searchAllTypeNames(
998             packageName,
999             typeName,
1000            isCaseSensitive ? matchMode | SearchPattern.R_CASE_SENSITIVE : matchMode,
1001            searchFor,
1002            scope,
1003            nameRequestor,
1004            waitingPolicy,
1005            progressMonitor);
1006    }
1007
1008    /**
1009     * Searches for all declarations of the fields accessed in the given element.
1010     * The element can be a compilation unit, a source type, or a source method.
1011     * Reports the field declarations using the given requestor.
1012     * <p>
1013     * Consider the following code:
1014     * <code>
1015     * <pre>
1016     * class A {
1017     * int field1;
1018     * }
1019     * class B extends A {
1020     * String value;
1021     * }
1022     * class X {
1023     * void test() {
1024     * B b = new B();
1025     * System.out.println(b.value + b.field1);
1026     * };
1027     * }
1028     * </pre>
1029     * </code>
1030     * then searching for declarations of accessed fields in method
1031     * <code>X.test()</code> would collect the fields
1032     * <code>B.value</code> and <code>A.field1</code>.
1033     * </p>
1034     *
1035     * @param enclosingElement the method, type, or compilation unit to be searched in
1036     * @param requestor a callback object to which each match is reported
1037     * @param monitor the progress monitor used to report progress
1038     * @exception JavaModelException if the search failed. Reasons include:
1039     * <ul>
1040     * <li>the element doesn't exist</li>
1041     * <li>the classpath is incorrectly set</li>
1042     * </ul>
1043     * @since 3.0
1044     */

1045    public void searchDeclarationsOfAccessedFields(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException {
1046        this.basicEngine.searchDeclarationsOfAccessedFields(enclosingElement, requestor, monitor);
1047    }
1048    
1049    /**
1050     * Searches for all declarations of the fields accessed in the given element.
1051     * The element can be a compilation unit, a source type, or a source method.
1052     * Reports the field declarations using the given collector.
1053     * <p>
1054     * Consider the following code:
1055     * <code>
1056     * <pre>
1057     * class A {
1058     * int field1;
1059     * }
1060     * class B extends A {
1061     * String value;
1062     * }
1063     * class X {
1064     * void test() {
1065     * B b = new B();
1066     * System.out.println(b.value + b.field1);
1067     * };
1068     * }
1069     * </pre>
1070     * </code>
1071     * then searching for declarations of accessed fields in method
1072     * <code>X.test()</code> would collect the fields
1073     * <code>B.value</code> and <code>A.field1</code>.
1074     * </p>
1075     *
1076     * @param workspace the workspace
1077     * @param enclosingElement the method, type, or compilation unit to be searched in
1078     * @param resultCollector a callback object to which each match is reported
1079     * @exception JavaModelException if the search failed. Reasons include:
1080     * <ul>
1081     * <li>the element doesn't exist</li>
1082     * <li>the classpath is incorrectly set</li>
1083     * </ul>
1084     * @deprecated Use {@link #searchDeclarationsOfAccessedFields(IJavaElement, SearchRequestor, IProgressMonitor)} instead.
1085     */

1086    public void searchDeclarationsOfAccessedFields(IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException {
1087        SearchPattern pattern = new DeclarationOfAccessedFieldsPattern(enclosingElement);
1088        this.basicEngine.searchDeclarations(enclosingElement, new ResultCollectorAdapter(resultCollector), pattern, resultCollector.getProgressMonitor());
1089    }
1090    
1091    /**
1092     * Searches for all declarations of the types referenced in the given element.
1093     * The element can be a compilation unit, a source type, or a source method.
1094     * Reports the type declarations using the given requestor.
1095     * <p>
1096     * Consider the following code:
1097     * <code>
1098     * <pre>
1099     * class A {
1100     * }
1101     * class B extends A {
1102     * }
1103     * interface I {
1104     * int VALUE = 0;
1105     * }
1106     * class X {
1107     * void test() {
1108     * B b = new B();
1109     * this.foo(b, I.VALUE);
1110     * };
1111     * }
1112     * </pre>
1113     * </code>
1114     * then searching for declarations of referenced types in method <code>X.test()</code>
1115     * would collect the class <code>B</code> and the interface <code>I</code>.
1116     * </p>
1117     *
1118     * @param enclosingElement the method, type, or compilation unit to be searched in
1119     * @param requestor a callback object to which each match is reported
1120     * @param monitor the progress monitor used to report progress
1121     * @exception JavaModelException if the search failed. Reasons include:
1122     * <ul>
1123     * <li>the element doesn't exist</li>
1124     * <li>the classpath is incorrectly set</li>
1125     * </ul>
1126     * @since 3.0
1127     */

1128    public void searchDeclarationsOfReferencedTypes(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException {
1129        this.basicEngine.searchDeclarationsOfReferencedTypes(enclosingElement, requestor, monitor);
1130    }
1131    
1132    /**
1133     * Searches for all declarations of the types referenced in the given element.
1134     * The element can be a compilation unit, a source type, or a source method.
1135     * Reports the type declarations using the given collector.
1136     * <p>
1137     * Consider the following code:
1138     * <code>
1139     * <pre>
1140     * class A {
1141     * }
1142     * class B extends A {
1143     * }
1144     * interface I {
1145     * int VALUE = 0;
1146     * }
1147     * class X {
1148     * void test() {
1149     * B b = new B();
1150     * this.foo(b, I.VALUE);
1151     * };
1152     * }
1153     * </pre>
1154     * </code>
1155     * then searching for declarations of referenced types in method <code>X.test()</code>
1156     * would collect the class <code>B</code> and the interface <code>I</code>.
1157     * </p>
1158     *
1159     * @param workspace the workspace
1160     * @param enclosingElement the method, type, or compilation unit to be searched in
1161     * @param resultCollector a callback object to which each match is reported
1162     * @exception JavaModelException if the search failed. Reasons include:
1163     * <ul>
1164     * <li>the element doesn't exist</li>
1165     * <li>the classpath is incorrectly set</li>
1166     * </ul>
1167     * @deprecated Use {@link #searchDeclarationsOfReferencedTypes(IJavaElement, SearchRequestor, IProgressMonitor)} instead.
1168     */

1169    public void searchDeclarationsOfReferencedTypes(IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException {
1170        SearchPattern pattern = new DeclarationOfReferencedTypesPattern(enclosingElement);
1171        this.basicEngine.searchDeclarations(enclosingElement, new ResultCollectorAdapter(resultCollector), pattern, resultCollector.getProgressMonitor());
1172    }
1173    
1174    /**
1175     * Searches for all declarations of the methods invoked in the given element.
1176     * The element can be a compilation unit, a source type, or a source method.
1177     * Reports the method declarations using the given requestor.
1178     * <p>
1179     * Consider the following code:
1180     * <code>
1181     * <pre>
1182     * class A {
1183     * void foo() {};
1184     * void bar() {};
1185     * }
1186     * class B extends A {
1187     * void foo() {};
1188     * }
1189     * class X {
1190     * void test() {
1191     * A a = new B();
1192     * a.foo();
1193     * B b = (B)a;
1194     * b.bar();
1195     * };
1196     * }
1197     * </pre>
1198     * </code>
1199     * then searching for declarations of sent messages in method
1200     * <code>X.test()</code> would collect the methods
1201     * <code>A.foo()</code>, <code>B.foo()</code>, and <code>A.bar()</code>.
1202     * </p>
1203     *
1204     * @param enclosingElement the method, type, or compilation unit to be searched in
1205     * @param requestor a callback object to which each match is reported
1206     * @param monitor the progress monitor used to report progress
1207     * @exception JavaModelException if the search failed. Reasons include:
1208     * <ul>
1209     * <li>the element doesn't exist</li>
1210     * <li>the classpath is incorrectly set</li>
1211     * </ul>
1212     * @since 3.0
1213     */

1214    public void searchDeclarationsOfSentMessages(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException {
1215        this.basicEngine.searchDeclarationsOfSentMessages(enclosingElement, requestor, monitor);
1216    }
1217
1218    /**
1219     * Searches for all declarations of the methods invoked in the given element.
1220     * The element can be a compilation unit, a source type, or a source method.
1221     * Reports the method declarations using the given collector.
1222     * <p>
1223     * Consider the following code:
1224     * <code>
1225     * <pre>
1226     * class A {
1227     * void foo() {};
1228     * void bar() {};
1229     * }
1230     * class B extends A {
1231     * void foo() {};
1232     * }
1233     * class X {
1234     * void test() {
1235     * A a = new B();
1236     * a.foo();
1237     * B b = (B)a;
1238     * b.bar();
1239     * };
1240     * }
1241     * </pre>
1242     * </code>
1243     * then searching for declarations of sent messages in method
1244     * <code>X.test()</code> would collect the methods
1245     * <code>A.foo()</code>, <code>B.foo()</code>, and <code>A.bar()</code>.
1246     * </p>
1247     *
1248     * @param workspace the workspace
1249     * @param enclosingElement the method, type, or compilation unit to be searched in
1250     * @param resultCollector a callback object to which each match is reported
1251     * @exception JavaModelException if the search failed. Reasons include:
1252     * <ul>
1253     * <li>the element doesn't exist</li>
1254     * <li>the classpath is incorrectly set</li>
1255     * </ul>
1256     * @deprecated Use {@link #searchDeclarationsOfSentMessages(IJavaElement, SearchRequestor, IProgressMonitor)} instead.
1257     */

1258    public void searchDeclarationsOfSentMessages(IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException {
1259        SearchPattern pattern = new DeclarationOfReferencedMethodsPattern(enclosingElement);
1260        this.basicEngine.searchDeclarations(enclosingElement, new ResultCollectorAdapter(resultCollector), pattern, resultCollector.getProgressMonitor());
1261    }
1262}
1263
Popular Tags