Class Criteria

java.lang.Object
org.checkerframework.afu.annotator.find.Criteria

public final class Criteria extends Object
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 Details

    • dbug

      public static DebugWriter dbug
      Debugging logger.
  • Constructor Details

    • Criteria

      public Criteria()
      Creates a new Criteria without any Criterion.
  • Method Details

    • add

      public void add(Criterion c)
      Add a Criterion to this Criteria.
      Parameters:
      c - the criterion to add
    • isSatisfiedBy

      public boolean isSatisfiedBy(@Nullable TreePath path, @FindDistinct Tree leaf)
      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
      leaf - 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

      public boolean isSatisfiedBy(@Nullable TreePath path)
      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 class extends bound.
    • isOnMethod

      public boolean isOnMethod(String methodname)
      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

      public ASTPath getASTPath()
      Gives the AST path specified in the criteria, if any.
      Returns:
      AST path from ASTPathCriterion, or null if none present
    • getClassName

      public @Nullable @ClassGetName String getClassName()
      Returns the name of the class specified in the Criteria, if any.
      Returns:
      class name from InClassCriterion, or null if none present
    • getMethodName

      public String getMethodName()
      Returns the name of the method specified in the Criteria, if any.
      Returns:
      method name from InMethodCriterion, or null if none present
    • getFieldName

      public String 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

      public GenericArrayLocationCriterion getGenericArrayLocation()
      Returns a GenericArrayLocationCriterion if this has one, else null.
      Returns:
      a GenericArrayLocationCriterion if this has one, else null
    • getCastRelativeLocation

      public RelativeLocation getCastRelativeLocation()
      Returns a RelativeCriterion if this has one, else null.
      Returns:
      a RelativeCriterion if this has one, else null
    • getInClass

      public InClassCriterion 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

      public String toString()
      Overrides:
      toString in class Object
    • is

      public static final Criterion is(Tree.Kind kind, String name)
      Creates an "is" criterion: that a program element has the specified kind and name.
      Parameters:
      kind - the program element's kind
      name - the program element's name
      Returns:
      an "is" criterion
    • enclosedBy

      public 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.
      Parameters:
      kind - the kind of enclosing program element
      Returns:
      an "enclosed by" criterion
    • inPackage

      public static final Criterion inPackage(String name)
      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

      public static final Criterion inClass(@ClassGetName String name, boolean exactMatch)
      Creates an "in class" criterion: that a program element is enclosed by the specified class.
      Parameters:
      name - the name of the enclosing class
      exactMatch - if true, match only in the class itself, not in its inner classes
      Returns:
      an "in class" criterion
    • inMethod

      public static final Criterion inMethod(String name)
      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

      public static final 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

      public static final Criterion packageDecl(String packageName)
    • atLocation

      public static final Criterion atLocation()
    • atLocation

      public static final Criterion atLocation(org.objectweb.asm.TypePath loc)
      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

      public static final Criterion field(String varName, boolean isOnDeclaration)
    • inStaticInit

      public static final Criterion inStaticInit(int blockID)
    • inInstanceInit

      public static final Criterion inInstanceInit(int blockID)
    • inFieldInit

      public static final Criterion inFieldInit(String varName)
    • receiver

      public static final Criterion receiver(String methodName)
    • returnType

      public static final Criterion returnType(@ClassGetName String className, String methodName)
      Returns a ReturnTypeCriterion.
      Parameters:
      className - the class name
      methodName - the method name
      Returns:
      a new ReturnTypeCriterion
    • isSigMethod

      public static final Criterion isSigMethod(String methodName)
      Creates an IsSigMethodCriterion.
      Parameters:
      methodName - the method name
      Returns:
      a new IsSigMethodCriterion
    • param

      public static final Criterion param(String methodName, Integer pos)
    • local

      public static final Criterion local(String methodName, LocalLocation loc)
    • cast

      public static final Criterion cast(String methodName, RelativeLocation loc)
    • newObject

      public static final Criterion newObject(String methodName, RelativeLocation loc)
    • instanceOf

      public static final Criterion instanceOf(String methodName, RelativeLocation loc)
    • memberReference

      public static Criterion memberReference(String methodName, RelativeLocation loc)
    • methodCall

      public static Criterion methodCall(String methodName, RelativeLocation loc)
    • typeArgument

      public static final Criterion typeArgument(String methodName, RelativeLocation loc)
    • lambda

      public static final Criterion lambda(String methodName, RelativeLocation loc)
    • atBoundLocation

      public static final Criterion atBoundLocation(BoundLocation loc)
    • atExtImplsLocation

      public static final Criterion atExtImplsLocation(String className, TypeIndexLocation loc)
    • methodBound

      public static final Criterion methodBound(String methodName, BoundLocation boundLoc)
    • classBound

      public static final Criterion classBound(String className, BoundLocation boundLoc)
    • astPath

      public static final Criterion astPath(ASTPath astPath)