Class TreePathUtil
java.lang.Object
org.checkerframework.afu.annotator.scanner.TreePathUtil
Utility methods relating to TreePaths.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TreePath
findCountingContext
(TreePath path) Returns the counting context for new, typecast, instanceof, and locals.static TreePath
findEnclosingClass
(TreePath path) Returns the enclosing class.static TreePath
static TreePath
findEnclosingInitBlock
(TreePath path, boolean isStatic) static TreePath
static TreePath
findEnclosingMethod
(TreePath path) Returns the enclosing method.static TreePath
static String
getBinaryName
(TreePath path) Given a TreePath, returns the binary name of the class it references.static boolean
hasClassKind
(Tree tree) static boolean
Returns true if the given class contains some constructor.static boolean
isFieldInit
(TreePath path) Returns true if this is a field initialization.static boolean
isInitBlock
(TreePath path) static boolean
isInitBlock
(TreePath path, boolean isStatic) static boolean
isInstanceInit
(TreePath path) static boolean
isStaticInit
(TreePath path)
-
Method Details
-
hasClassKind
-
findCountingContext
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
Returns the enclosing class.- Parameters:
path
- a tree path- Returns:
- the enclosing class
-
findEnclosingMethod
Returns the enclosing method.- Parameters:
path
- a tree path- Returns:
- the enclosing method
-
isFieldInit
Returns true if this is a field initialization.- Parameters:
path
- a tree path- Returns:
- true if this is a field initialization
-
findEnclosingFieldInit
-
isInitBlock
-
isInitBlock
-
findEnclosingInitBlock
-
isStaticInit
-
findEnclosingStaticInit
-
isInstanceInit
-
findEnclosingInstanceInit
-
hasConstructor
Returns true if the given class contains some constructor.- Parameters:
ct
- a class- Returns:
- true if the given class contains some constructor
-
getBinaryName
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
-