Class SearchEngine
SearchEngine
searches for Java elements following a search pattern.
The search can be limited to a search scope.
Various search patterns can be created using the factory methods
SearchPattern.createPattern(String, int, int, int)
, SearchPattern.createPattern(IJavaElement, int)
,
SearchPattern.createOrPattern(SearchPattern, SearchPattern)
.
For example, one can search for references to a method in the hierarchy of a type, or one can search for the declarations of types starting with "Abstract" in a project.
This class may be instantiated.
- Restriction:
- This class is not intended to be subclassed by clients.
-
Constructor Summary
ConstructorDescriptionCreates a new search engine.SearchEngine
(ICompilationUnit[] workingCopies) Creates a new search engine with a list of working copies that will take precedence over their original compilation units in the subsequent search operations.SearchEngine
(IWorkingCopy[] workingCopies) Deprecated.SearchEngine
(WorkingCopyOwner workingCopyOwner) Creates a new search engine with the given working copy owner. -
Method Summary
Modifier and TypeMethodDescriptionstatic IJavaSearchScope
createHierarchyScope
(IType type) Returns a Java search scope limited to the hierarchy of the given type.static IJavaSearchScope
createHierarchyScope
(IType type, WorkingCopyOwner owner) Returns a Java search scope limited to the hierarchy of the given type.static IJavaSearchScope
createJavaSearchScope
(boolean excludeTestCode, IJavaElement[] elements, boolean includeReferencedProjects) Returns a Java search scope limited to the given Java elements.static IJavaSearchScope
createJavaSearchScope
(boolean excludeTestCode, IJavaElement[] elements, int includeMask) Returns a Java search scope limited to the given Java elements.static IJavaSearchScope
createJavaSearchScope
(org.eclipse.core.resources.IResource[] resources) Deprecated.UsecreateJavaSearchScope(IJavaElement[])
instead.static IJavaSearchScope
createJavaSearchScope
(IJavaElement[] elements) Returns a Java search scope limited to the given Java elements.static IJavaSearchScope
createJavaSearchScope
(IJavaElement[] elements, boolean includeReferencedProjects) Returns a Java search scope limited to the given Java elements.static IJavaSearchScope
createJavaSearchScope
(IJavaElement[] elements, int includeMask) Returns a Java search scope limited to the given Java elements.static MethodNameMatch
createMethodNameMatch
(IMethod method, int modifiers) Create a method name match on a given method with specific modifiers.static ISearchPattern
createOrSearchPattern
(ISearchPattern leftPattern, ISearchPattern rightPattern) Deprecated.static ISearchPattern
createSearchPattern
(String stringPattern, int searchFor, int limitTo, boolean isCaseSensitive) Deprecated.UseSearchPattern.createPattern(String, int, int, int)
instead.static ISearchPattern
createSearchPattern
(IJavaElement element, int limitTo) Deprecated.UseSearchPattern.createPattern(IJavaElement, int)
instead.static IJavaSearchScope
createStrictHierarchyScope
(IJavaProject project, IType type, boolean onlySubtypes, boolean includeFocusType, WorkingCopyOwner owner) Returns a Java search scope limited to the hierarchy of the given type and to a given project.static TypeNameMatch
createTypeNameMatch
(IType type, int modifiers) Create a type name match on a given type with specific modifiers.static IJavaSearchScope
Returns a Java search scope with the workspace as the only limit.static SearchParticipant
Returns a new default Java search participant.void
search
(org.eclipse.core.resources.IWorkspace workspace, String patternString, int searchFor, int limitTo, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) Deprecated.void
search
(org.eclipse.core.resources.IWorkspace workspace, IJavaElement element, int limitTo, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) Deprecated.void
search
(org.eclipse.core.resources.IWorkspace workspace, ISearchPattern searchPattern, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) Deprecated.void
search
(SearchPattern pattern, SearchParticipant[] participants, IJavaSearchScope scope, SearchRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) Searches for matches of a given search pattern.void
searchAllMethodNames
(char[] packageName, int pkgMatchRule, char[] declaringQualification, int declQualificationMatchRule, char[] declaringSimpleName, int declSimpleNameMatchRule, char[] methodName, int methodMatchRule, IJavaSearchScope scope, MethodNameMatchRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Searches for all method declarations in the given scope.void
searchAllMethodNames
(char[] packageName, int pkgMatchRule, char[] declaringQualification, int declQualificationMatchRule, char[] declaringSimpleName, int declSimpleNameMatchRule, char[] methodName, int methodMatchRule, IJavaSearchScope scope, MethodNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Searches for all method declarations in the given scope.void
searchAllMethodNames
(char[] qualifier, int qualifierMatchRule, char[] methodName, int methodMatchRule, IJavaSearchScope scope, MethodNameMatchRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Searches for all method declarations in the given scope.void
searchAllMethodNames
(char[] qualifier, int qualifierMatchRule, char[] methodName, int methodMatchRule, IJavaSearchScope scope, MethodNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Searches for all method declarations in the given scope.void
searchAllTypeNames
(char[][] qualifications, char[][] typeNames, IJavaSearchScope scope, TypeNameMatchRequestor nameMatchRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Searches for all top-level types and member types in the given scope matching any of the given qualifications and type names in a case sensitive way.void
searchAllTypeNames
(char[][] qualifications, char[][] typeNames, IJavaSearchScope scope, TypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Searches for all top-level types and member types in the given scope matching any of the given qualifications and type names in a case sensitive way.void
searchAllTypeNames
(char[] packageName, char[] typeName, int matchRule, int searchFor, IJavaSearchScope scope, ITypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) void
searchAllTypeNames
(char[] packageExactName, char[] typeName, int matchRule, int searchFor, IJavaSearchScope scope, TypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) void
searchAllTypeNames
(char[] packageName, int packageMatchRule, char[] typeName, int typeMatchRule, int searchFor, IJavaSearchScope scope, TypeNameMatchRequestor nameMatchRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Searches for all top-level types and member types in the given scope.void
searchAllTypeNames
(char[] packageName, int packageMatchRule, char[] typeName, int typeMatchRule, int searchFor, IJavaSearchScope scope, TypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) Searches for all top-level types and member types in the given scope.void
searchAllTypeNames
(org.eclipse.core.resources.IWorkspace workspace, char[] packageName, char[] typeName, int matchMode, boolean isCaseSensitive, int searchFor, IJavaSearchScope scope, ITypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) void
searchDeclarationsOfAccessedFields
(org.eclipse.core.resources.IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) Deprecated.void
searchDeclarationsOfAccessedFields
(IJavaElement enclosingElement, SearchRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) Searches for all declarations of the fields accessed in the given element.void
searchDeclarationsOfReferencedTypes
(org.eclipse.core.resources.IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) Deprecated.void
searchDeclarationsOfReferencedTypes
(IJavaElement enclosingElement, SearchRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) Searches for all declarations of the types referenced in the given element.void
searchDeclarationsOfSentMessages
(org.eclipse.core.resources.IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) Deprecated.void
searchDeclarationsOfSentMessages
(IJavaElement enclosingElement, SearchRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) Searches for all declarations of the methods invoked in the given element.
-
Constructor Details
-
SearchEngine
public SearchEngine()Creates a new search engine. -
SearchEngine
Creates a new search engine with a list of working copies that will take precedence over their original compilation units in the subsequent search operations.Note that passing an empty working copy will be as if the original compilation unit had been deleted.
Since 3.0 the given working copies take precedence over primary working copies (if any).
- Parameters:
workingCopies
- the working copies that take precedence over their original compilation units- Since:
- 3.0
-
SearchEngine
Deprecated.UseSearchEngine(ICompilationUnit[])
instead.Creates a new search engine with a list of working copies that will take precedence over their original compilation units in the subsequent search operations.Note that passing an empty working copy will be as if the original compilation unit had been deleted.
Since 3.0 the given working copies take precedence over primary working copies (if any).
- Parameters:
workingCopies
- the working copies that take precedence over their original compilation units- Since:
- 2.0
-
SearchEngine
Creates a new search engine with the given working copy owner. The working copies owned by this owner will take precedence over the primary compilation units in the subsequent search operations.- Parameters:
workingCopyOwner
- the owner of the working copies that take precedence over their original compilation units- Since:
- 3.0
-
-
Method Details
-
createHierarchyScope
Returns a Java search scope limited to the hierarchy of the given type. The Java elements resulting from a search with this scope will be types in this hierarchy, or members of the types in this hierarchy.- Parameters:
type
- the focus of the hierarchy scope- Returns:
- a new hierarchy scope
- Throws:
JavaModelException
- if the hierarchy could not be computed on the given type
-
createHierarchyScope
public static IJavaSearchScope createHierarchyScope(IType type, WorkingCopyOwner owner) throws JavaModelException Returns a Java search scope limited to the hierarchy of the given type. When the hierarchy is computed, the types defined in the working copies owned by the given owner take precedence over the original compilation units. The Java elements resulting from a search with this scope will be types in this hierarchy, or members of the types in this hierarchy.- Parameters:
type
- the focus of the hierarchy scopeowner
- the owner of working copies that take precedence over original compilation units- Returns:
- a new hierarchy scope
- Throws:
JavaModelException
- if the hierarchy could not be computed on the given type- Since:
- 3.0
-
createStrictHierarchyScope
public static IJavaSearchScope createStrictHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean includeFocusType, WorkingCopyOwner owner) throws JavaModelException Returns a Java search scope limited to the hierarchy of the given type and to a given project. The Java elements resulting from a search with this scope will be types in this hierarchy.Unlike the
createHierarchyScope
methods, this method creates strict scopes that only contain types that actually span the hierarchy of the focus type, but do not include additional enclosing or member types.By default, hierarchy scopes include all direct and indirect supertypes and subtypes of the focus type. This method, however, allows to restrict the hierarchy to true subtypes, and exclude supertypes. Also, inclusion of the focus type itself is controlled by a parameter.
- Parameters:
project
- the project to which to constrain the search, ornull
if search should consider all types in the workspacetype
- the focus of the hierarchy scopeonlySubtypes
- iftrue
only subtypes oftype
are consideredincludeFocusType
- if true the focus typetype
is included in the resulting scope, otherwise it is excludedowner
- the owner of working copies that take precedence over original compilation units, ornull
if the primary working copy owner should be used- Returns:
- a new hierarchy scope
- Throws:
JavaModelException
- if the hierarchy could not be computed on the given type- Since:
- 3.6
-
createJavaSearchScope
public static IJavaSearchScope createJavaSearchScope(org.eclipse.core.resources.IResource[] resources) Deprecated.UsecreateJavaSearchScope(IJavaElement[])
instead.Returns a Java search scope limited to the given resources. The Java elements resulting from a search with this scope will have their underlying resource included in or equals to one of the given resources.Resources must not overlap, for example, one cannot include a folder and its children.
- Parameters:
resources
- the resources the scope is limited to- Returns:
- a new Java search scope
-
createJavaSearchScope
Returns a Java search scope limited to the given Java elements. The Java elements resulting from a search with this scope will be children of the given elements.If an element is an
IJavaProject
, then the project's source folders, its jars (external and internal) and its referenced projects (with their source folders and jars, recursively) will be included.If an element is an
IPackageFragmentRoot
, then only the package fragments of this package fragment root will be included.If an element is an
IPackageFragment
, then only the compilation unit and class files of this package fragment will be included. Subpackages will NOT be included.In other words, this is equivalent to using SearchEngine.createJavaSearchScope(elements, true).
- Parameters:
elements
- the Java elements the scope is limited to- Returns:
- a new Java search scope
- Since:
- 2.0
-
createJavaSearchScope
public static IJavaSearchScope createJavaSearchScope(IJavaElement[] elements, boolean includeReferencedProjects) Returns a Java search scope limited to the given Java elements. The Java elements resulting from a search with this scope will be children of the given elements.If an element is an
IJavaProject
, then the project's source folders, its jars (external and internal) and - if specified - its referenced projects (with their source folders and jars, recursively) will be included.If an element is an
IPackageFragmentRoot
, then only the package fragments of this package fragment root will be included.If an element is an
IPackageFragment
, then only the compilation unit and class files of this package fragment will be included. Subpackages will NOT be included.- Parameters:
elements
- the Java elements the scope is limited toincludeReferencedProjects
- a flag indicating if referenced projects must be recursively included- Returns:
- a new Java search scope
- Since:
- 2.0
-
createJavaSearchScope
public static IJavaSearchScope createJavaSearchScope(boolean excludeTestCode, IJavaElement[] elements, boolean includeReferencedProjects) Returns a Java search scope limited to the given Java elements. The Java elements resulting from a search with this scope will be children of the given elements.If an element is an
IJavaProject
, then the project's source folders, its jars (external and internal) and - if specified - its referenced projects (with their source folders and jars, recursively) will be included.If an element is an
IPackageFragmentRoot
, then only the package fragments of this package fragment root will be included.If an element is an
IPackageFragment
, then only the compilation unit and class files of this package fragment will be included. Subpackages will NOT be included.- Parameters:
excludeTestCode
- if true, test code we be excludedelements
- the Java elements the scope is limited toincludeReferencedProjects
- a flag indicating if referenced projects must be recursively included- Returns:
- a new Java search scope
- Since:
- 3.14
-
createJavaSearchScope
Returns a Java search scope limited to the given Java elements. The Java elements resulting from a search with this scope will be children of the given elements.If an element is an IJavaProject, then it includes:
- its source folders if
IJavaSearchScope.SOURCES
is specified, - its application libraries (internal and external jars, class folders that are on the raw classpath,
or the ones that are coming from a classpath path variable,
or the ones that are coming from a classpath container with the K_APPLICATION kind)
if
IJavaSearchScope.APPLICATION_LIBRARIES
is specified - its system libraries (internal and external jars, class folders that are coming from an
IClasspathContainer with the K_SYSTEM kind)
if
IJavaSearchScope.SYSTEM_LIBRARIES
is specified - its referenced projects (with their source folders and jars, recursively)
if
IJavaSearchScope.REFERENCED_PROJECTS
is specified.
If an element is an
IPackageFragmentRoot
, then only the package fragments of this package fragment root will be included.If an element is an
IPackageFragment
, then only the compilation unit and class files of this package fragment will be included. Subpackages will NOT be included.- Parameters:
elements
- the Java elements the scope is limited toincludeMask
- the bit-wise OR of all include types of interest- Returns:
- a new Java search scope
- Since:
- 3.0
- See Also:
- its source folders if
-
createJavaSearchScope
public static IJavaSearchScope createJavaSearchScope(boolean excludeTestCode, IJavaElement[] elements, int includeMask) Returns a Java search scope limited to the given Java elements. The Java elements resulting from a search with this scope will be children of the given elements.If an element is an IJavaProject, then it includes:
- its source folders if
IJavaSearchScope.SOURCES
is specified, - its application libraries (internal and external jars, class folders that are on the raw classpath,
or the ones that are coming from a classpath path variable,
or the ones that are coming from a classpath container with the K_APPLICATION kind)
if
IJavaSearchScope.APPLICATION_LIBRARIES
is specified - its system libraries (internal and external jars, class folders that are coming from an
IClasspathContainer with the K_SYSTEM kind)
if
IJavaSearchScope.SYSTEM_LIBRARIES
is specified - its referenced projects (with their source folders and jars, recursively)
if
IJavaSearchScope.REFERENCED_PROJECTS
is specified.
If an element is an
IPackageFragmentRoot
, then only the package fragments of this package fragment root will be included.If an element is an
IPackageFragment
, then only the compilation unit and class files of this package fragment will be included. Subpackages will NOT be included.- Parameters:
elements
- the Java elements the scope is limited toincludeMask
- the bit-wise OR of all include types of interest- Returns:
- a new Java search scope
- Since:
- 3.14
- See Also:
- its source folders if
-
createOrSearchPattern
public static ISearchPattern createOrSearchPattern(ISearchPattern leftPattern, ISearchPattern rightPattern) Deprecated.Returns a search pattern that combines the given two patterns into a "or" pattern. The search result will match either the left pattern or the right pattern.- Parameters:
leftPattern
- the left patternrightPattern
- the right pattern- Returns:
- a "or" pattern
-
createSearchPattern
public static ISearchPattern createSearchPattern(String stringPattern, int searchFor, int limitTo, boolean isCaseSensitive) Deprecated.UseSearchPattern.createPattern(String, int, int, int)
instead.Returns a search pattern based on a given string pattern. The string patterns support '*' wild-cards. The remaining parameters are used to narrow down the type of expected results.
Examples:- search for case insensitive references to
Object
:createSearchPattern("Object", TYPE, REFERENCES, false);
- search for case sensitive references to exact
Object()
constructor:createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true);
- search for implementers of
java.lang.Runnable
:createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);
- Parameters:
stringPattern
- the given patternsearchFor
- determines the nature of the searched elementsIJavaSearchConstants.CLASS
: only look for classesIJavaSearchConstants.INTERFACE
: only look for interfacesIJavaSearchConstants.TYPE
: look for both classes and interfacesIJavaSearchConstants.FIELD
: look for fieldsIJavaSearchConstants.METHOD
: look for methodsIJavaSearchConstants.CONSTRUCTOR
: look for constructorsIJavaSearchConstants.PACKAGE
: look for packages
limitTo
- determines the nature of the expected matchesIJavaSearchConstants.DECLARATIONS
: will search declarations matching with the corresponding element. In case the element is a method, declarations of matching methods in subtypes will also be found, allowing to find declarations of abstract methods, etc.IJavaSearchConstants.REFERENCES
: will search references to the given element.IJavaSearchConstants.ALL_OCCURRENCES
: will search for either declarations or references as specified above.IJavaSearchConstants.IMPLEMENTORS
: for types, will find all types which directly implement/extend a given interface. Note that types may be only classes or only interfaces ifIJavaSearchConstants.CLASS
orIJavaSearchConstants.INTERFACE
is respectively used instead ofIJavaSearchConstants.TYPE
.
isCaseSensitive
- indicates whether the search is case sensitive or not.- Returns:
- a search pattern on the given string pattern, or
null
if the string pattern is ill-formed.
- search for case insensitive references to
-
createSearchPattern
Deprecated.UseSearchPattern.createPattern(IJavaElement, int)
instead.Returns a search pattern based on a given Java element. The pattern is used to trigger the appropriate search, and can be parameterized as follows:- Parameters:
element
- the Java element the search pattern is based onlimitTo
- determines the nature of the expected matchesIJavaSearchConstants.DECLARATIONS
: will search declarations matching with the corresponding element. In case the element is a method, declarations of matching methods in subtypes will also be found, allowing to find declarations of abstract methods, etc.IJavaSearchConstants.REFERENCES
: will search references to the given element.IJavaSearchConstants.ALL_OCCURRENCES
: will search for either declarations or references as specified above.IJavaSearchConstants.IMPLEMENTORS
: for types, will find all types which directly implement/extend a given interface.
- Returns:
- a search pattern for a Java element or
null
if the given element is ill-formed
-
createTypeNameMatch
Create a type name match on a given type with specific modifiers.- Parameters:
type
- The java model handle of the typemodifiers
- Modifiers of the type- Returns:
- A non-null match on the given type.
- Since:
- 3.3
-
createMethodNameMatch
Create a method name match on a given method with specific modifiers.NOTE: this is a first-cut version and might have noticeable delay times in some cases. Targeted for optimization during 4.7. It is recommended to contact JDT Team if anyone plans to use this.
- Parameters:
method
- The Java model handle of the methodmodifiers
- Modifiers of the method- Returns:
- A non-null match on the given method.
- Since:
- 3.12
-
createWorkspaceScope
Returns a Java search scope with the workspace as the only limit.- Returns:
- a new workspace scope
-
getDefaultSearchParticipant
Returns a new default Java search participant.- Returns:
- a new default Java search participant
- Since:
- 3.0
-
search
public void search(org.eclipse.core.resources.IWorkspace workspace, String patternString, int searchFor, int limitTo, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException Deprecated.Searches for the Java element determined by the given signature. The signature can be incomplete. For example, a call likesearch(ws, "run()", METHOD,REFERENCES, col)
searches for all references to the methodrun
. Note that by default the pattern will be case insensitive. For specifying case s sensitive search, usesearch(workspace, createSearchPattern(patternString, searchFor, limitTo, true), scope, resultCollector);
- Parameters:
workspace
- the workspacepatternString
- the pattern to be searched forsearchFor
- a hint what kind of Java element the string pattern represents. Look intoIJavaSearchConstants
for valid valueslimitTo
- one of the following values:IJavaSearchConstants.DECLARATIONS
: search for declarations onlyIJavaSearchConstants.REFERENCES
: search for all referencesIJavaSearchConstants.ALL_OCCURRENCES
: search for both declarations and all referencesIJavaSearchConstants.IMPLEMENTORS
: for types, will find all types which directly implement/extend a given interface.
Note that types may be only classes or only interfaces if respectivelyIJavaSearchConstants.CLASS
orIJavaSearchConstants.INTERFACE
is used for searchFor parameter instead ofIJavaSearchConstants.TYPE
.
scope
- the search result has to be limited to the given scoperesultCollector
- a callback object to which each match is reported- Throws:
JavaModelException
- if the search failed. Reasons include:- the classpath is incorrectly set
-
search
public void search(org.eclipse.core.resources.IWorkspace workspace, IJavaElement element, int limitTo, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException Deprecated.Searches for the given Java element.- Parameters:
workspace
- the workspaceelement
- the Java element to be searched forlimitTo
- one of the following values:IJavaSearchConstants.DECLARATIONS
: search for declarations onlyIJavaSearchConstants.REFERENCES
: search for all referencesIJavaSearchConstants.ALL_OCCURRENCES
: search for both declarations and all referencesIJavaSearchConstants.IMPLEMENTORS
: for types, will find all types which directly implement/extend a given interface.
scope
- the search result has to be limited to the given scoperesultCollector
- a callback object to which each match is reported- Throws:
JavaModelException
- if the search failed. Reasons include:- the element doesn't exist
- the classpath is incorrectly set
-
search
public void search(org.eclipse.core.resources.IWorkspace workspace, ISearchPattern searchPattern, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException Deprecated.Searches for matches of a given search pattern. Search patterns can be created using helper methods (from a String pattern or a Java element) and encapsulate the description of what is being searched (for example, search method declarations in a case sensitive way).- Parameters:
workspace
- the workspacesearchPattern
- the pattern to be searched forscope
- the search result has to be limited to the given scoperesultCollector
- a callback object to which each match is reported- Throws:
JavaModelException
- if the search failed. Reasons include:- the classpath is incorrectly set
-
search
public void search(SearchPattern pattern, SearchParticipant[] participants, IJavaSearchScope scope, SearchRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Searches for matches of a given search pattern. Search patterns can be created using helper methods (from a String pattern or a Java element) and encapsulate the description of what is being searched (for example, search method declarations in a case sensitive way).- Parameters:
pattern
- the pattern to searchparticipants
- the participants in the searchscope
- the search scoperequestor
- the requestor to report the matches tomonitor
- the progress monitor used to report progress- Throws:
org.eclipse.core.runtime.CoreException
- if the search failed. Reasons include:- the classpath is incorrectly set
- Since:
- 3.0
-
searchAllMethodNames
public void searchAllMethodNames(char[] packageName, int pkgMatchRule, char[] declaringQualification, int declQualificationMatchRule, char[] declaringSimpleName, int declSimpleNameMatchRule, char[] methodName, int methodMatchRule, IJavaSearchScope scope, MethodNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Searches for all method declarations in the given scope. Accepted matches will be returned byMethodNameRequestor.acceptMethod(char[], int, char[], char[], int, char[], char[], char[][], char[][], char[], int, java.lang.String, int)
.NOTE: this is a first-cut version and might have noticeable delay times in some cases. Targeted for optimization during 4.7. It is recommended to contact JDT Team if anyone plans to use this.
- Parameters:
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. May benull
, then any package name is accepted.pkgMatchRule
- match rule for package.declaringQualification
- Qualification of the declaring type.declQualificationMatchRule
- match rule for declaring qualifier of parent of the type.declaringSimpleName
- simple name of the declaring type.declSimpleNameMatchRule
- match rule for the simple name of the enclosing type.methodName
- the method name searched for.methodMatchRule
- match rule for the method name.scope
- the scope to search innameRequestor
- the requestor that collects the results of the search.waitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed.- Since:
- 3.12
-
searchAllMethodNames
public void searchAllMethodNames(char[] packageName, int pkgMatchRule, char[] declaringQualification, int declQualificationMatchRule, char[] declaringSimpleName, int declSimpleNameMatchRule, char[] methodName, int methodMatchRule, IJavaSearchScope scope, MethodNameMatchRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Searches for all method declarations in the given scope.Provided
MethodNameMatchRequestor
requestor will collect theMethodNameMatch
matches found during the search.NOTE: this is a first-cut version and might have noticeable delay times in some cases. Targeted for optimization during 4.7. It is recommended to contact JDT Team if anyone plans to use this.
- Parameters:
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. May benull
, then any package name is accepted.pkgMatchRule
- match rule for package.declaringQualification
- Qualification of the declaring type.declQualificationMatchRule
- match rule for declaring qualifier of parent of the type.declaringSimpleName
- simple name of the declaring type.declSimpleNameMatchRule
- match rule for the simple name of the enclosing type.methodName
- the method name searched for.methodMatchRule
- match rule for the method name.scope
- the scope to search innameRequestor
- theMethodNameMatchRequestor
waitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed.- Since:
- 3.12
-
searchAllMethodNames
public void searchAllMethodNames(char[] qualifier, int qualifierMatchRule, char[] methodName, int methodMatchRule, IJavaSearchScope scope, MethodNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Searches for all method declarations in the given scope. Accepted matches will be returned byMethodNameRequestor.acceptMethod(char[], int, char[], char[], int, char[], char[], char[][], char[][], char[], int, java.lang.String, int)
.NOTE: this is a first-cut version and might have noticeable delay times in some cases. Targeted for optimization during 4.7. It is recommended to contact JDT Team if anyone plans to use this.
- Parameters:
qualifier
- qualifier including package name and qualified type name May benull
, then any qualifier name is accepted.qualifierMatchRule
- match rule for the qualifier and can be one of *SearchPattern.R_EXACT_MATCH
if the package name and type name are the full names of the types of the searched methods.SearchPattern.R_PREFIX_MATCH
if the package name and type name are prefixes of the names of the types of searched methods.SearchPattern.R_PATTERN_MATCH
if the package name and type name contain wild-cards.SearchPattern.R_CAMELCASE_MATCH
if the package name and types are camel case of the package and type of searched methods.SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH
if the package name and type names are camel case with same part count of the package and types of searched methods.
methodName
- the method name searched for.methodMatchRule
- match rule for the method name and can be one ofSearchPattern.R_EXACT_MATCH
if the method name searched is exact.SearchPattern.R_PREFIX_MATCH
if method name is prefix of the names of the searched methods.SearchPattern.R_PATTERN_MATCH
if the method name contains wild-cards.SearchPattern.R_CAMELCASE_MATCH
if the method name is a camel case of the searched method name.SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH
if the method name is a camel case with same part count of the searched methods name.
scope
- the scope to search innameRequestor
- the requestor that collects the results of the search.waitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed.- Since:
- 3.12
-
searchAllMethodNames
public void searchAllMethodNames(char[] qualifier, int qualifierMatchRule, char[] methodName, int methodMatchRule, IJavaSearchScope scope, MethodNameMatchRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Searches for all method declarations in the given scope.Provided
MethodNameMatchRequestor
requestor will collect theMethodNameMatch
matches found during the search.NOTE: this is a first-cut version and might have noticeable delay times in some cases. Targeted for optimization during 4.7. It is recommended to contact JDT Team if anyone plans to use this.
- Parameters:
qualifier
- qualifier including package name and qualified type name May benull
, then any qualifier name is accepted.qualifierMatchRule
- match rule for the qualifier and can be one of *SearchPattern.R_EXACT_MATCH
if the package name and type name are the full names of the types of the searched methods.SearchPattern.R_PREFIX_MATCH
if the package name and type name are prefixes of the names of the types of searched methods.SearchPattern.R_PATTERN_MATCH
if the package name and type name contain wild-cards.SearchPattern.R_CAMELCASE_MATCH
if the package name and types are camel case of the package and type of searched methods.SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH
if the package name and type names are camel case with same part count of the package and types of searched methods.
methodName
- the method name searched for.methodMatchRule
- match rule for the method name and can be one ofSearchPattern.R_EXACT_MATCH
if the method name searched is exact.SearchPattern.R_PREFIX_MATCH
if method name is prefix of the names of the searched methods.SearchPattern.R_PATTERN_MATCH
if the method name contains wild-cards.SearchPattern.R_CAMELCASE_MATCH
if the method name is a camel case of the searched method name.SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH
if the method name is a camel case with same part count of the searched methods name.
scope
- the scope to search innameRequestor
- theMethodNameMatchRequestor
waitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed.- Since:
- 3.12
-
searchAllTypeNames
public void searchAllTypeNames(char[] packageExactName, char[] typeName, int matchRule, int searchFor, IJavaSearchScope scope, TypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Deprecated.Searches for all top-level types and member types in the given scope. The search can be selecting specific types (given a package exact full name or a type name with specific match mode).- Parameters:
packageExactName
- the exact package full name of the searched types.
If you want to use a prefix or a wild-carded string for package, you need to usesearchAllTypeNames(char[], int, char[], int, int, IJavaSearchScope, TypeNameRequestor, int, IProgressMonitor)
method instead. May benull
, then any package name is accepted.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. May benull
, then any type name is accepted.matchRule
- type name match rule one ofSearchPattern.R_EXACT_MATCH
if the package name and type name are the full names of the searched types.SearchPattern.R_PREFIX_MATCH
if the package name and type name are prefixes of the names of the searched types.SearchPattern.R_PATTERN_MATCH
if the package name and type name contain wild-cards.SearchPattern.R_CAMELCASE_MATCH
if the type name is a camel case of the searched types name.SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH
if the type name is a camel case with same part count of the searched types name.
SearchPattern.R_CASE_SENSITIVE
, e.g.SearchPattern.R_EXACT_MATCH
|SearchPattern.R_CASE_SENSITIVE
if an exact and case sensitive match is requested, orSearchPattern.R_PREFIX_MATCH
if a prefix non case sensitive match is requested.searchFor
- determines the nature of the searched elementsIJavaSearchConstants.CLASS
: only look for classesIJavaSearchConstants.INTERFACE
: only look for interfacesIJavaSearchConstants.ENUM
: only look for enumerationIJavaSearchConstants.ANNOTATION_TYPE
: only look for annotation typeIJavaSearchConstants.CLASS_AND_ENUM
: only look for classes and enumerationsIJavaSearchConstants.CLASS_AND_INTERFACE
: only look for classes and interfacesIJavaSearchConstants.TYPE
: look for all types (i.e. classes, interfaces, enum and annotation types)
scope
- the scope to search innameRequestor
- the requestor that collects the results of the searchwaitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed. Reasons include:- the classpath is incorrectly set
- Since:
- 3.1
-
searchAllTypeNames
public void searchAllTypeNames(char[] packageName, int packageMatchRule, char[] typeName, int typeMatchRule, int searchFor, IJavaSearchScope scope, TypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Searches for all top-level types and member types in the given scope. The search can be selecting specific types (given a package name using specific match mode and/or a type name using another specific match mode).- Parameters:
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. May benull
, then any package name is accepted.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. May benull
, then any type name is accepted.packageMatchRule
- one ofSearchPattern.R_EXACT_MATCH
if the package name and type name are the full names of the searched types.SearchPattern.R_PREFIX_MATCH
if the package name and type name are prefixes of the names of the searched types.SearchPattern.R_PATTERN_MATCH
if the package name and type name contain wild-cards.SearchPattern.R_CAMELCASE_MATCH
if the package name is a camel case of the searched types package name.SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH
if the package name is a camel case with same part count of the searched types package name.
SearchPattern.R_CASE_SENSITIVE
, e.g.SearchPattern.R_EXACT_MATCH
|SearchPattern.R_CASE_SENSITIVE
if an exact and case sensitive match is requested, orSearchPattern.R_PREFIX_MATCH
if a prefix non case sensitive match is requested.typeMatchRule
- one ofSearchPattern.R_EXACT_MATCH
if the package name and type name are the full names of the searched types.SearchPattern.R_PREFIX_MATCH
if the package name and type name are prefixes of the names of the searched types.SearchPattern.R_PATTERN_MATCH
if the package name and type name contain wild-cards.SearchPattern.R_CAMELCASE_MATCH
if the type name is a camel case of the searched types name.SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH
if the type name is a camel case with same part count of the searched types name.
SearchPattern.R_CASE_SENSITIVE
, e.g.SearchPattern.R_EXACT_MATCH
|SearchPattern.R_CASE_SENSITIVE
if an exact and case sensitive match is requested, orSearchPattern.R_PREFIX_MATCH
if a prefix non case sensitive match is requested.searchFor
- determines the nature of the searched elementsIJavaSearchConstants.CLASS
: only look for classesIJavaSearchConstants.INTERFACE
: only look for interfacesIJavaSearchConstants.ENUM
: only look for enumerationIJavaSearchConstants.ANNOTATION_TYPE
: only look for annotation typeIJavaSearchConstants.CLASS_AND_ENUM
: only look for classes and enumerationsIJavaSearchConstants.CLASS_AND_INTERFACE
: only look for classes and interfacesIJavaSearchConstants.TYPE
: look for all types (i.e. classes, interfaces, enum and annotation types)
scope
- the scope to search innameRequestor
- the requestor that collects the results of the searchwaitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed. Reasons include:- the classpath is incorrectly set
- Since:
- 3.3
-
searchAllTypeNames
public void searchAllTypeNames(char[] packageName, int packageMatchRule, char[] typeName, int typeMatchRule, int searchFor, IJavaSearchScope scope, TypeNameMatchRequestor nameMatchRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Searches for all top-level types and member types in the given scope. The search can be selecting specific types (given a package name using specific match mode and/or a type name using another specific match mode).Provided
TypeNameMatchRequestor
requestor will collectTypeNameMatch
matches found during the search.- Parameters:
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. May benull
, then any package name is accepted.packageMatchRule
- one ofSearchPattern.R_EXACT_MATCH
if the package name and type name are the full names of the searched types.SearchPattern.R_PREFIX_MATCH
if the package name and type name are prefixes of the names of the searched types.SearchPattern.R_PATTERN_MATCH
if the package name and type name contain wild-cards.SearchPattern.R_CAMELCASE_MATCH
if the package name is a camel case of the searched types package name.SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH
if the package name is a camel case with same part count of the searched types package name.
SearchPattern.R_CASE_SENSITIVE
, e.g.SearchPattern.R_EXACT_MATCH
|SearchPattern.R_CASE_SENSITIVE
if an exact and case sensitive match is requested, orSearchPattern.R_PREFIX_MATCH
if a prefix non case sensitive match is requested.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. May benull
, then any type name is accepted.typeMatchRule
- one ofSearchPattern.R_EXACT_MATCH
if the package name and type name are the full names of the searched types.SearchPattern.R_PREFIX_MATCH
if the package name and type name are prefixes of the names of the searched types.SearchPattern.R_PATTERN_MATCH
if the package name and type name contain wild-cards.SearchPattern.R_CAMELCASE_MATCH
if the type name is a camel case of the searched types name.SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH
if the type name is a camel case with same part count of the searched types name.
SearchPattern.R_CASE_SENSITIVE
, e.g.SearchPattern.R_EXACT_MATCH
|SearchPattern.R_CASE_SENSITIVE
if an exact and case sensitive match is requested, orSearchPattern.R_PREFIX_MATCH
if a prefix non case sensitive match is requested.searchFor
- determines the nature of the searched elementsIJavaSearchConstants.CLASS
: only look for classesIJavaSearchConstants.INTERFACE
: only look for interfacesIJavaSearchConstants.ENUM
: only look for enumerationIJavaSearchConstants.ANNOTATION_TYPE
: only look for annotation typeIJavaSearchConstants.CLASS_AND_ENUM
: only look for classes and enumerationsIJavaSearchConstants.CLASS_AND_INTERFACE
: only look for classes and interfacesIJavaSearchConstants.TYPE
: look for all types (i.e. classes, interfaces, enum and annotation types)
scope
- the scope to search innameMatchRequestor
- therequestor
that collectsmatches
of the search.waitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed. Reasons include:- the classpath is incorrectly set
- Since:
- 3.3
-
searchAllTypeNames
public void searchAllTypeNames(char[][] qualifications, char[][] typeNames, IJavaSearchScope scope, TypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Searches for all top-level types and member types in the given scope matching any of the given qualifications and type names in a case sensitive way.- Parameters:
qualifications
- the qualified name of the package/enclosing type of the searched types. May benull
, then any package name is accepted.typeNames
- the simple names of the searched types. If this parameter isnull
, then no type will be found.scope
- the scope to search innameRequestor
- the requestor that collects the results of the searchwaitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed. Reasons include:- the classpath is incorrectly set
- Since:
- 3.1
-
searchAllTypeNames
public void searchAllTypeNames(char[][] qualifications, char[][] typeNames, IJavaSearchScope scope, TypeNameMatchRequestor nameMatchRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Searches for all top-level types and member types in the given scope matching any of the given qualifications and type names in a case sensitive way.Provided
TypeNameMatchRequestor
requestor will collectTypeNameMatch
matches found during the search.- Parameters:
qualifications
- the qualified name of the package/enclosing type of the searched types. May benull
, then any package name is accepted.typeNames
- the simple names of the searched types. If this parameter isnull
, then no type will be found.scope
- the scope to search innameMatchRequestor
- therequestor
that collectsmatches
of the search.waitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed. Reasons include:- the classpath is incorrectly set
- Since:
- 3.3
-
searchAllTypeNames
public void searchAllTypeNames(char[] packageName, char[] typeName, int matchRule, int searchFor, IJavaSearchScope scope, ITypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Deprecated.Searches for all top-level types and member types in the given scope. The search can be selecting specific types (given a package or a type name prefix and match modes).- Parameters:
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.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.matchRule
- one ofSearchPattern.R_EXACT_MATCH
if the package name and type name are the full names of the searched types.SearchPattern.R_PREFIX_MATCH
if the package name and type name are prefixes of the names of the searched types.SearchPattern.R_PATTERN_MATCH
if the package name and type name contain wild-cards.
SearchPattern.R_CASE_SENSITIVE
, e.g.SearchPattern.R_EXACT_MATCH
|SearchPattern.R_CASE_SENSITIVE
if an exact and case sensitive match is requested, orSearchPattern.R_PREFIX_MATCH
if a prefix non case sensitive match is requested.searchFor
- one ofIJavaSearchConstants.CLASS
if searching for classes onlyIJavaSearchConstants.INTERFACE
if searching for interfaces onlyIJavaSearchConstants.TYPE
if searching for both classes and interfaces
scope
- the scope to search innameRequestor
- the requestor that collects the results of the searchwaitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed. Reasons include:- the classpath is incorrectly set
- Since:
- 3.0
-
searchAllTypeNames
public void searchAllTypeNames(org.eclipse.core.resources.IWorkspace workspace, char[] packageName, char[] typeName, int matchMode, boolean isCaseSensitive, int searchFor, IJavaSearchScope scope, ITypeNameRequestor nameRequestor, int waitingPolicy, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws JavaModelException Deprecated.Searches for all top-level types and member types in the given scope. The search can be selecting specific types (given a package or a type name prefix and match modes).- Parameters:
workspace
- the workspace to search inpackageName
- the full name of the package of the searched types, or a prefix for this package, or a wild-carded string for this package.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.matchMode
- one ofIJavaSearchConstants.EXACT_MATCH
if the package name and type name are the full names of the searched types.IJavaSearchConstants.PREFIX_MATCH
if the package name and type name are prefixes of the names of the searched types.IJavaSearchConstants.PATTERN_MATCH
if the package name and type name contain wild-cards.
isCaseSensitive
- whether the search should be case sensitivesearchFor
- one ofIJavaSearchConstants.CLASS
if searching for classes onlyIJavaSearchConstants.INTERFACE
if searching for interfaces onlyIJavaSearchConstants.TYPE
if searching for both classes and interfaces
scope
- the scope to search innameRequestor
- the requestor that collects the results of the searchwaitingPolicy
- one ofIJavaSearchConstants.FORCE_IMMEDIATE_SEARCH
if the search should start immediatelyIJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH
if the search should be cancelled if the underlying indexer has not finished indexing the workspaceIJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
if the search should wait for the underlying indexer to finish indexing the workspace
progressMonitor
- the progress monitor to report progress to, ornull
if no progress monitor is provided- Throws:
JavaModelException
- if the search failed. Reasons include:- the classpath is incorrectly set
-
searchDeclarationsOfAccessedFields
public void searchDeclarationsOfAccessedFields(IJavaElement enclosingElement, SearchRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Searches for all declarations of the fields accessed in the given element. The element can be a compilation unit or a source type/method/field. Reports the field declarations using the given requestor.Consider the following code:
class A { int field1; } class B extends A { String value; } class X { void test() { B b = new B(); System.out.println(b.value + b.field1); }; }
then searching for declarations of accessed fields in method
X.test()
would collect the fieldsB.value
andA.field1
.- Parameters:
enclosingElement
- the field, method, type, or compilation unit to be searched inrequestor
- a callback object to which each match is reportedmonitor
- the progress monitor used to report progress- Throws:
JavaModelException
- if the search failed. Reasons include:- the element doesn't exist
- the classpath is incorrectly set
IllegalArgumentException
- if the given java element has not the right type- Since:
- 3.0
-
searchDeclarationsOfAccessedFields
public void searchDeclarationsOfAccessedFields(org.eclipse.core.resources.IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException Deprecated.Searches for all declarations of the fields accessed in the given element. The element can be a compilation unit, a source type, or a source method. Reports the field declarations using the given collector.Consider the following code:
class A { int field1; } class B extends A { String value; } class X { void test() { B b = new B(); System.out.println(b.value + b.field1); }; }
then searching for declarations of accessed fields in method
X.test()
would collect the fieldsB.value
andA.field1
.- Parameters:
workspace
- the workspaceenclosingElement
- the method, type, or compilation unit to be searched inresultCollector
- a callback object to which each match is reported- Throws:
JavaModelException
- if the search failed. Reasons include:- the element doesn't exist
- the classpath is incorrectly set
-
searchDeclarationsOfReferencedTypes
public void searchDeclarationsOfReferencedTypes(IJavaElement enclosingElement, SearchRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Searches for all declarations of the types referenced in the given element. The element can be a compilation unit or a source type/method/field. Reports the type declarations using the given requestor.Consider the following code:
class A { } class B extends A { } interface I { int VALUE = 0; } class X { void test() { B b = new B(); this.foo(b, I.VALUE); }; }
then searching for declarations of referenced types in method
X.test()
would collect the classB
and the interfaceI
.- Parameters:
enclosingElement
- the field, method, type, or compilation unit to be searched inrequestor
- a callback object to which each match is reportedmonitor
- the progress monitor used to report progress- Throws:
JavaModelException
- if the search failed. Reasons include:- the element doesn't exist
- the classpath is incorrectly set
IllegalArgumentException
- if the given java element has not the right type- Since:
- 3.0
-
searchDeclarationsOfReferencedTypes
public void searchDeclarationsOfReferencedTypes(org.eclipse.core.resources.IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException Deprecated.Searches for all declarations of the types referenced in the given element. The element can be a compilation unit, a source type, or a source method. Reports the type declarations using the given collector.Consider the following code:
class A { } class B extends A { } interface I { int VALUE = 0; } class X { void test() { B b = new B(); this.foo(b, I.VALUE); }; }
then searching for declarations of referenced types in method
X.test()
would collect the classB
and the interfaceI
.- Parameters:
workspace
- the workspaceenclosingElement
- the method, type, or compilation unit to be searched inresultCollector
- a callback object to which each match is reported- Throws:
JavaModelException
- if the search failed. Reasons include:- the element doesn't exist
- the classpath is incorrectly set
-
searchDeclarationsOfSentMessages
public void searchDeclarationsOfSentMessages(IJavaElement enclosingElement, SearchRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Searches for all declarations of the methods invoked in the given element. The element can be a compilation unit or a source type/method/field. Reports the method declarations using the given requestor.Consider the following code:
class A { void foo() {}; void bar() {}; } class B extends A { void foo() {}; } class X { void test() { A a = new B(); a.foo(); B b = (B)a; b.bar(); }; }
then searching for declarations of sent messages in method
X.test()
would collect the methodsA.foo()
,B.foo()
, andA.bar()
.- Parameters:
enclosingElement
- the field, method, type or compilation unit to be searched inrequestor
- a callback object to which each match is reportedmonitor
- the progress monitor used to report progress- Throws:
JavaModelException
- if the search failed. Reasons include:- the element doesn't exist
- the classpath is incorrectly set
IllegalArgumentException
- if the given java element has not the right type- Since:
- 3.0
-
searchDeclarationsOfSentMessages
public void searchDeclarationsOfSentMessages(org.eclipse.core.resources.IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException Deprecated.Searches for all declarations of the methods invoked in the given element. The element can be a compilation unit, a source type, or a source method. Reports the method declarations using the given collector.Consider the following code:
class A { void foo() {}; void bar() {}; } class B extends A { void foo() {}; } class X { void test() { A a = new B(); a.foo(); B b = (B)a; b.bar(); }; }
then searching for declarations of sent messages in method
X.test()
would collect the methodsA.foo()
,B.foo()
, andA.bar()
.- Parameters:
workspace
- the workspaceenclosingElement
- the method, type, or compilation unit to be searched inresultCollector
- a callback object to which each match is reported- Throws:
JavaModelException
- if the search failed. Reasons include:- the element doesn't exist
- the classpath is incorrectly set
-
SearchEngine(ICompilationUnit[])
instead.