|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object checkers.util.TreeUtils
@DefaultQualifier(value="checkers.nullness.quals.NonNull") public final class TreeUtils
A utility class made for helping to analyze a given Tree
.
Method Summary | ||
---|---|---|
static boolean |
containsThisConstructorInvocation(MethodTree node)
|
|
static TypeElement |
elementFromDeclaration(ClassTree node)
Gets the element for a class corresponding to a declaration. |
|
static ExecutableElement |
elementFromDeclaration(MethodTree node)
Gets the element for a method corresponding to a declaration. |
|
static VariableElement |
elementFromDeclaration(VariableTree node)
Gets the element for a variable corresponding to its declaration. |
|
static Element |
elementFromUse(ExpressionTree node)
|
|
static Element |
elementFromUse(IdentifierTree node)
Gets the element for the declaration corresponding to this identifier. |
|
static Element |
elementFromUse(MemberSelectTree node)
Gets the element for the declaration corresponding to this member access. |
|
static ExecutableElement |
elementFromUse(MethodInvocationTree node)
Gets the element for the method corresponding to this invocation. |
|
static ClassTree |
enclosingClass(TreePath path)
Gets the enclosing method of the tree node defined by the given {@link TreePath} . |
|
static MethodTree |
enclosingMethod(TreePath path)
Gets the enclosing method of the tree node defined by the given {@link TreePath} . |
|
static
|
enclosingOfClass(TreePath path,
Class<T> treeClass)
Gets the first enclosing tree in path, of the specified class |
|
static Tree |
enclosingOfKind(TreePath path,
Tree.Kind kind)
Gets the first enclosing tree in path, of the specified kind. |
|
static VariableTree |
enclosingVariable(TreePath path)
Gets the enclosing variable of a tree node defined by the given TreePath . |
|
static Tree |
getAssignmentContext(TreePath treePath)
Returns the tree with the assignment context for the treePath leaf node. |
|
static boolean |
isConstructor(MethodTree tree)
Checks if the provided method is a constructor method or no. |
|
static boolean |
isSelfAccess(ExpressionTree tree)
Returns true if the tree is a tree that 'looks like' either an access of a field or an invokation of a method that are owned by the same accessing instance. |
|
static boolean |
isSuperCall(MethodInvocationTree tree)
Checks if the method invocation is a call to super |
|
static Name |
methodName(MethodInvocationTree node)
|
|
static ExpressionTree |
skipParens(ExpressionTree tree)
If the given tree is a parenthesized tree, it returns the enclosed non-parenthesized tree. |
|
static Tree |
skipParens(Tree tree)
If the given tree is a parenthesized tree, it returns the enclosed non-parenthesized tree. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean isConstructor(MethodTree tree)
tree
- a tree defining the method
public static boolean isSelfAccess(ExpressionTree tree)
field this.field method() this.method()It does not perform any semantical check to differentiate between fields and local variables; local methods or imported static methods.
tree
- expression tree representing an access to object member
true
iff the member is a member of this
instancepublic static boolean isSuperCall(MethodInvocationTree tree)
tree
- a tree defining a method invocation
public static Tree enclosingOfKind(TreePath path, Tree.Kind kind)
path
- the path defining the tree nodekind
- the kind of the desired tree
public static <T extends Tree> T enclosingOfClass(TreePath path, Class<T> treeClass)
path
- the path defining the tree nodetreeClass
- the class of the desired tree
public static ClassTree enclosingClass(TreePath path)
{@link TreePath}
. It returns a Tree
, from which
AnnotatedTypeMirror
or Element
can be
obtained.
path
- the path defining the tree node
public static VariableTree enclosingVariable(TreePath path)
TreePath
.
path
- the path defining the tree node
public static MethodTree enclosingMethod(TreePath path)
{@link TreePath}
. It returns a Tree
, from which an
AnnotatedTypeMirror
or Element
can be
obtained.
path
- the path defining the tree node
public static Tree skipParens(Tree tree)
tree
- a tree
public static ExpressionTree skipParens(ExpressionTree tree)
tree
- an expression tree
public static Tree getAssignmentContext(TreePath treePath)
treePath
-
public static final TypeElement elementFromDeclaration(ClassTree node)
node
-
public static final ExecutableElement elementFromDeclaration(MethodTree node)
node
-
public static final VariableElement elementFromDeclaration(VariableTree node)
node
-
public static final ExecutableElement elementFromUse(MethodInvocationTree node)
Trees.getElement(TreePath)
instead.
node
- the method invocation
public static final Element elementFromUse(IdentifierTree node)
Trees.getElement(TreePath)
instead.
node
- the identifier
public static final Element elementFromUse(ExpressionTree node)
public static final Element elementFromUse(MemberSelectTree node)
Trees.getElement(TreePath)
instead.
node
- the member access
public static final Name methodName(MethodInvocationTree node)
public static final boolean containsThisConstructorInvocation(MethodTree node)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |