Class MatchLocator
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.search.matching.MatchLocator
- All Implemented Interfaces:
ITypeRequestor
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
Modifier and TypeFieldDescriptionchar[][][]
int
static int
int
org.eclipse.core.runtime.IProgressMonitor
long
-
Constructor Summary
ConstructorDescriptionMatchLocator(SearchPattern pattern, SearchRequestor requestor, IJavaSearchScope scope, org.eclipse.core.runtime.IProgressMonitor progressMonitor)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
accept(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction)
Add an additional binary typevoid
accept(ICompilationUnit sourceUnit, AccessRestriction accessRestriction)
Add an additional compilation unit into the loop -> build compilation unit declarations, their bindings and record their results.void
accept(ISourceType[] sourceTypes, PackageBinding packageBinding, AccessRestriction accessRestriction)
Add additional source typesstatic SearchDocument[]
addWorkingCopies(SearchPattern pattern, SearchDocument[] indexMatches, ICompilationUnit[] copies, SearchParticipant participant)
protected Parser
protected BinaryTypeBinding
cacheBinaryType(IType type, IBinaryType binaryType)
static IBinaryType
classFileReader(IType type)
protected char[][][]
computeSuperTypeNames(IType focusType)
protected IJavaElement
createHandle(AbstractMethodDeclaration method, IJavaElement parent)
Creates an IMethod from the given method declaration and type.protected IJavaElement
createHandle(AbstractVariableDeclaration variableDeclaration, IJavaElement parent)
Create an handle for a local variable declaration (may be a local variable or type parameter).protected IJavaElement
createHandle(Annotation annotation, IAnnotatable parent)
Create an handle for a local variable declaration (may be a local variable or type parameter).protected IJavaElement
createHandle(FieldDeclaration fieldDeclaration, TypeDeclaration typeDeclaration, IJavaElement parent)
Creates an IField from the given field declaration and type.protected IJavaElement
createHandle(LambdaExpression lambdaExpression, IJavaElement parent)
Creates an IMethod from the given lambda declaration and type.protected boolean
createHierarchyResolver(IType focusType, PossibleMatch[] possibleMatches)
protected IJavaElement
createImportHandle(ImportReference importRef)
Creates an IImportDeclaration from the given import statementprotected IJavaElement
Creates an IImportDeclaration from the given import statementprotected IType
createTypeHandle(String simpleTypeName)
Creates an IType from the given simple top level type name.protected boolean
encloses(IJavaElement element)
static void
findIndexMatches(SearchPattern pattern, Index index, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, org.eclipse.core.runtime.IProgressMonitor monitor)
Query a given index for matching entries.protected IBinaryType
getBinaryInfo(ClassFile classFile, org.eclipse.core.resources.IResource resource)
protected IType
getMethodBinding(MethodPattern methodPattern)
protected void
getMethodBodies(CompilationUnitDeclaration unit, MatchingNodeSet nodeSet)
static IJavaElement
getProjectOrJar(IJavaElement element)
protected TypeBinding
protected boolean
hasAlreadyDefinedType(CompilationUnitDeclaration parsedUnit)
void
initialize(JavaProject project, int possibleMatchSize)
Create a new parser for the given project, as well as a lookup environment.void
locateMatches(SearchDocument[] searchDocuments)
Locate the matches in the given files and report them using the search requestor.protected void
locateMatches(JavaProject javaProject, PossibleMatch[] possibleMatches, int start, int length)
protected void
locateMatches(JavaProject javaProject, PossibleMatchSet matchSet, int expected)
Locate the matches amongst the possible matches.protected void
locatePackageDeclarations(SearchParticipant participant, IJavaProject[] projects)
Locates the package declarations corresponding to this locator's pattern.protected void
locatePackageDeclarations(SearchPattern searchPattern, SearchParticipant participant, IJavaProject[] projects)
Locates the package declarations corresponding to the search pattern.protected IType
lookupType(ReferenceBinding typeBinding)
newDeclarationMatch(IJavaElement element, Binding binding, int accuracy, int offset, int length)
newDeclarationMatch(IJavaElement element, Binding binding, int accuracy, int offset, int length, SearchParticipant participant, org.eclipse.core.resources.IResource resource)
newFieldReferenceMatch(IJavaElement enclosingElement, IJavaElement localElement, Binding enclosingBinding, int accuracy, int offset, int length, ASTNode reference)
newLocalVariableReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, ASTNode reference)
newMethodReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, int offset, int length, boolean isConstructor, boolean isSynthetic, ASTNode reference)
newModuleReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, int offset, int length, ASTNode reference)
newModuleReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, ASTNode reference)
newPackageReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, ASTNode reference)
newTypeParameterReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, ASTNode reference)
newTypeReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, int offset, int length, ASTNode reference)
newTypeReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, ASTNode reference)
protected boolean
parseAndBuildBindings(PossibleMatch possibleMatch, boolean mustResolve)
Add the possibleMatch to the loop -> build compilation unit declarations, their bindings and record their results.protected void
process(PossibleMatch possibleMatch, boolean bindingsWereCreated)
static IJavaElement
projectOrJarFocus(SearchPattern pattern)
protected void
purgeMethodStatements(TypeDeclaration type, boolean checkEachMethod)
protected void
Called prior to the unit being resolved.protected void
report(SearchMatch match)
protected void
reportAccurateEnumConstructorReference(SearchMatch match, FieldDeclaration field, AllocationExpression allocation)
Finds the accurate positions of each valid token in the source and reports a reference to this token to the search requestor.protected void
reportAccurateFieldReference(SearchMatch[] matches, QualifiedNameReference qNameRef)
Finds the accurate positions of each valid token in the source and reports a reference to this token to the search requestor.protected void
reportAccurateParameterizedMethodReference(SearchMatch match, ASTNode statement, TypeReference[] typeArguments)
Finds the accurate positions of the sequence of tokens given by qualifiedName in the source and reports a reference to this parameterized type name to the search requestor.protected void
reportAccurateParameterizedTypeReference(SearchMatch match, TypeReference typeRef, int index, TypeReference[] typeArguments)
Finds the accurate positions of the sequence of tokens given by qualifiedName in the source and reports a reference to this parameterized type name to the search requestor.protected void
reportAccurateTypeReference(SearchMatch match, ASTNode typeRef, char[] name)
Finds the accurate positions of the sequence of tokens given by qualifiedName in the source and reports a reference to this this qualified name to the search requestor.protected void
reportBinaryMemberDeclaration(org.eclipse.core.resources.IResource resource, IMember binaryMember, Binding binaryMemberBinding, IBinaryType info, int accuracy)
protected void
reportMatching(AbstractMethodDeclaration method, TypeDeclaration type, IJavaElement parent, int accuracy, boolean typeInHierarchy, MatchingNodeSet nodeSet)
Visit the given method declaration and report the nodes that match exactly the search pattern (i.e. the ones in the matching nodes set) Note that the method declaration has already been checked.protected void
reportMatching(Annotation[] annotations, IJavaElement enclosingElement, IJavaElement[] otherElements, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedContainer, boolean enclosesElement)
Report matching in annotations.protected void
reportMatching(CompilationUnitDeclaration unit, boolean mustResolve)
Visit the given resolved parse tree and report the nodes that match the search pattern.protected void
reportMatching(FieldDeclaration field, FieldDeclaration[] otherFields, TypeDeclaration type, IJavaElement parent, int accuracy, boolean typeInHierarchy, MatchingNodeSet nodeSet)
Visit the given field declaration and report the nodes that match exactly the search pattern (i.e. the ones in the matching nodes set)protected void
reportMatching(LambdaExpression lambdaExpression, IJavaElement parent, int accuracy, MatchingNodeSet nodeSet, boolean typeInHierarchy)
protected void
reportMatching(ModuleDeclaration module, IJavaElement parent, int accuracy, MatchingNodeSet nodeSet, int occurrenceCount)
Visit the given module declaration and report the nodes that match exactly the search pattern (i.e. the ones in the matching nodes set)protected void
reportMatching(TypeDeclaration type, IJavaElement parent, int accuracy, MatchingNodeSet nodeSet, int occurrenceCount)
Visit the given type declaration and report the nodes that match exactly the search pattern (i.e. the ones in the matching nodes set)protected void
reportMatching(TypeParameter[] typeParameters, IJavaElement enclosingElement, IJavaElement parent, Binding binding, MatchingNodeSet nodeSet)
Report matches in type parameters.protected void
reportMatchingSuperOrPermit(TypeReference superReference, IJavaElement enclosingElement, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedClassContainer)
static void
setFocus(SearchPattern pattern, IJavaElement focus)
static void
setIndexQualifierQuery(SearchPattern pattern, char[] queries)
Sets the qualifier queries into pattern.protected boolean
typeInHierarchy(ReferenceBinding binding)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.aspectj.org.eclipse.jdt.internal.compiler.impl.ITypeRequestor
accept
-
Field Details
-
MAX_AT_ONCE
public static final int MAX_AT_ONCE -
pattern
-
patternLocator
-
matchContainer
public int matchContainer -
requestor
-
scope
-
progressMonitor
public org.eclipse.core.runtime.IProgressMonitor progressMonitor -
workingCopies
-
handleFactory
-
allSuperTypeNames
public char[][][] allSuperTypeNames -
parser
-
nameEnvironment
-
nameLookup
-
lookupEnvironment
-
hierarchyResolver
-
options
-
numberOfMatches
public int numberOfMatches -
matchesToProcess
-
currentPossibleMatch
-
resultCollectorTime
public long resultCollectorTime
-
-
Constructor Details
-
MatchLocator
public MatchLocator(SearchPattern pattern, SearchRequestor requestor, IJavaSearchScope scope, org.eclipse.core.runtime.IProgressMonitor progressMonitor)
-
-
Method Details
-
addWorkingCopies
public static SearchDocument[] addWorkingCopies(SearchPattern pattern, SearchDocument[] indexMatches, ICompilationUnit[] copies, SearchParticipant participant) -
setFocus
-
setIndexQualifierQuery
Sets the qualifier queries into pattern. -
classFileReader
-
findIndexMatches
public static void findIndexMatches(SearchPattern pattern, Index index, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, org.eclipse.core.runtime.IProgressMonitor monitor) throws IOExceptionQuery a given index for matching entries. Assumes the sender has opened the index and will close when finished.- Throws:
IOException
-
getProjectOrJar
-
projectOrJarFocus
-
accept
public void accept(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction)Add an additional binary type- Specified by:
accept
in interfaceITypeRequestor
-
accept
Add an additional compilation unit into the loop -> build compilation unit declarations, their bindings and record their results.- Specified by:
accept
in interfaceITypeRequestor
-
accept
public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding, AccessRestriction accessRestriction)Add additional source types- Specified by:
accept
in interfaceITypeRequestor
-
basicParser
-
cacheBinaryType
protected BinaryTypeBinding cacheBinaryType(IType type, IBinaryType binaryType) throws JavaModelException- Throws:
JavaModelException
-
computeSuperTypeNames
-
createHandle
Creates an IMethod from the given lambda declaration and type. -
createHandle
Creates an IMethod from the given method declaration and type. -
createHandle
protected IJavaElement createHandle(FieldDeclaration fieldDeclaration, TypeDeclaration typeDeclaration, IJavaElement parent)Creates an IField from the given field declaration and type. -
createHandle
protected IJavaElement createHandle(AbstractVariableDeclaration variableDeclaration, IJavaElement parent)Create an handle for a local variable declaration (may be a local variable or type parameter). -
createHandle
Create an handle for a local variable declaration (may be a local variable or type parameter). -
createHierarchyResolver
-
createImportHandle
Creates an IImportDeclaration from the given import statement -
createPackageDeclarationHandle
Creates an IImportDeclaration from the given import statement -
createTypeHandle
Creates an IType from the given simple top level type name. -
encloses
-
getBinaryInfo
protected IBinaryType getBinaryInfo(ClassFile classFile, org.eclipse.core.resources.IResource resource) throws org.eclipse.core.runtime.CoreException- Throws:
org.eclipse.core.runtime.CoreException
-
getFocusType
-
getMethodBodies
-
getType
-
getMethodBinding
-
hasAlreadyDefinedType
-
initialize
Create a new parser for the given project, as well as a lookup environment.- Throws:
JavaModelException
-
locateMatches
protected void locateMatches(JavaProject javaProject, PossibleMatch[] possibleMatches, int start, int length) throws org.eclipse.core.runtime.CoreException- Throws:
org.eclipse.core.runtime.CoreException
-
locateMatches
protected void locateMatches(JavaProject javaProject, PossibleMatchSet matchSet, int expected) throws org.eclipse.core.runtime.CoreExceptionLocate the matches amongst the possible matches.- Throws:
org.eclipse.core.runtime.CoreException
-
locateMatches
public void locateMatches(SearchDocument[] searchDocuments) throws org.eclipse.core.runtime.CoreExceptionLocate the matches in the given files and report them using the search requestor.- Throws:
org.eclipse.core.runtime.CoreException
-
locatePackageDeclarations
protected void locatePackageDeclarations(SearchParticipant participant, IJavaProject[] projects) throws org.eclipse.core.runtime.CoreExceptionLocates the package declarations corresponding to this locator's pattern.- Throws:
org.eclipse.core.runtime.CoreException
-
locatePackageDeclarations
protected void locatePackageDeclarations(SearchPattern searchPattern, SearchParticipant participant, IJavaProject[] projects) throws org.eclipse.core.runtime.CoreExceptionLocates the package declarations corresponding to the search pattern.- Throws:
org.eclipse.core.runtime.CoreException
-
lookupType
-
newDeclarationMatch
public SearchMatch newDeclarationMatch(IJavaElement element, Binding binding, int accuracy, int offset, int length) -
newDeclarationMatch
public SearchMatch newDeclarationMatch(IJavaElement element, Binding binding, int accuracy, int offset, int length, SearchParticipant participant, org.eclipse.core.resources.IResource resource) -
newFieldReferenceMatch
public FieldReferenceMatch newFieldReferenceMatch(IJavaElement enclosingElement, IJavaElement localElement, Binding enclosingBinding, int accuracy, int offset, int length, ASTNode reference) -
newLocalVariableReferenceMatch
public SearchMatch newLocalVariableReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, ASTNode reference) -
newMethodReferenceMatch
public MethodReferenceMatch newMethodReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, int offset, int length, boolean isConstructor, boolean isSynthetic, ASTNode reference) -
newPackageReferenceMatch
public PackageReferenceMatch newPackageReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, ASTNode reference) -
newTypeParameterReferenceMatch
public SearchMatch newTypeParameterReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, ASTNode reference) -
newTypeReferenceMatch
public TypeReferenceMatch newTypeReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, int offset, int length, ASTNode reference) -
newTypeReferenceMatch
public TypeReferenceMatch newTypeReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, ASTNode reference) -
newModuleReferenceMatch
public ModuleReferenceMatch newModuleReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, int offset, int length, ASTNode reference) -
newModuleReferenceMatch
public ModuleReferenceMatch newModuleReferenceMatch(IJavaElement enclosingElement, Binding enclosingBinding, int accuracy, ASTNode reference) -
parseAndBuildBindings
protected boolean parseAndBuildBindings(PossibleMatch possibleMatch, boolean mustResolve) throws org.eclipse.core.runtime.CoreExceptionAdd the possibleMatch to the loop -> build compilation unit declarations, their bindings and record their results.- Throws:
org.eclipse.core.runtime.CoreException
-
process
protected void process(PossibleMatch possibleMatch, boolean bindingsWereCreated) throws org.eclipse.core.runtime.CoreException- Throws:
org.eclipse.core.runtime.CoreException
-
purgeMethodStatements
-
reduceParseTree
Called prior to the unit being resolved. Reduce the parse tree where possible. -
getParticipant
-
report
- Throws:
org.eclipse.core.runtime.CoreException
-
reportAccurateTypeReference
protected void reportAccurateTypeReference(SearchMatch match, ASTNode typeRef, char[] name) throws org.eclipse.core.runtime.CoreExceptionFinds the accurate positions of the sequence of tokens given by qualifiedName in the source and reports a reference to this this qualified name to the search requestor.- Throws:
org.eclipse.core.runtime.CoreException
-
reportAccurateParameterizedMethodReference
protected void reportAccurateParameterizedMethodReference(SearchMatch match, ASTNode statement, TypeReference[] typeArguments) throws org.eclipse.core.runtime.CoreExceptionFinds the accurate positions of the sequence of tokens given by qualifiedName in the source and reports a reference to this parameterized type name to the search requestor.- Throws:
org.eclipse.core.runtime.CoreException
- Since:
- 3.1
-
reportAccurateParameterizedTypeReference
protected void reportAccurateParameterizedTypeReference(SearchMatch match, TypeReference typeRef, int index, TypeReference[] typeArguments) throws org.eclipse.core.runtime.CoreExceptionFinds the accurate positions of the sequence of tokens given by qualifiedName in the source and reports a reference to this parameterized type name to the search requestor.- Throws:
org.eclipse.core.runtime.CoreException
- Since:
- 3.1
-
reportAccurateEnumConstructorReference
protected void reportAccurateEnumConstructorReference(SearchMatch match, FieldDeclaration field, AllocationExpression allocation) throws org.eclipse.core.runtime.CoreExceptionFinds the accurate positions of each valid token in the source and reports a reference to this token to the search requestor. A token is valid if it has an accuracy which is not -1.- Throws:
org.eclipse.core.runtime.CoreException
-
reportAccurateFieldReference
protected void reportAccurateFieldReference(SearchMatch[] matches, QualifiedNameReference qNameRef) throws org.eclipse.core.runtime.CoreExceptionFinds the accurate positions of each valid token in the source and reports a reference to this token to the search requestor. A token is valid if it has an accuracy which is not -1.- Throws:
org.eclipse.core.runtime.CoreException
-
reportBinaryMemberDeclaration
protected void reportBinaryMemberDeclaration(org.eclipse.core.resources.IResource resource, IMember binaryMember, Binding binaryMemberBinding, IBinaryType info, int accuracy) throws org.eclipse.core.runtime.CoreException- Throws:
org.eclipse.core.runtime.CoreException
-
reportMatching
protected void reportMatching(LambdaExpression lambdaExpression, IJavaElement parent, int accuracy, MatchingNodeSet nodeSet, boolean typeInHierarchy) throws org.eclipse.core.runtime.CoreException- Throws:
org.eclipse.core.runtime.CoreException
-
reportMatching
protected void reportMatching(AbstractMethodDeclaration method, TypeDeclaration type, IJavaElement parent, int accuracy, boolean typeInHierarchy, MatchingNodeSet nodeSet) throws org.eclipse.core.runtime.CoreExceptionVisit the given method declaration and report the nodes that match exactly the search pattern (i.e. the ones in the matching nodes set) Note that the method declaration has already been checked.- Throws:
org.eclipse.core.runtime.CoreException
-
reportMatching
protected void reportMatching(Annotation[] annotations, IJavaElement enclosingElement, IJavaElement[] otherElements, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedContainer, boolean enclosesElement) throws org.eclipse.core.runtime.CoreExceptionReport matching in annotations.- Parameters:
otherElements
- TODO- Throws:
org.eclipse.core.runtime.CoreException
-
reportMatching
protected void reportMatching(CompilationUnitDeclaration unit, boolean mustResolve) throws org.eclipse.core.runtime.CoreExceptionVisit the given resolved parse tree and report the nodes that match the search pattern.- Throws:
org.eclipse.core.runtime.CoreException
-
reportMatching
protected void reportMatching(FieldDeclaration field, FieldDeclaration[] otherFields, TypeDeclaration type, IJavaElement parent, int accuracy, boolean typeInHierarchy, MatchingNodeSet nodeSet) throws org.eclipse.core.runtime.CoreExceptionVisit the given field declaration and report the nodes that match exactly the search pattern (i.e. the ones in the matching nodes set)- Throws:
org.eclipse.core.runtime.CoreException
-
reportMatching
protected void reportMatching(ModuleDeclaration module, IJavaElement parent, int accuracy, MatchingNodeSet nodeSet, int occurrenceCount) throws org.eclipse.core.runtime.CoreExceptionVisit the given module declaration and report the nodes that match exactly the search pattern (i.e. the ones in the matching nodes set)- Throws:
org.eclipse.core.runtime.CoreException
-
reportMatching
protected void reportMatching(TypeDeclaration type, IJavaElement parent, int accuracy, MatchingNodeSet nodeSet, int occurrenceCount) throws org.eclipse.core.runtime.CoreExceptionVisit the given type declaration and report the nodes that match exactly the search pattern (i.e. the ones in the matching nodes set)- Throws:
org.eclipse.core.runtime.CoreException
-
reportMatching
protected void reportMatching(TypeParameter[] typeParameters, IJavaElement enclosingElement, IJavaElement parent, Binding binding, MatchingNodeSet nodeSet) throws org.eclipse.core.runtime.CoreExceptionReport matches in type parameters.- Throws:
org.eclipse.core.runtime.CoreException
-
reportMatchingSuperOrPermit
protected void reportMatchingSuperOrPermit(TypeReference superReference, IJavaElement enclosingElement, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedClassContainer) throws org.eclipse.core.runtime.CoreException- Throws:
org.eclipse.core.runtime.CoreException
-
typeInHierarchy
-