Class PatternLocator
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.search.matching.PatternLocator
- All Implemented Interfaces:
IQualifiedTypeResolutionListener,IIndexConstants
- Direct Known Subclasses:
AndLocator,ConstructorLocator,MethodLocator,ModuleLocator,OrLocator,PackageDeclarationLocator,PackageReferenceLocator,SuperTypeReferenceLocator,TypeDeclarationLocator,TypeParameterLocator,TypeReferenceLocator,VariableLocator
public abstract class PatternLocator
extends Object
implements IIndexConstants, IQualifiedTypeResolutionListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected booleanprotected booleanprotected booleanstatic final intprotected intprotected booleanstatic final intprotected booleanstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intFields inherited from interface org.aspectj.org.eclipse.jdt.internal.core.search.indexing.IIndexConstants
AND_PATTERN, ANNOT_REF_PATTERN, ANNOTATION_REF, ANNOTATION_TYPE_SUFFIX, CLASS_AND_ENUM_SUFFIX, CLASS_AND_INTERFACE_SUFFIX, CLASS_SUFFIX, CONSTRUCTOR_DECL, CONSTRUCTOR_PATTERN, CONSTRUCTOR_REF, COUNTS, DEFAULT_CONSTRUCTOR, ENUM_SUFFIX, FIELD_DECL, FIELD_PATTERN, INTERFACE_AND_ANNOTATION_SUFFIX, INTERFACE_SUFFIX, LOCAL_VAR_PATTERN, META_INDEX_CATEGORIES, META_INDEX_QUALIFIED_SUPER_TYPE_QUALIFIER_REF, META_INDEX_QUALIFIED_TYPE_QUALIFIER_REF, META_INDEX_SIMPLE_SUPER_TYPE_QUALIFIER_REF, META_INDEX_SIMPLE_TYPE_QUALIFIER_REF, METHOD_DECL, METHOD_DECL_PLUS, METHOD_PATTERN, METHOD_REF, MODULE_DECL, MODULE_INFO, MODULE_PATTERN, MODULE_REF, OBJECT, ONE_STAR, ONE_STAR_CHAR, ONE_ZERO, ONE_ZERO_CHAR, OR_PATTERN, PARAMETER_SEPARATOR, PKG_DECL_PATTERN, PKG_REF_PATTERN, REF, SECONDARY_SUFFIX, SEPARATOR, SUPER_REF, SUPER_REF_PATTERN, TYPE_DECL, TYPE_DECL_PATTERN, TYPE_PARAM_PATTERN, TYPE_REF_PATTERN, TYPE_SUFFIX, ZERO_CHAR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclear()protected intprotected char[]getQualifiedPattern(char[] simpleNamePattern, char[] qualificationPattern) protected char[]getQualifiedSourceName(TypeBinding binding) protected TypeBindinggetTypeNameBinding(int index) voidinitializePolymorphicSearch(MatchLocator locator) Initializes this search pattern so that polymorphic search can be performed.intmatch(Annotation node, MatchingNodeSet nodeSet) intmatch(ASTNode node, MatchingNodeSet nodeSet) Check if the given ast node syntactically matches this pattern.intmatch(ConstructorDeclaration node, MatchingNodeSet nodeSet) intmatch(Expression node, MatchingNodeSet nodeSet) intmatch(FieldDeclaration node, MatchingNodeSet nodeSet) intmatch(LambdaExpression node, MatchingNodeSet nodeSet) intmatch(LocalDeclaration node, MatchingNodeSet nodeSet) intmatch(MemberValuePair node, MatchingNodeSet nodeSet) intmatch(MessageSend node, MatchingNodeSet nodeSet) intmatch(MethodDeclaration node, MatchingNodeSet nodeSet) protected intmatch(ModuleDeclaration node, MatchingNodeSet nodeSet) protected intmatch(ModuleReference node, MatchingNodeSet nodeSet) intmatch(ReferenceExpression node, MatchingNodeSet nodeSet) intmatch(Reference node, MatchingNodeSet nodeSet) intmatch(TypeDeclaration node, MatchingNodeSet nodeSet) intmatch(TypeParameter node, MatchingNodeSet nodeSet) intmatch(TypeReference node, MatchingNodeSet nodeSet) protected intReturns the type(s) of container for this pattern.protected booleanmatchesName(char[] pattern, char[] name) Returns whether the given name matches the given pattern.protected booleanmatchesTypeReference(char[] pattern, TypeReference type) Returns whether the given type reference matches the given pattern.protected intmatchLevel(ImportReference importRef) Returns the match level for the given importRef.protected voidmatchLevelAndReportImportRef(ImportReference importRef, Binding binding, MatchLocator locator) Reports the match of the given import reference if the resolveLevel is high enough.protected intmatchNameValue(char[] pattern, char[] name) Return how the given name matches the given pattern.protected voidmatchReportImportRef(ImportReference importRef, Binding binding, IJavaElement element, int accuracy, MatchLocator locator) Reports the match of the given import reference.protected voidmatchReportReference(ASTNode reference, IJavaElement element, IJavaElement localElement, IJavaElement[] otherElements, Binding elementBinding, int accuracy, MatchLocator locator) Reports the match of the given reference.protected voidmatchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) Reports the match of the given reference.newDeclarationMatch(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, int length, MatchLocator locator) static PatternLocatorpatternLocator(SearchPattern pattern) static char[]qualifiedPattern(char[] simpleNamePattern, char[] qualificationPattern) static char[]qualifiedSourceName(TypeBinding binding) voidrecordResolution(QualifiedTypeReference typeReference, TypeBinding resolution) Notifies that the given resolution has been found for the given type reference.protected intintresolveLevel(ASTNode possibleMatchingNode) Finds out whether the given ast node matches this search pattern.intresolveLevel(Binding binding) Finds out whether the given binding matches this search pattern.protected intresolveLevelForType(char[] simpleNamePattern, char[] qualificationPattern, char[][][] patternTypeArguments, int depth, TypeBinding type) protected intresolveLevelForType(char[] simpleNamePattern, char[] qualificationPattern, TypeBinding binding) Returns whether the given type binding matches the given simple name pattern and qualification pattern.protected intresolveLevelForType(char[] qualifiedPattern, TypeBinding type) Returns whether the given type binding matches the given qualified pattern.toString()protected voidupdateMatch(ParameterizedTypeBinding parameterizedBinding, char[][][] patternTypeArguments, boolean patternHasTypeParameters, int depth, MatchLocator locator) protected voidupdateMatch(ParameterizedTypeBinding parameterizedBinding, char[][][] patternTypeArguments, MatchLocator locator) protected voidupdateMatch(TypeBinding[] argumentsBinding, MatchLocator locator, char[][] patternArguments, boolean hasTypeParameters)
-
Field Details
-
matchMode
protected int matchMode -
isCaseSensitive
protected boolean isCaseSensitive -
isEquivalentMatch
protected boolean isEquivalentMatch -
isErasureMatch
protected boolean isErasureMatch -
mustResolve
protected boolean mustResolve -
mayBeGeneric
protected boolean mayBeGeneric -
IMPOSSIBLE_MATCH
public static final int IMPOSSIBLE_MATCH- See Also:
-
INACCURATE_MATCH
public static final int INACCURATE_MATCH- See Also:
-
POSSIBLE_MATCH
public static final int POSSIBLE_MATCH- See Also:
-
ACCURATE_MATCH
public static final int ACCURATE_MATCH- See Also:
-
ERASURE_MATCH
public static final int ERASURE_MATCH- See Also:
-
NO_FLAVOR
public static final int NO_FLAVOR- See Also:
-
EXACT_FLAVOR
public static final int EXACT_FLAVOR- See Also:
-
PREFIX_FLAVOR
public static final int PREFIX_FLAVOR- See Also:
-
PATTERN_FLAVOR
public static final int PATTERN_FLAVOR- See Also:
-
REGEXP_FLAVOR
public static final int REGEXP_FLAVOR- See Also:
-
CAMELCASE_FLAVOR
public static final int CAMELCASE_FLAVOR- See Also:
-
SUPER_INVOCATION_FLAVOR
public static final int SUPER_INVOCATION_FLAVOR- See Also:
-
SUB_INVOCATION_FLAVOR
public static final int SUB_INVOCATION_FLAVOR- See Also:
-
OVERRIDDEN_METHOD_FLAVOR
public static final int OVERRIDDEN_METHOD_FLAVOR- See Also:
-
SUPERTYPE_REF_FLAVOR
public static final int SUPERTYPE_REF_FLAVOR- See Also:
-
MATCH_LEVEL_MASK
public static final int MATCH_LEVEL_MASK- See Also:
-
FLAVORS_MASK
public static final int FLAVORS_MASK- See Also:
-
COMPILATION_UNIT_CONTAINER
public static final int COMPILATION_UNIT_CONTAINER- See Also:
-
CLASS_CONTAINER
public static final int CLASS_CONTAINER- See Also:
-
METHOD_CONTAINER
public static final int METHOD_CONTAINER- See Also:
-
FIELD_CONTAINER
public static final int FIELD_CONTAINER- See Also:
-
ALL_CONTAINER
public static final int ALL_CONTAINER- See Also:
-
RAW_MASK
public static final int RAW_MASK- See Also:
-
RULE_MASK
public static final int RULE_MASK- See Also:
-
-
Constructor Details
-
PatternLocator
-
-
Method Details
-
patternLocator
-
qualifiedPattern
public static char[] qualifiedPattern(char[] simpleNamePattern, char[] qualificationPattern) -
qualifiedSourceName
-
clear
protected void clear() -
getQualifiedPattern
protected char[] getQualifiedPattern(char[] simpleNamePattern, char[] qualificationPattern) -
getQualifiedSourceName
-
getTypeNameBinding
-
initializePolymorphicSearch
Initializes this search pattern so that polymorphic search can be performed. -
match
-
match
Check if the given ast node syntactically matches this pattern. If it does, add it to the match set. Returns the match level. -
match
-
match
-
match
-
match
-
match
-
match
-
match
-
match
-
match
-
match
-
match
-
match
-
match
-
match
-
match
-
matchContainer
protected int matchContainer()Returns the type(s) of container for this pattern. It is a bit combination of types, denoting compilation unit, class declarations, field declarations or method declarations. -
fineGrain
protected int fineGrain() -
matchesName
protected boolean matchesName(char[] pattern, char[] name) Returns whether the given name matches the given pattern. -
matchNameValue
protected int matchNameValue(char[] pattern, char[] name) Return how the given name matches the given pattern.- Returns:
- Possible values are:
-
ACCURATE_MATCH -
IMPOSSIBLE_MATCH -
POSSIBLE_MATCHwhich may be flavored with following values:EXACT_FLAVOR: Given name is equals to patternPREFIX_FLAVOR: Given name prefix equals to patternCAMELCASE_FLAVOR: Given name matches pattern as Camel CasePATTERN_FLAVOR: Given name matches pattern as Pattern (i.e. using '*' and '?' characters)
-
- See Also:
-
matchesTypeReference
Returns whether the given type reference matches the given pattern. -
matchLevel
Returns the match level for the given importRef. -
matchLevelAndReportImportRef
protected void matchLevelAndReportImportRef(ImportReference importRef, Binding binding, MatchLocator locator) throws org.eclipse.core.runtime.CoreException Reports the match of the given import reference if the resolveLevel is high enough.- Throws:
org.eclipse.core.runtime.CoreException
-
matchReportImportRef
protected void matchReportImportRef(ImportReference importRef, Binding binding, IJavaElement element, int accuracy, MatchLocator locator) throws org.eclipse.core.runtime.CoreException Reports the match of the given import reference.- Throws:
org.eclipse.core.runtime.CoreException
-
matchReportReference
protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws org.eclipse.core.runtime.CoreException Reports the match of the given reference.- Throws:
org.eclipse.core.runtime.CoreException
-
matchReportReference
protected void matchReportReference(ASTNode reference, IJavaElement element, IJavaElement localElement, IJavaElement[] otherElements, Binding elementBinding, int accuracy, MatchLocator locator) throws org.eclipse.core.runtime.CoreException Reports the match of the given reference. Also provide a local element to eventually report in match.- Throws:
org.eclipse.core.runtime.CoreException
-
newDeclarationMatch
public SearchMatch newDeclarationMatch(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, int length, MatchLocator locator) -
referenceType
protected int referenceType() -
resolveLevel
Finds out whether the given ast node matches this search pattern. Returns IMPOSSIBLE_MATCH if it doesn't. Returns INACCURATE_MATCH if it potentially matches this search pattern (i.e. it has already been resolved but resolving failed.) Returns ACCURATE_MATCH if it matches exactly this search pattern (i.e. it doesn't need to be resolved or it has already been resolved.) -
updateMatch
protected void updateMatch(ParameterizedTypeBinding parameterizedBinding, char[][][] patternTypeArguments, MatchLocator locator) -
updateMatch
protected void updateMatch(ParameterizedTypeBinding parameterizedBinding, char[][][] patternTypeArguments, boolean patternHasTypeParameters, int depth, MatchLocator locator) -
updateMatch
protected void updateMatch(TypeBinding[] argumentsBinding, MatchLocator locator, char[][] patternArguments, boolean hasTypeParameters) -
resolveLevel
Finds out whether the given binding matches this search pattern. Returns ACCURATE_MATCH if it does. Returns INACCURATE_MATCH if resolve failed but match is still possible. Returns IMPOSSIBLE_MATCH otherwise. Default is to return INACCURATE_MATCH. -
resolveLevelForType
protected int resolveLevelForType(char[] simpleNamePattern, char[] qualificationPattern, TypeBinding binding) Returns whether the given type binding matches the given simple name pattern and qualification pattern. Note that from since 3.1, this method resolve to accurate member or local types even if they are not fully qualified (i.e. X.Member instead of p.X.Member). Returns ACCURATE_MATCH if it does. Returns INACCURATE_MATCH if resolve failed. Returns IMPOSSIBLE_MATCH if it doesn't. -
resolveLevelForType
Returns whether the given type binding matches the given qualified pattern. Returns ACCURATE_MATCH if it does. Returns INACCURATE_MATCH if resolve failed. Returns IMPOSSIBLE_MATCH if it doesn't. -
resolveLevelForType
protected int resolveLevelForType(char[] simpleNamePattern, char[] qualificationPattern, char[][][] patternTypeArguments, int depth, TypeBinding type) -
toString
-
recordResolution
Description copied from interface:IQualifiedTypeResolutionListenerNotifies that the given resolution has been found for the given type reference. Some of the bindings are intermediate types i.e. qualifying types.- Specified by:
recordResolutionin interfaceIQualifiedTypeResolutionListener- Parameters:
typeReference- the type referenceresolution- the resolution found
-