Modifier and Type | Method and Description |
---|---|
static Set<Tree.Kind> |
classTreeKinds() |
static boolean |
containsThisConstructorInvocation(@Nullable MethodTree node) |
static TypeElement |
elementFromDeclaration(@Nullable ClassTree node)
Gets the element for a class corresponding to a declaration.
|
static @NonNull ExecutableElement |
elementFromDeclaration(@Nullable 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 @Nullable Element |
elementFromUse(ExpressionTree node)
Gets the element for the declaration corresponding to this use of an element.
|
static @NonNull ExecutableElement |
elementFromUse(MethodInvocationTree node) |
static @NonNull ExecutableElement |
elementFromUse(NewClassTree node) |
static @Nullable ClassTree |
enclosingClass(@Nullable TreePath path)
Gets the enclosing class of the tree node defined by the given
{@link TreePath} . |
static @Nullable MethodTree |
enclosingMethod(@Nullable TreePath path)
Gets the enclosing method of the tree node defined by the given
{@link TreePath} . |
static <T extends @Nullable Tree> |
enclosingOfClass(@Nullable TreePath path,
Class<T> treeClass)
Gets the first enclosing tree in path, of the specified class
|
static @Nullable Tree |
enclosingOfKind(@Nullable TreePath path,
Set<Tree.Kind> kinds)
Gets the first enclosing tree in path, with any one of the specified kinds.
|
static @Nullable Tree |
enclosingOfKind(@Nullable TreePath path,
Tree.Kind kind)
Gets the first enclosing tree in path, of the specified kind.
|
static @Nullable BlockTree |
enclosingTopLevelBlock(@Nullable TreePath path) |
static VariableTree |
enclosingVariable(@Nullable TreePath path)
Gets the enclosing variable of a tree node defined by the given
TreePath . |
static @Nullable Tree |
firstStatement(@Nullable Tree tree) |
static @Nullable Tree |
getAssignmentContext(@Nullable TreePath treePath)
Returns the tree with the assignment context for the treePath
leaf node.
|
static VariableElement |
getField(@ReadOnly String typeName,
@ReadOnly String fieldName,
ProcessingEnvironment env)
Returns the VariableElement for a field declaration.
|
static @NonNull ExecutableElement |
getMethod(@ReadOnly String typeName,
@ReadOnly String methodName,
int params,
ProcessingEnvironment env)
Returns the ExecutableElement for a method declaration of
methodName, in class typeName, with params parameters.
|
static ExpressionTree |
getReceiverTree(ExpressionTree expression)
Returns the receiver tree of a field access or a method invocation
|
static boolean |
hasExplicitConstructor(@Nullable ClassTree node)
Determine whether the given class contains an explicit constructor.
|
static boolean |
isClassTree(Tree.Kind kind) |
static boolean |
isCompileTimeString(ExpressionTree node)
Returns true if the node is a constant-time expression.
|
static boolean |
isConstructor(@Nullable MethodTree tree)
Checks if the provided method is a constructor method or no.
|
static boolean |
isDiamondTree(@Nullable Tree tree)
Returns true if the tree is of a diamond type
|
static boolean |
isEnumSuper(MethodInvocationTree node) |
static boolean |
isExpressionTree(@Nullable Tree tree)
Determine whether the given tree represents an ExpressionTree.
|
static boolean |
isFieldAccess(@Nullable Tree tree,
VariableElement var,
ProcessingEnvironment env)
Returns true if the given tree represents an access of the given VariableElement.
|
static boolean |
isMethodInvocation(@Nullable Tree tree,
@NonNull ExecutableElement method,
ProcessingEnvironment env)
Returns true if the given element is an invocation of the method, or
of any method that overrides that one.
|
static boolean |
isStringCompoundConcatenation(CompoundAssignmentTree tree)
Returns true if the compound assignment tree is a string concatenation
|
static boolean |
isStringConcatenation(@Nullable Tree tree)
Returns true if the tree represents a
String concatenation
operation |
static boolean |
isSuperCall(MethodInvocationTree tree)
Checks if the method invocation is a call to super.
|
static boolean |
isUseOfElement(ExpressionTree node)
Determine whether the given ExpressionTree has an underlying element.
|
static @Nullable Name |
methodName(MethodInvocationTree node) |
static @Nullable TreePath |
pathTillClass(@Nullable TreePath path)
Gets path to the the first enclosing class tree, where class is
defined by the classTreeKinds method.
|
static @Nullable TreePath |
pathTillOfKind(@Nullable TreePath path,
Set<Tree.Kind> kinds)
Gets path to the the first enclosing tree with any one of the specified kinds.
|
static @Nullable TreePath |
pathTillOfKind(@Nullable TreePath path,
Tree.Kind kind)
Gets path to the the first enclosing tree of the specified kind.
|
static ExpressionTree |
skipParens(ExpressionTree tree)
If the given tree is a parenthesized tree, it returns the enclosed
non-parenthesized tree.
|
public static boolean isConstructor(@Nullable MethodTree tree)
tree
- a tree defining the methodpublic static boolean isSuperCall(MethodInvocationTree tree)
tree
- a tree defining a method invocationpublic static @Nullable Tree enclosingOfKind(@Nullable TreePath path, Tree.Kind kind)
path
- the path defining the tree nodekind
- the kind of the desired treepublic static @Nullable Tree enclosingOfKind(@Nullable TreePath path, Set<Tree.Kind> kinds)
path
- the path defining the tree nodekinds
- the set of kinds of the desired treepublic static @Nullable TreePath pathTillClass(@Nullable TreePath path)
path
- the path defining the tree nodepublic static @Nullable TreePath pathTillOfKind(@Nullable TreePath path, Tree.Kind kind)
path
- the path defining the tree nodekind
- the kind of the desired treepublic static @Nullable TreePath pathTillOfKind(@Nullable TreePath path, Set<Tree.Kind> kinds)
path
- the path defining the tree nodekinds
- the set of kinds of the desired treepublic static <T extends @Nullable Tree> T enclosingOfClass(@Nullable TreePath path, Class<T> treeClass)
path
- the path defining the tree nodetreeClass
- the class of the desired treepublic static @Nullable 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(@Nullable TreePath path)
TreePath
.path
- the path defining the tree nodepublic static @Nullable 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 @Nullable BlockTree enclosingTopLevelBlock(@Nullable TreePath path)
public static ExpressionTree skipParens(ExpressionTree tree)
tree
- an expression treepublic static @Nullable Tree getAssignmentContext(@Nullable TreePath treePath)
treePath
- public static final TypeElement elementFromDeclaration(@Nullable ClassTree node)
node
- public static final @NonNull ExecutableElement elementFromDeclaration(@Nullable MethodTree node)
node
- public static final VariableElement elementFromDeclaration(VariableTree node)
node
- public static final @Nullable Element elementFromUse(ExpressionTree node)
Trees.getElement(TreePath)
instead.
TODO: remove this method, as it really doesn't do anything.node
- the tree corresponding to a use of an elementpublic static final @NonNull ExecutableElement elementFromUse(MethodInvocationTree node)
public static final @NonNull ExecutableElement elementFromUse(NewClassTree node)
public static final boolean isUseOfElement(ExpressionTree node)
node
- the ExpressionTree to testpublic static final @Nullable Name methodName(MethodInvocationTree node)
public static final boolean containsThisConstructorInvocation(@Nullable MethodTree node)
public static boolean hasExplicitConstructor(@Nullable ClassTree node)
node
- A class tree.public static final boolean isDiamondTree(@Nullable Tree tree)
public static final boolean isStringConcatenation(@Nullable Tree tree)
String
concatenation
operationpublic static final boolean isStringCompoundConcatenation(CompoundAssignmentTree tree)
public static boolean isCompileTimeString(ExpressionTree node)
public static ExpressionTree getReceiverTree(ExpressionTree expression)
public static boolean isClassTree(Tree.Kind kind)
public static boolean isMethodInvocation(@Nullable Tree tree, @NonNull ExecutableElement method, ProcessingEnvironment env)
public static @NonNull ExecutableElement getMethod(@ReadOnly String typeName, @ReadOnly String methodName, int params, ProcessingEnvironment env)
public static boolean isFieldAccess(@Nullable Tree tree, VariableElement var, ProcessingEnvironment env)
public static VariableElement getField(@ReadOnly String typeName, @ReadOnly String fieldName, ProcessingEnvironment env)
typeName
- the class where the field is declared.fieldName
- the name of the field.env
- the processing environment.public static boolean isExpressionTree(@Nullable Tree tree)
tree
- the Tree to test.public static boolean isEnumSuper(MethodInvocationTree node)
node
- the method invocation to checkEnum
constructor