Class TreePathUtil

java.lang.Object
org.checkerframework.afu.annotator.scanner.TreePathUtil

public class TreePathUtil extends Object
Utility methods relating to TreePaths.
  • Method Details

    • hasClassKind

      public static boolean hasClassKind(Tree tree)
    • findCountingContext

      public static TreePath findCountingContext(TreePath path)
      Returns the counting context for new, typecast, instanceof, and locals.
      Parameters:
      path - a path to a method or a field/instance/static initializer
      Returns:
      the counting context for new, typecast, instanceof, and locals
    • findEnclosingClass

      public static TreePath findEnclosingClass(TreePath path)
      Returns the enclosing class.
      Parameters:
      path - a tree path
      Returns:
      the enclosing class
    • findEnclosingMethod

      public static TreePath findEnclosingMethod(TreePath path)
      Returns the enclosing method.
      Parameters:
      path - a tree path
      Returns:
      the enclosing method
    • isFieldInit

      public static boolean isFieldInit(TreePath path)
      Returns true if this is a field initialization.
      Parameters:
      path - a tree path
      Returns:
      true if this is a field initialization
    • findEnclosingFieldInit

      public static TreePath findEnclosingFieldInit(TreePath path)
    • isInitBlock

      public static boolean isInitBlock(TreePath path, boolean isStatic)
    • isInitBlock

      public static boolean isInitBlock(TreePath path)
    • findEnclosingInitBlock

      public static TreePath findEnclosingInitBlock(TreePath path, boolean isStatic)
    • isStaticInit

      public static boolean isStaticInit(TreePath path)
    • findEnclosingStaticInit

      public static TreePath findEnclosingStaticInit(TreePath path)
    • isInstanceInit

      public static boolean isInstanceInit(TreePath path)
    • findEnclosingInstanceInit

      public static TreePath findEnclosingInstanceInit(TreePath path)
    • hasConstructor

      public static boolean hasConstructor(ClassTree ct)
      Returns true if the given class contains some constructor.
      Parameters:
      ct - a class
      Returns:
      true if the given class contains some constructor
    • getBinaryName

      public static String getBinaryName(TreePath path)
      Given a TreePath, returns the binary name of the class it references. Does not give the right name for anonymous classes, including those defined within methods.
      Parameters:
      path - a path to a class definition
      Returns:
      the binary name of the class