Class Criteria
java.lang.Object
org.checkerframework.afu.annotator.find.Criteria
Represents a set of Criterion objects for locating a program element in a source tree.
This class also contains static factory methods for creating a Criterion.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd aCriterionto thisCriteria.static final Criterionstatic final Criterionstatic final CriterionatExtImplsLocation(String className, TypeIndexLocation loc) static final Criterionstatic final CriterionatLocation(org.objectweb.asm.TypePath loc) Creates a GenericArrayLocationCriterion for a location.static final Criterioncast(String methodName, RelativeLocation loc) static final CriterionclassBound(String className, BoundLocation boundLoc) static final CriterionenclosedBy(Tree.Kind kind) Creates an "enclosed by" criterion: that a program element is enclosed by the specified kind of program element.static final CriterionDeprecated.static final CriterionGives the AST path specified in the criteria, if any.Returns a RelativeCriterion if this has one, else null.Returns the name of the class specified in the Criteria, if any.Returns the name of the member field specified in the Criteria, if any.Returns a GenericArrayLocationCriterion if this has one, else null.Returns an InClassCriterion if this has one, else null.Returns the name of the method specified in the Criteria, if any.static final CriterioninClass(@ClassGetName String name, boolean exactMatch) Creates an "in class" criterion: that a program element is enclosed by the specified class.static final CriterioninFieldInit(String varName) static final CriterioninInstanceInit(int blockID) static final CriterionCreates an "in method" criterion: that a program element is enclosed by the specified method.static final CriterionCreates an "in package" criterion: that a program element is enclosed by the specified package.static final CriterioninstanceOf(String methodName, RelativeLocation loc) static final CriterioninStaticInit(int blockID) static final CriterionCreates an "is" criterion: that a program element has the specified kind and name.booleanReturns true if this Criteria is on a field declaration.booleanReturns true if this is the criteria on the RHS of an occurrence of 'instanceof'.booleanReturns true if this is the criteria on a local variable.booleanReturns true if this Criteria only permits type annotations, not declaration annotations.booleanisOnMethod(String methodname) Returns true if this Criteria is on the given method.booleanisOnNew()Returns true if this is the criteria on an object initializer.booleanReturns true if this is the criteria on a package.booleanReturns true if this is the criteria on a receiver.booleanReturns true if this is the criteria on a return type.booleanReturns true if this is the criteria on a classextendsbound.booleanReturns true if this is the criteria on a variable declaration: a local variable or a field declaration, but not a formal parameter declaration.booleanisSatisfiedBy(@Nullable TreePath path) Returns true if the program element at the leaf of the specified path is satisfied by these criteria.booleanisSatisfiedBy(@Nullable TreePath path, Tree leaf) Returns true if the program element at the leaf of the specified path is satisfied by these criteria.static final CriterionisSigMethod(String methodName) Creates an IsSigMethodCriterion.static final Criterionlambda(String methodName, RelativeLocation loc) static final Criterionlocal(String methodName, LocalLocation loc) static CriterionmemberReference(String methodName, RelativeLocation loc) static final CriterionmethodBound(String methodName, BoundLocation boundLoc) static CriterionmethodCall(String methodName, RelativeLocation loc) static final CriterionnewObject(String methodName, RelativeLocation loc) static final CriterionCreates a "not in method" criterion: that a program element is not enclosed by any method.booleanReturns true if this is on the zeroth bound of a type.static final CriterionpackageDecl(String packageName) static final Criterionstatic final Criterionstatic final CriterionreturnType(@ClassGetName String className, String methodName) Returns a ReturnTypeCriterion.toString()static final CriteriontypeArgument(String methodName, RelativeLocation loc)
-
Field Details
-
dbug
Debugging logger.
-
-
Constructor Details
-
Criteria
public Criteria()Creates a newCriteriawithout anyCriterion.
-
-
Method Details
-
add
Add aCriterionto thisCriteria.- Parameters:
c- the criterion to add
-
isSatisfiedBy
Returns true if the program element at the leaf of the specified path is satisfied by these criteria.- Parameters:
path- the tree path to check againstleaf- the tree at the leaf of the path; only relevant when the path is null, in which case the leaf is a CompilationUnitTree- Returns:
- true if all of these criteria are satisfied by the given path, false otherwise
-
isSatisfiedBy
Returns true if the program element at the leaf of the specified path is satisfied by these criteria.- Parameters:
path- the tree path to check against- Returns:
- true if all of these criteria are satisfied by the given path, false otherwise
-
isOnlyTypeAnnotationCriterion
public boolean isOnlyTypeAnnotationCriterion()Returns true if this Criteria only permits type annotations, not declaration annotations.- Returns:
- true if this Criteria only permits type annotations, not declaration annotations
-
isOnReceiver
public boolean isOnReceiver()Returns true if this is the criteria on a receiver.- Returns:
- true iff this is the criteria on a receiver
-
isOnPackage
public boolean isOnPackage()Returns true if this is the criteria on a package.- Returns:
- true iff this is the criteria on a package
-
isOnReturnType
public boolean isOnReturnType()Returns true if this is the criteria on a return type.- Returns:
- true iff this is the criteria on a return type
-
isOnLocalVariable
public boolean isOnLocalVariable()Returns true if this is the criteria on a local variable.- Returns:
- true iff this is the criteria on a local variable
-
isOnInstanceof
public boolean isOnInstanceof()Returns true if this is the criteria on the RHS of an occurrence of 'instanceof'.- Returns:
- true if this is the criteria on the RHS of an occurrence of 'instanceof'
-
isOnNew
public boolean isOnNew()Returns true if this is the criteria on an object initializer.- Returns:
- true if this is the criteria on an object initializer
-
isOnTypeDeclarationExtendsClause
public boolean isOnTypeDeclarationExtendsClause()Returns true if this is the criteria on a classextendsbound. -
isOnMethod
Returns true if this Criteria is on the given method.- Parameters:
methodname- the name of a method- Returns:
- true if this Criteria is on the given method
-
isOnFieldDeclaration
public boolean isOnFieldDeclaration()Returns true if this Criteria is on a field declaration. -
isOnVariableDeclaration
public boolean isOnVariableDeclaration()Returns true if this is the criteria on a variable declaration: a local variable or a field declaration, but not a formal parameter declaration.- Returns:
- true iff this is the criteria on a local variable
-
getASTPath
Gives the AST path specified in the criteria, if any.- Returns:
- AST path from
ASTPathCriterion, or null if none present
-
getClassName
Returns the name of the class specified in the Criteria, if any.- Returns:
- class name from
InClassCriterion, or null if none present
-
getMethodName
Returns the name of the method specified in the Criteria, if any.- Returns:
- method name from
InMethodCriterion, or null if none present
-
getFieldName
Returns the name of the member field specified in the Criteria, if any.- Returns:
- field name from
FieldCriterion, or null if none present
-
getGenericArrayLocation
Returns a GenericArrayLocationCriterion if this has one, else null.- Returns:
- a GenericArrayLocationCriterion if this has one, else null
-
getCastRelativeLocation
Returns a RelativeCriterion if this has one, else null.- Returns:
- a RelativeCriterion if this has one, else null
-
getInClass
Returns an InClassCriterion if this has one, else null.- Returns:
- an InClassCriterion if this has one, else null
-
onBoundZero
public boolean onBoundZero()Returns true if this is on the zeroth bound of a type.- Returns:
- true if this is on the zeroth bound of a type
-
toString
-
is
Creates an "is" criterion: that a program element has the specified kind and name.- Parameters:
kind- the program element's kindname- the program element's name- Returns:
- an "is" criterion
-
enclosedBy
Creates an "enclosed by" criterion: that a program element is enclosed by the specified kind of program element.- Parameters:
kind- the kind of enclosing program element- Returns:
- an "enclosed by" criterion
-
inPackage
Creates an "in package" criterion: that a program element is enclosed by the specified package.- Parameters:
name- the name of the enclosing package- Returns:
- an "in package" criterion
-
inClass
Creates an "in class" criterion: that a program element is enclosed by the specified class.- Parameters:
name- the name of the enclosing classexactMatch- if true, match only in the class itself, not in its inner classes- Returns:
- an "in class" criterion
-
inMethod
Creates an "in method" criterion: that a program element is enclosed by the specified method.- Parameters:
name- the name of the enclosing method- Returns:
- an "in method" criterion
-
notInMethod
Creates a "not in method" criterion: that a program element is not enclosed by any method.- Returns:
- a "not in method" criterion
-
packageDecl
-
atLocation
-
atLocation
Creates a GenericArrayLocationCriterion for a location.- Parameters:
loc- location of the generic array- Returns:
- a GenericArrayLocationCriterion for the given location
-
field
@Deprecated @InlineMe(replacement="new FieldCriterion(varName)", imports="org.checkerframework.afu.annotator.find.FieldCriterion") public static final Criterion field(String varName) Deprecated.Creates a GenericArrayLocationCriterion for a field.- Parameters:
varName- location of the field- Returns:
- a GenericArrayLocationCriterion for the given field
-
field
-
inStaticInit
-
inInstanceInit
-
inFieldInit
-
receiver
-
returnType
Returns a ReturnTypeCriterion.- Parameters:
className- the class namemethodName- the method name- Returns:
- a new ReturnTypeCriterion
-
isSigMethod
Creates an IsSigMethodCriterion.- Parameters:
methodName- the method name- Returns:
- a new IsSigMethodCriterion
-
param
-
local
-
cast
-
newObject
-
instanceOf
-
memberReference
-
methodCall
-
typeArgument
-
lambda
-
atBoundLocation
-
atExtImplsLocation
-
methodBound
-
classBound
-
astPath
-