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 TypeMethodDescriptionvoid
Add aCriterion
to thisCriteria
.static final Criterion
static final Criterion
static final Criterion
atExtImplsLocation
(String className, TypeIndexLocation loc) static final Criterion
static final Criterion
atLocation
(org.objectweb.asm.TypePath loc) Creates a GenericArrayLocationCriterion for a location.static final Criterion
cast
(String methodName, RelativeLocation loc) static final Criterion
classBound
(String className, BoundLocation boundLoc) static final Criterion
enclosedBy
(Tree.Kind kind) Creates an "enclosed by" criterion: that a program element is enclosed by the specified kind of program element.static final Criterion
Deprecated.static final Criterion
Gives 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 Criterion
inClass
(@ClassGetName String name, boolean exactMatch) Creates an "in class" criterion: that a program element is enclosed by the specified class.static final Criterion
inFieldInit
(String varName) static final Criterion
inInstanceInit
(int blockID) static final Criterion
Creates an "in method" criterion: that a program element is enclosed by the specified method.static final Criterion
Creates an "in package" criterion: that a program element is enclosed by the specified package.static final Criterion
instanceOf
(String methodName, RelativeLocation loc) static final Criterion
inStaticInit
(int blockID) static final Criterion
Creates an "is" criterion: that a program element has the specified kind and name.boolean
Returns true if this Criteria is on a field declaration.boolean
Returns true if this is the criteria on the RHS of an occurrence of 'instanceof'.boolean
Returns true if this is the criteria on a local variable.boolean
Returns true if this Criteria only permits type annotations, not declaration annotations.boolean
isOnMethod
(String methodname) Returns true if this Criteria is on the given method.boolean
isOnNew()
Returns true if this is the criteria on an object initializer.boolean
Returns true if this is the criteria on a package.boolean
Returns true if this is the criteria on a receiver.boolean
Returns true if this is the criteria on a return type.boolean
Returns true if this is the criteria on a classextends
bound.boolean
Returns true if this is the criteria on a variable declaration: a local variable or a field declaration, but not a formal parameter declaration.boolean
isSatisfiedBy
(@Nullable TreePath path) Returns true if the program element at the leaf of the specified path is satisfied by these criteria.boolean
isSatisfiedBy
(@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 Criterion
isSigMethod
(String methodName) Creates an IsSigMethodCriterion.static final Criterion
lambda
(String methodName, RelativeLocation loc) static final Criterion
local
(String methodName, LocalLocation loc) static Criterion
memberReference
(String methodName, RelativeLocation loc) static final Criterion
methodBound
(String methodName, BoundLocation boundLoc) static Criterion
methodCall
(String methodName, RelativeLocation loc) static final Criterion
newObject
(String methodName, RelativeLocation loc) static final Criterion
Creates a "not in method" criterion: that a program element is not enclosed by any method.boolean
Returns true if this is on the zeroth bound of a type.static final Criterion
packageDecl
(String packageName) static final Criterion
static final Criterion
static final Criterion
returnType
(@ClassGetName String className, String methodName) Returns a ReturnTypeCriterion.toString()
static final Criterion
typeArgument
(String methodName, RelativeLocation loc)
-
Field Details
-
dbug
Debugging logger.
-
-
Constructor Details
-
Criteria
public Criteria()Creates a newCriteria
without anyCriterion
.
-
-
Method Details
-
add
Add aCriterion
to 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 classextends
bound. -
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
-