|
|||||||||
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 extends Object
A utility class made for helping to analyze a given Tree
.
Modifier and Type | Method and Description | |
---|---|---|
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 methodpublic 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 membertrue
iff the member is a member of this
instancepublic static boolean isSuperCall(MethodInvocationTree tree)
tree
- a tree defining a method invocationpublic static Tree enclosingOfKind(TreePath path, Tree.Kind kind)
path
- the path defining the tree nodekind
- the kind of the desired treepublic static <T extends Tree> T enclosingOfClass(TreePath path, Class<T> treeClass)
path
- the path defining the tree nodetreeClass
- the class of the desired tree@Nullable public static ClassTree enclosingClass(@Nullable TreePath path)
{@link TreePath}
. It returns a Tree
, from which
AnnotatedTypeMirror
or Element
can be
obtained.
path
- the path defining the tree nodepublic static VariableTree enclosingVariable(TreePath path)
TreePath
.
path
- the path defining the tree node@Nullable public static MethodTree enclosingMethod(@Nullable TreePath path)
{@link TreePath}
. It returns a Tree
, from which an
AnnotatedTypeMirror
or Element
can be
obtained.
path
- the path defining the tree nodepublic static Tree skipParens(Tree tree)
tree
- a treepublic static ExpressionTree skipParens(ExpressionTree tree)
tree
- an expression treepublic 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 invocationpublic static final Element elementFromUse(IdentifierTree node)
Trees.getElement(TreePath)
instead.
node
- the identifierpublic static final Element elementFromUse(ExpressionTree node)
public static final Element elementFromUse(MemberSelectTree node)
Trees.getElement(TreePath)
instead.
node
- the member accesspublic 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 |