Class TreeUtils
Tree.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.plumelib.util.UniqueIdMap<com.sun.source.tree.Tree>Unique IDs for trees. -
Method Summary
Modifier and TypeMethodDescriptionstatic AnnotationMirrorannotationFromAnnotationTree(com.sun.source.tree.AnnotationTree tree) Converts the given AnnotationTree to an AnnotationMirror.static List<? extends AnnotationMirror>annotationsFromArrayCreation(com.sun.source.tree.NewArrayTree tree, int level) Converts the given NewArrayTree to a list of AnnotationMirrors.static List<? extends AnnotationMirror>annotationsFromTree(com.sun.source.tree.AnnotatedTypeTree tree) Converts the given AnnotatedTypeTree to a list of AnnotationMirrors.static List<? extends AnnotationMirror>annotationsFromTree(com.sun.source.tree.TypeParameterTree tree) Converts the given TypeParameterTree to a list of AnnotationMirrors.static List<AnnotationMirror>annotationsFromTypeAnnotationTrees(List<? extends com.sun.source.tree.AnnotationTree> annoTrees) Converts the given AnnotationTrees to AnnotationMirrors.static com.sun.source.tree.VariableTreebindingPatternTreeGetVariable(com.sun.source.tree.Tree bindingPatternTree) Returns the binding variable ofbindingPatternTree.static booleancanHaveTypeAnnotation(com.sun.source.tree.Tree tree) Returntrueif and only iftreecan have a type annotation.static @Nullable com.sun.source.tree.TreecaseTreeGetBody(com.sun.source.tree.CaseTree caseTree) Returns the body of the case statement if it is of the formcase <expression> -> <expression>.static List<? extends com.sun.source.tree.ExpressionTree>caseTreeGetExpressions(com.sun.source.tree.CaseTree caseTree) Get the list of expressions from a case expression.static Set<com.sun.source.tree.Tree.Kind>Return the set of kinds that represent classes.static ExecutableElementconstructor(com.sun.source.tree.NewClassTree tree) Deprecated.use elementFromUse insteadstatic booleancontainsThisConstructorInvocation(com.sun.source.tree.MethodTree tree) Returns true if the first statement in the body is a self constructor invocation within a constructor.static com.sun.source.tree.LiteralTreecreateLiteral(com.sun.tools.javac.code.TypeTag typeTag, @Nullable Object value, TypeMirror typeMirror, ProcessingEnvironment processingEnv) Creates a LiteralTree for the given value.static Set<com.sun.source.tree.Tree.Kind>Return the set of kinds that represent declarations: classes, methods, and variables.static @Nullable TypeElementelementFromDeclaration(com.sun.source.tree.ClassTree tree) Returns the type element corresponding to the given class declaration.elementFromDeclaration(com.sun.source.tree.ExpressionTree tree) Deprecated.use elementFromUse or elementFromTreestatic ElementelementFromDeclaration(com.sun.source.tree.MemberSelectTree tree) Deprecated.use elementFromUsestatic ExecutableElementelementFromDeclaration(com.sun.source.tree.MethodInvocationTree tree) Deprecated.use elementFromUsestatic @Nullable ExecutableElementelementFromDeclaration(com.sun.source.tree.MethodTree tree) Returns the ExecutableElement for the given method declaration.static ExecutableElementelementFromDeclaration(com.sun.source.tree.NewClassTree tree) Deprecated.use elementFromUsestatic @Nullable VariableElementelementFromDeclaration(com.sun.source.tree.VariableTree tree) Returns the VariableElement corresponding to the given variable declaration.static @Nullable TypeElementelementFromTree(com.sun.source.tree.ClassTree tree) Deprecated.use elementFromDeclarationelementFromTree(com.sun.source.tree.ExpressionTree tree) Returns the element corresponding to the given tree.static ElementelementFromTree(com.sun.source.tree.MemberSelectTree tree) Deprecated.use elementFromUsestatic ExecutableElementelementFromTree(com.sun.source.tree.MethodInvocationTree tree) Deprecated.use elementFromUsestatic @Nullable ExecutableElementelementFromTree(com.sun.source.tree.MethodTree tree) Deprecated.use elementFromDeclarationstatic ExecutableElementelementFromTree(com.sun.source.tree.NewClassTree tree) Deprecated.use elementFromUseelementFromTree(com.sun.source.tree.Tree tree) Returns theElementfor the given Tree API node.static @Nullable VariableElementelementFromTree(com.sun.source.tree.VariableTree tree) Deprecated.use elementFromDeclarationstatic @Nullable TypeElementelementFromUse(com.sun.source.tree.ClassTree tree) Deprecated.use elementFromDeclarationstatic ElementelementFromUse(com.sun.source.tree.ExpressionTree tree) Gets the element for the declaration corresponding to this use of an element.static ElementelementFromUse(com.sun.source.tree.MemberSelectTree tree) Returns the element for the given expression.static ExecutableElementelementFromUse(com.sun.source.tree.MethodInvocationTree tree) Returns the ExecutableElement for the called method.static @Nullable ExecutableElementelementFromUse(com.sun.source.tree.MethodTree tree) Deprecated.use elementFromDeclarationstatic ExecutableElementelementFromUse(com.sun.source.tree.NewClassTree tree) Gets the ExecutableElement for the called constructor, from a constructor invocation.static @Nullable VariableElementelementFromUse(com.sun.source.tree.VariableTree tree) Deprecated.use elementFromDeclarationstatic ExecutableElementfindFunction(com.sun.source.tree.Tree tree, ProcessingEnvironment env) The type of the lambda or method reference tree is a functional interface type.static com.sun.source.tree.TreefirstStatement(com.sun.source.tree.Tree tree) Returns the first statement of the tree if it is a block.static com.sun.source.tree.LiteralTreegetDefaultValueTree(TypeMirror typeMirror, ProcessingEnvironment processingEnv) Return a tree for the default value of the given type.static List<? extends com.sun.source.tree.AnnotationTree>getExplicitAnnotationTrees(@Nullable List<? extends com.sun.source.tree.AnnotationTree> annoTrees, com.sun.source.tree.Tree typeTree) Returns the annotations explicitly written on the given type.static VariableElementgetField(@FullyQualifiedName String typeName, String fieldName, ProcessingEnvironment env) Returns the VariableElement for a field declaration.static StringgetFieldName(com.sun.source.tree.Tree tree) Compute the name of the field that the field accesstreeaccesses.static com.sun.source.tree.Tree.KindgetKindRecordAsClass(com.sun.source.tree.Tree tree) Calls getKind() on the given tree, but returns CLASS if the Kind is RECORD.static ExecutableElementgetMethod(@FullyQualifiedName String typeName, String methodName, int params, ProcessingEnvironment env) Returns the ExecutableElement for a method declaration.static ExecutableElementgetMethod(@FullyQualifiedName String typeName, String methodName, ProcessingEnvironment env, String... paramTypes) Returns the ExecutableElement for a method declaration.static ExecutableElementgetMethod(Class<?> type, String methodName, int params, ProcessingEnvironment env) Returns the ExecutableElement for a method declaration.static ExecutableElementgetMethod(Class<?> type, String methodName, ProcessingEnvironment env, String... paramTypes) Returns the ExecutableElement for a method declaration.static StringgetMethodName(com.sun.source.tree.Tree tree) Compute the name of the method that the method accesstreeaccesses.static @Nullable ExecutableElementgetMethodOrNull(@FullyQualifiedName String typeName, String methodName, int params, ProcessingEnvironment env) Returns the ExecutableElement for a method declaration.static List<ExecutableElement>getMethods(@FullyQualifiedName String typeName, String methodName, int params, ProcessingEnvironment env) Returns all ExecutableElements for method declarations of methodName, in class typeName, with params formal parameters.static @Nullable com.sun.source.tree.ExpressionTreegetReceiverTree(com.sun.source.tree.ExpressionTree expression) Returns the receiver tree of a field access or a method invocation.static ExecutableElementgetSuperConstructor(com.sun.source.tree.NewClassTree newClassTree) Returns the constructor invoked bynewClassTreeunlessnewClassTreeis creating an anonymous class.static booleanhasExplicitConstructor(com.sun.source.tree.ClassTree tree) Determine whether the given class contains an explicit constructor.static booleanhasSyntheticArgument(com.sun.source.tree.NewClassTree tree) Returns true iftreehas a synthetic argument.static @Nullable com.sun.source.tree.TreeinstanceOfGetPattern(com.sun.source.tree.InstanceOfTree instanceOfTree) Returns the pattern ofinstanceOfTreetree.static booleanisAnonymousConstructor(com.sun.source.tree.MethodTree method) Determines whether or not the givenMethodTreeis an anonymous constructor (the constructor for an anonymous class).static booleanisArrayLengthAccess(com.sun.source.tree.Tree tree) Returns whether or not tree is an access of array length.static booleanisAutoGeneratedRecordMember(com.sun.source.tree.Tree member) Returns true if the givenTreeis part of a record that has been automatically generated by the compiler.static booleanReturns true if the givenElementis part of a record that has been automatically generated by the compiler.static booleanisBinaryComparison(com.sun.source.tree.BinaryTree tree) Returns true if thetreeis a binary tree that performs a comparison.static booleanisCaseRule(com.sun.source.tree.CaseTree caseTree) Returns true if this is a case rule (as opposed to a case statement).static booleanisClassLiteral(com.sun.source.tree.Tree tree) Determine whethertreeis a class literal, such asstatic booleanisClassTree(com.sun.source.tree.Tree tree) Is the given tree kind a class, i.e.static booleanisCompactCanonicalRecordConstructor(com.sun.source.tree.MethodTree method) Returns true if the givenMethodTreeis a compact canonical constructor (the constructor for a record where the parameters are implicitly declared and implicitly assigned to the record's fields).static booleanisCompileTimeString(com.sun.source.tree.ExpressionTree tree) Returns true if the tree is a constant-time expression.static booleanisConstructor(com.sun.source.tree.MethodTree tree) Checks if the provided method is a constructor method or no.static booleanisDeclarationTree(com.sun.source.tree.Tree tree) Returns true if the given tree is a declaration.static booleanisDefaultCaseTree(com.sun.source.tree.CaseTree caseTree) Returns true if this is the default case for a switch statement or expression.static booleanisDiamondTree(com.sun.source.tree.Tree tree) Returns true if the tree is of a diamond type.static booleanisEnumSuperCall(com.sun.source.tree.MethodInvocationTree tree) Returns true if this is a super call to theEnumconstructor.static booleanisExplicitThisDereference(com.sun.source.tree.ExpressionTree tree) Determine whether the given expression is either "this" or an outer "C.this".static booleanisExprConstTrue(com.sun.source.tree.ExpressionTree tree) Determine whether an expressionExpressionTreehas the constant value true, according to the compiler logic.static booleanisExpressionTree(com.sun.source.tree.Tree tree) Determine whether the given tree represents an ExpressionTree.static booleanisFieldAccess(com.sun.source.tree.Tree tree) Determine whethertreeis a field access expression, such asstatic booleanisImplicitlyTypedLambda(com.sun.source.tree.Tree tree) Returns true iftreeis an implicitly typed lambda.static booleanisLocalVariable(com.sun.source.tree.Tree tree) Returns true if the tree is the declaration or use of a local variable.static booleanisMethodAccess(com.sun.source.tree.Tree tree) Determine whethertreerefers to a method element, such as.static booleanisMethodInvocation(com.sun.source.tree.Tree methodTree, List<ExecutableElement> methods, ProcessingEnvironment processingEnv) Returns true if the argument is an invocation of one of the given methods, or of any method that overrides them.static booleanisMethodInvocation(com.sun.source.tree.Tree tree, 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 booleanisNullExpression(com.sun.source.tree.Tree t) Returns true if the given tree evaluates tonull.static booleanisSelfAccess(com.sun.source.tree.ExpressionTree tree) Returns true if the tree is a tree that 'looks like' either an access of a field or an invocation of a method that are owned by the same accessing instance.static booleanisSpecificFieldAccess(com.sun.source.tree.Tree tree, VariableElement var) Returns true if and only if the giventreerepresents a field access of the givenVariableElement.static booleanisStringCompoundConcatenation(com.sun.source.tree.CompoundAssignmentTree tree) Returns true if the compound assignment tree is a string concatenation.static booleanisStringConcatenation(com.sun.source.tree.Tree tree) Returns true if the tree represents aStringconcatenation operation.static booleanisSuperConstructorCall(com.sun.source.tree.MethodInvocationTree tree) Checks if the method invocation is a call to super.static booleanisSwitchStatement(com.sun.source.tree.Tree tree) Returns true if the given tree is a switch statement (as opposed to a switch expression).static booleanisSynthetic(com.sun.source.tree.MethodTree tree) Returns true if the given method is synthetic.static booleanReturns true if the given method is synthetic.static booleanisThisConstructorCall(com.sun.source.tree.MethodInvocationTree tree) Checks if the method invocation is a call to "this".static booleanisTypeDeclaration(com.sun.source.tree.Tree tree) Determine whether the given tree represents a declaration of a type (including type parameters).static booleanisTypeTree(com.sun.source.tree.Tree tree) Is the given tree a type instantiation?static booleanisUseOfElement(com.sun.source.tree.ExpressionTree tree) Determine whether the given ExpressionTree has an underlying element.static booleanisVarArgs(com.sun.source.tree.MethodInvocationTree invok) Returns true if the given method invocation is a varargs invocation.static booleanisVarArgs(com.sun.source.tree.NewClassTree newClassTree) Returns true if the given constructor invocation is a varargs invocation.static booleanisVarArgs(com.sun.source.tree.Tree tree) Returns true if the given method/constructor invocation is a varargs invocation.static booleanisWideningBinary(com.sun.source.tree.BinaryTree tree) Returns true if the binary operator may do a widening primitive conversion.static NamemethodName(com.sun.source.tree.MethodInvocationTree tree) Returns the name of the invoked method.static StringnameExpressionToString(com.sun.source.tree.ExpressionTree nameExpr) Given a javac ExpressionTree representing a fully qualified name such as "java.lang.Object", creates a String containing the name.static booleansameTree(com.sun.source.tree.ExpressionTree expr1, com.sun.source.tree.ExpressionTree expr2) Returns true if two expressions originating from the same scope are identical, i.e.static List<? extends com.sun.source.tree.CaseTree>switchExpressionTreeGetCases(com.sun.source.tree.Tree switchExpressionTree) Returns the cases ofswitchExpressionTree.static com.sun.source.tree.ExpressionTreeswitchExpressionTreeGetExpression(com.sun.source.tree.Tree switchExpressionTree) Returns the selector expression ofswitchExpressionTree.static StringtoStringOneLine(com.sun.source.tree.Tree tree) Return toString(), but without line separators.static StringtoStringTruncated(com.sun.source.tree.Tree tree, int length) Return eithertoStringOneLine(com.sun.source.tree.Tree)if it is no more thanlengthcharacters, ortoStringOneLine(com.sun.source.tree.Tree)quoted and truncated.static TypeMirrortypeOf(com.sun.source.tree.Tree tree) Returns the type as a TypeMirror oftree.static Set<com.sun.source.tree.Tree.Kind>static VariableElementvariableElementFromTree(com.sun.source.tree.Tree tree) Returns theVariableElementfor the given Tree API node.static VariableElementvariableElementFromUse(com.sun.source.tree.ExpressionTree tree) Returns the VariableElement corresponding to the given use.static @PolyInterned com.sun.source.tree.ExpressionTreewithoutParens(@PolyInterned com.sun.source.tree.ExpressionTree tree) If the given tree is a parenthesized tree, return the enclosed non-parenthesized tree.static @PolyInterned com.sun.source.tree.ExpressionTreewithoutParensOrCasts(@PolyInterned com.sun.source.tree.ExpressionTree tree) If the given tree is a parenthesized tree or cast tree, return the enclosed non-parenthesized, non-cast tree.static com.sun.source.tree.ExpressionTreeyieldTreeGetValue(com.sun.source.tree.Tree yieldTree) Returns the value (expression) foryieldTree.
-
Field Details
-
treeUids
public static final org.plumelib.util.UniqueIdMap<com.sun.source.tree.Tree> treeUidsUnique IDs for trees. Used instead of hash codes, so output is deterministic.
-
-
Method Details
-
isConstructor
public static boolean isConstructor(com.sun.source.tree.MethodTree tree) Checks if the provided method is a constructor method or no.- Parameters:
tree- a tree defining the method- Returns:
- true iff tree describes a constructor
-
isSuperConstructorCall
public static boolean isSuperConstructorCall(com.sun.source.tree.MethodInvocationTree tree) Checks if the method invocation is a call to super.- Parameters:
tree- a tree defining a method invocation- Returns:
- true iff tree describes a call to super
-
isThisConstructorCall
public static boolean isThisConstructorCall(com.sun.source.tree.MethodInvocationTree tree) Checks if the method invocation is a call to "this".- Parameters:
tree- a tree defining a method invocation- Returns:
- true iff tree describes a call to this
-
isSelfAccess
public static boolean isSelfAccess(com.sun.source.tree.ExpressionTree tree) Returns true if the tree is a tree that 'looks like' either an access of a field or an invocation of a method that are owned by the same accessing instance.It would only return true if the access tree is of the form:
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.- Parameters:
tree- expression tree representing an access to object member- Returns:
trueiff the member is a member ofthisinstance
-
withoutParens
public static @PolyInterned com.sun.source.tree.ExpressionTree withoutParens(@PolyInterned com.sun.source.tree.ExpressionTree tree) If the given tree is a parenthesized tree, return the enclosed non-parenthesized tree. Otherwise, return the same tree.- Parameters:
tree- an expression tree- Returns:
- the outermost non-parenthesized tree enclosed by the given tree
-
withoutParensOrCasts
public static @PolyInterned com.sun.source.tree.ExpressionTree withoutParensOrCasts(@PolyInterned com.sun.source.tree.ExpressionTree tree) If the given tree is a parenthesized tree or cast tree, return the enclosed non-parenthesized, non-cast tree. Otherwise, return the same tree.- Parameters:
tree- an expression tree- Returns:
- the outermost non-parenthesized non-cast tree enclosed by the given tree
-
elementFromDeclaration
Returns the type element corresponding to the given class declaration.- Parameters:
tree- class declaration- Returns:
- the element for the given class
-
elementFromTree
@Deprecated @Pure public static @Nullable TypeElement elementFromTree(com.sun.source.tree.ClassTree tree) Deprecated.use elementFromDeclarationReturns the type element corresponding to the given class declaration.The TypeElement may be null for an anonymous class.
- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the
Symbolfor the given tree, or null if one could not be found
-
elementFromUse
@Deprecated @Pure public static @Nullable TypeElement elementFromUse(com.sun.source.tree.ClassTree tree) Deprecated.use elementFromDeclarationReturns the type element corresponding to the given class declaration.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the
Symbolfor the given tree, or null if one could not be found
-
elementFromDeclaration
@Pure @Deprecated public static @Nullable Element elementFromDeclaration(com.sun.source.tree.ExpressionTree tree) Deprecated.use elementFromUse or elementFromTreeReturns the element corresponding to the given tree.- Parameters:
tree- the tree corresponding to a use of an element- Returns:
- the element for the corresponding declaration,
nullotherwise
-
elementFromTree
Returns the element corresponding to the given tree.- Parameters:
tree- the tree corresponding to a use of an element- Returns:
- the element for the corresponding declaration,
nullotherwise
-
elementFromUse
Gets the element for the declaration corresponding to this use of an element. To get the element for a declaration, useelementFromDeclaration(ClassTree),elementFromDeclaration(MethodTree), orelementFromDeclaration(VariableTree)instead.This method is just a wrapper around
elementFromTree(Tree), but this class might be the first place someone looks for this functionality.- Parameters:
tree- the tree, which must be a use of an element- Returns:
- the element for the corresponding declaration,
nullotherwise
-
variableElementFromUse
Returns the VariableElement corresponding to the given use.- Parameters:
tree- the tree corresponding to a use of a VariableElement- Returns:
- the element for the corresponding declaration,
nullotherwise
-
elementFromDeclaration
@Deprecated @Pure public static Element elementFromDeclaration(com.sun.source.tree.MemberSelectTree tree) Deprecated.use elementFromUseReturns the element for the given expression.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the element for the given tree, or null if one could not be found
-
elementFromTree
Deprecated.use elementFromUseReturns the element for the given expression.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the element for the given tree, or null if one could not be found
-
elementFromUse
Returns the element for the given expression.- Parameters:
tree- a method call- Returns:
- the element for the called method
-
elementFromDeclaration
@Deprecated @Pure public static ExecutableElement elementFromDeclaration(com.sun.source.tree.MethodInvocationTree tree) Deprecated.use elementFromUseReturns the ExecutableElement for the called method.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the Element for the given tree, or null if one could not be found
-
elementFromTree
@Deprecated @Pure public static ExecutableElement elementFromTree(com.sun.source.tree.MethodInvocationTree tree) Deprecated.use elementFromUseReturns the ExecutableElement for the called method.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the Element for the given tree, or null if one could not be found
-
elementFromUse
Returns the ExecutableElement for the called method.- Parameters:
tree- a method call- Returns:
- the ExecutableElement for the called method
-
elementFromDeclaration
public static @Nullable ExecutableElement elementFromDeclaration(com.sun.source.tree.MethodTree tree) Returns the ExecutableElement for the given method declaration.The result can be null, when
treeis a method in an anonymous class.- Parameters:
tree- a method declaration- Returns:
- the element for the given method, or null (e.g. for a method in an anonymous class)
-
elementFromTree
@Deprecated @Pure public static @Nullable ExecutableElement elementFromTree(com.sun.source.tree.MethodTree tree) Deprecated.use elementFromDeclarationReturns the ExecutableElement for the given method declaration.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the Element for the given tree, or null if one could not be found
-
elementFromUse
@Deprecated @Pure public static @Nullable ExecutableElement elementFromUse(com.sun.source.tree.MethodTree tree) Deprecated.use elementFromDeclarationReturns the ExecutableElement for the given method declaration.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the Element for the given tree, or null if one could not be found
-
elementFromDeclaration
@Deprecated @Pure public static ExecutableElement elementFromDeclaration(com.sun.source.tree.NewClassTree tree) Deprecated.use elementFromUseReturns the ExecutableElement for the given constructor invocation.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the
Symbolfor the given tree, or null if one could not be found - Throws:
IllegalArgumentException- iftreeis null or is not a valid javac-internal tree (JCTree)
-
elementFromTree
@Deprecated @Pure public static ExecutableElement elementFromTree(com.sun.source.tree.NewClassTree tree) Deprecated.use elementFromUseGets the ExecutableElement for the called constructor, from a constructor invocation.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the
Symbolfor the given tree, or null if one could not be found - Throws:
IllegalArgumentException- iftreeis null or is not a valid javac-internal tree (JCTree)
-
elementFromUse
Gets the ExecutableElement for the called constructor, from a constructor invocation.- Parameters:
tree- a constructor invocation- Returns:
- the ExecutableElement for the called constructor
- See Also:
-
elementFromDeclaration
public static @Nullable VariableElement elementFromDeclaration(com.sun.source.tree.VariableTree tree) Returns the VariableElement corresponding to the given variable declaration.- Parameters:
tree- the variable- Returns:
- the element for the given variable
-
elementFromTree
@Deprecated @Pure public static @Nullable VariableElement elementFromTree(com.sun.source.tree.VariableTree tree) Deprecated.use elementFromDeclarationReturns the VariableElement corresponding to the given variable declaration.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the Element for the given tree, or null if one could not be found
-
elementFromUse
@Deprecated @Pure public static @Nullable VariableElement elementFromUse(com.sun.source.tree.VariableTree tree) Deprecated.use elementFromDeclarationReturns the VariableElement corresponding to the given variable declaration.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the Element for the given tree, or null if one could not be found
-
variableElementFromTree
Returns theVariableElementfor the given Tree API node.- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the
Symbolfor the given tree - Throws:
IllegalArgumentException- iftreeis null or is not a valid javac-internal tree (JCTree)
-
elementFromTree
Returns theElementfor the given Tree API node. For an object instantiation returns the value of theJCTree.JCNewClass.constructorfield.Use this only when you do not statically know whether the tree is a declaration or a use of an element.
- Parameters:
tree- theTreenode to get the symbol for- Returns:
- the
Symbolfor the given tree, or null if one could not be found - Throws:
IllegalArgumentException- iftreeis null or is not a valid javac-internal tree (JCTree)
-
getSuperConstructor
Returns the constructor invoked bynewClassTreeunlessnewClassTreeis creating an anonymous class. In which case, the super constructor is returned.- Parameters:
newClassTree- the constructor invocation- Returns:
- the super constructor invoked in the body of the anonymous constructor; or
constructor(NewClassTree)ifnewClassTreeis not creating an anonymous class
-
constructor
Deprecated.use elementFromUse insteadDetermines the symbol for a constructor given an invocation vianew.- Parameters:
tree- the constructor invocation- Returns:
- the
ExecutableElementcorresponding to the constructor call intree - See Also:
-
isUseOfElement
@EnsuresNonNullIf(result=true,expression="elementFromTree(#1)") @EnsuresNonNullIf(result=true,expression="elementFromUse(#1)") @Pure public static boolean isUseOfElement(com.sun.source.tree.ExpressionTree tree) Determine whether the given ExpressionTree has an underlying element.- Parameters:
tree- the ExpressionTree to test- Returns:
- whether the tree refers to an identifier, member select, or method invocation
-
hasSyntheticArgument
public static boolean hasSyntheticArgument(com.sun.source.tree.NewClassTree tree) Returns true iftreehas a synthetic argument.For some anonymous classes with an explicit enclosing expression, javac creates a synthetic argument to the constructor that is the enclosing expression of the NewClassTree. Suppose a programmer writes:
Java 9 javac creates the following synthetic tree forclass Outer { class Inner { } void method() { this.new Inner(){}; } }this.new Inner(){}:
Java 11 javac creates a different tree without the synthetic argument fornew Inner(this) { (.Outer x0) { x0.super(); } }this.new Inner(){}; the first line in the below code differs:this.new Inner() { (.Outer x0) { x0.super(); } }- Parameters:
tree- a new class tree- Returns:
- true if
treehas a synthetic argument
-
methodName
Returns the name of the invoked method.- Parameters:
tree- the method invocation- Returns:
- the name of the invoked method
-
containsThisConstructorInvocation
public static boolean containsThisConstructorInvocation(com.sun.source.tree.MethodTree tree) Returns true if the first statement in the body is a self constructor invocation within a constructor.- Parameters:
tree- the method declaration- Returns:
- true if the first statement in the body is a self constructor invocation within a constructor
-
firstStatement
public static com.sun.source.tree.Tree firstStatement(com.sun.source.tree.Tree tree) Returns the first statement of the tree if it is a block. If it is not a block or an empty block, tree is returned.- Parameters:
tree- any kind of tree- Returns:
- the first statement of the tree if it is a block. If it is not a block or an empty block, tree is returned.
-
hasExplicitConstructor
public static boolean hasExplicitConstructor(com.sun.source.tree.ClassTree tree) Determine whether the given class contains an explicit constructor.- Parameters:
tree- a class tree- Returns:
- true iff there is an explicit constructor
-
isSynthetic
Returns true if the given method is synthetic. Also returns true if the method is a generated default constructor, which does not appear in source code but is not considered synthetic.- Parameters:
ee- a method or constructor element- Returns:
- true iff the given method is synthetic
-
isSynthetic
public static boolean isSynthetic(com.sun.source.tree.MethodTree tree) Returns true if the given method is synthetic.- Parameters:
tree- a method declaration tree- Returns:
- true iff the given method is synthetic
-
isDiamondTree
public static boolean isDiamondTree(com.sun.source.tree.Tree tree) Returns true if the tree is of a diamond type. In contrast to the implementation in TreeInfo, this version works on Trees.- See Also:
-
TreeInfo.isDiamond(JCTree)
-
isStringConcatenation
public static boolean isStringConcatenation(com.sun.source.tree.Tree tree) Returns true if the tree represents aStringconcatenation operation. -
isStringCompoundConcatenation
public static boolean isStringCompoundConcatenation(com.sun.source.tree.CompoundAssignmentTree tree) Returns true if the compound assignment tree is a string concatenation. -
isCompileTimeString
public static boolean isCompileTimeString(com.sun.source.tree.ExpressionTree tree) Returns true if the tree is a constant-time expression.A tree is a constant-time expression if it is:
- a literal tree
- a reference to a final variable initialized with a compile time constant
- a String concatenation of two compile time constants
- Parameters:
tree- the tree to check- Returns:
- true if the tree is a constant-time expression
-
getReceiverTree
public static @Nullable com.sun.source.tree.ExpressionTree getReceiverTree(com.sun.source.tree.ExpressionTree expression) Returns the receiver tree of a field access or a method invocation.- Parameters:
expression- a field access or a method invocation- Returns:
- the expression's receiver tree, or null if it does not have an explicit receiver
-
classTreeKinds
Return the set of kinds that represent classes.- Returns:
- the set of kinds that represent classes
-
declarationTreeKinds
Return the set of kinds that represent declarations: classes, methods, and variables.- Returns:
- the set of kinds that represent declarations
-
isClassTree
public static boolean isClassTree(com.sun.source.tree.Tree tree) Is the given tree kind a class, i.e. a class, enum, interface, or annotation type.- Parameters:
tree- the tree to test- Returns:
- true, iff the given kind is a class kind
-
typeTreeKinds
-
isDeclarationTree
public static boolean isDeclarationTree(com.sun.source.tree.Tree tree) Returns true if the given tree is a declaration.- Parameters:
tree- the tree to test- Returns:
- true if the given tree is a declaration
-
isTypeTree
public static boolean isTypeTree(com.sun.source.tree.Tree tree) Is the given tree a type instantiation?TODO: this is an under-approximation: e.g. an identifier could be either a type use or an expression. How can we distinguish.
- Parameters:
tree- the tree to test- Returns:
- true, iff the given tree is a type
-
isMethodInvocation
public static boolean isMethodInvocation(com.sun.source.tree.Tree tree, ExecutableElement method, ProcessingEnvironment env) Returns true if the given element is an invocation of the method, or of any method that overrides that one. -
isMethodInvocation
public static boolean isMethodInvocation(com.sun.source.tree.Tree methodTree, List<ExecutableElement> methods, ProcessingEnvironment processingEnv) Returns true if the argument is an invocation of one of the given methods, or of any method that overrides them. -
getMethod
public static ExecutableElement getMethod(Class<?> type, String methodName, int params, ProcessingEnvironment env) Returns the ExecutableElement for a method declaration. Errs if there is not exactly one matching method. If more than one method takes the same number of formal parameters, then usegetMethod(String, String, ProcessingEnvironment, String...).- Parameters:
type- the class that contains the methodmethodName- the name of the methodparams- the number of formal parametersenv- the processing environment- Returns:
- the ExecutableElement for the specified method
-
getMethod
public static ExecutableElement getMethod(@FullyQualifiedName String typeName, String methodName, int params, ProcessingEnvironment env) Returns the ExecutableElement for a method declaration. Errs if there is not exactly one matching method. If more than one method takes the same number of formal parameters, then usegetMethod(String, String, ProcessingEnvironment, String...).- Parameters:
typeName- the class that contains the methodmethodName- the name of the methodparams- the number of formal parametersenv- the processing environment- Returns:
- the ExecutableElement for the specified method
-
getMethodOrNull
public static @Nullable ExecutableElement getMethodOrNull(@FullyQualifiedName String typeName, String methodName, int params, ProcessingEnvironment env) Returns the ExecutableElement for a method declaration. Returns null there is no matching method. Errs if there is more than one matching method. If more than one method takes the same number of formal parameters, then usegetMethod(String, String, ProcessingEnvironment, String...).- Parameters:
typeName- the class that contains the methodmethodName- the name of the methodparams- the number of formal parametersenv- the processing environment- Returns:
- the ExecutableElement for the specified method, or null
-
getMethods
public static List<ExecutableElement> getMethods(@FullyQualifiedName String typeName, String methodName, int params, ProcessingEnvironment env) Returns all ExecutableElements for method declarations of methodName, in class typeName, with params formal parameters.- Parameters:
typeName- the class that contains the methodmethodName- the name of the methodparams- the number of formal parametersenv- the processing environment- Returns:
- the ExecutableElements for all matching methods
-
getMethod
public static ExecutableElement getMethod(Class<?> type, String methodName, ProcessingEnvironment env, String... paramTypes) Returns the ExecutableElement for a method declaration. Errs if there is no matching method.- Parameters:
type- the class that contains the methodmethodName- the name of the methodenv- the processing environmentparamTypes- the method's formal parameter types- Returns:
- the ExecutableElement for the specified method
-
getMethod
public static ExecutableElement getMethod(@FullyQualifiedName String typeName, String methodName, ProcessingEnvironment env, String... paramTypes) Returns the ExecutableElement for a method declaration. Errs if there is no matching method.- Parameters:
typeName- the class that contains the methodmethodName- the name of the methodenv- the processing environmentparamTypes- the method's formal parameter types- Returns:
- the ExecutableElement for the specified method
-
isExplicitThisDereference
public static boolean isExplicitThisDereference(com.sun.source.tree.ExpressionTree tree) Determine whether the given expression is either "this" or an outer "C.this".TODO: Should this also handle "super"?
-
isClassLiteral
public static boolean isClassLiteral(com.sun.source.tree.Tree tree) Determine whethertreeis a class literal, such asObject . class
- Returns:
- true iff if tree is a class literal
-
isFieldAccess
public static boolean isFieldAccess(com.sun.source.tree.Tree tree) Determine whethertreeis a field access expression, such asf obj . f
This method currently also returns true for class literals and qualified this.- Parameters:
tree- a tree that might be a field access- Returns:
- true iff if tree is a field access expression (implicit or explicit)
-
getFieldName
Compute the name of the field that the field accesstreeaccesses. Requirestreeto be a field access, as determined byisFieldAccess(which currently also returns true for class literals and qualified this).- Parameters:
tree- a field access tree- Returns:
- the name of the field accessed by
tree
-
isMethodAccess
public static boolean isMethodAccess(com.sun.source.tree.Tree tree) Determine whethertreerefers to a method element, such as.m(...) obj . m(...)
- Returns:
- true iff if tree is a method access expression (implicit or explicit)
-
getMethodName
Compute the name of the method that the method accesstreeaccesses. Requirestreeto be a method access, as determined byisMethodAccess.- Parameters:
tree- a method access tree- Returns:
- the name of the method accessed by
tree
-
canHaveTypeAnnotation
public static boolean canHaveTypeAnnotation(com.sun.source.tree.Tree tree) Returntrueif and only iftreecan have a type annotation.- Returns:
trueif and only iftreecan have a type annotation
-
isSpecificFieldAccess
Returns true if and only if the giventreerepresents a field access of the givenVariableElement. -
getField
public static VariableElement getField(@FullyQualifiedName String typeName, String fieldName, ProcessingEnvironment env) Returns the VariableElement for a field declaration.- Parameters:
typeName- the class where the field is declaredfieldName- the name of the fieldenv- the processing environment- Returns:
- the VariableElement for typeName.fieldName
-
isExpressionTree
public static boolean isExpressionTree(com.sun.source.tree.Tree tree) Determine whether the given tree represents an ExpressionTree.- Parameters:
tree- the Tree to test- Returns:
- whether the tree is an ExpressionTree
-
isEnumSuperCall
public static boolean isEnumSuperCall(com.sun.source.tree.MethodInvocationTree tree) Returns true if this is a super call to theEnumconstructor.- Parameters:
tree- the method invocation to check- Returns:
- true if this is a super call to the
Enumconstructor
-
isTypeDeclaration
public static boolean isTypeDeclaration(com.sun.source.tree.Tree tree) Determine whether the given tree represents a declaration of a type (including type parameters).- Parameters:
tree- the Tree to test- Returns:
- true if the tree is a type declaration
-
isArrayLengthAccess
public static boolean isArrayLengthAccess(com.sun.source.tree.Tree tree) Returns whether or not tree is an access of array length.- Parameters:
tree- tree to check- Returns:
- true if tree is an access of array length
-
isAnonymousConstructor
public static boolean isAnonymousConstructor(com.sun.source.tree.MethodTree method) Determines whether or not the givenMethodTreeis an anonymous constructor (the constructor for an anonymous class).- Parameters:
method- a method tree that may be an anonymous constructor- Returns:
- true if the given path points to an anonymous constructor, false if it does not
-
isCompactCanonicalRecordConstructor
public static boolean isCompactCanonicalRecordConstructor(com.sun.source.tree.MethodTree method) Returns true if the givenMethodTreeis a compact canonical constructor (the constructor for a record where the parameters are implicitly declared and implicitly assigned to the record's fields). This may be an explicitly declared compact canonical constructor or an implicitly generated one.- Parameters:
method- a method tree that may be a compact canonical constructor- Returns:
- true if the given method is a compact canonical constructor
-
isAutoGeneratedRecordMember
public static boolean isAutoGeneratedRecordMember(com.sun.source.tree.Tree member) Returns true if the givenTreeis part of a record that has been automatically generated by the compiler. This can be a field that is derived from the record's header field list, or an automatically generated canonical constructor.- Parameters:
member- theTreefor a member of a record- Returns:
- true if the given path is generated by the compiler
-
isAutoGeneratedRecordMember
Returns true if the givenElementis part of a record that has been automatically generated by the compiler. This can be a field that is derived from the record's header field list, or an automatically generated canonical constructor.- Parameters:
e- theElementfor a member of a record- Returns:
- true if the given element is generated by the compiler
-
annotationsFromTypeAnnotationTrees
public static List<AnnotationMirror> annotationsFromTypeAnnotationTrees(List<? extends com.sun.source.tree.AnnotationTree> annoTrees) Converts the given AnnotationTrees to AnnotationMirrors.- Parameters:
annoTrees- list of annotation trees to convert to annotation mirrors- Returns:
- list of annotation mirrors that represent the given annotation trees
-
annotationFromAnnotationTree
public static AnnotationMirror annotationFromAnnotationTree(com.sun.source.tree.AnnotationTree tree) Converts the given AnnotationTree to an AnnotationMirror.- Parameters:
tree- annotation tree to convert to an annotation mirror- Returns:
- annotation mirror that represent the given annotation tree
-
annotationsFromTree
public static List<? extends AnnotationMirror> annotationsFromTree(com.sun.source.tree.AnnotatedTypeTree tree) Converts the given AnnotatedTypeTree to a list of AnnotationMirrors.- Parameters:
tree- annotated type tree to convert- Returns:
- list of AnnotationMirrors from the tree
-
annotationsFromTree
public static List<? extends AnnotationMirror> annotationsFromTree(com.sun.source.tree.TypeParameterTree tree) Converts the given TypeParameterTree to a list of AnnotationMirrors.- Parameters:
tree- type parameter tree to convert- Returns:
- list of AnnotationMirrors from the tree
-
annotationsFromArrayCreation
public static List<? extends AnnotationMirror> annotationsFromArrayCreation(com.sun.source.tree.NewArrayTree tree, int level) Converts the given NewArrayTree to a list of AnnotationMirrors.- Parameters:
tree- new array tree- Returns:
- list of AnnotationMirrors from the tree
-
isLocalVariable
public static boolean isLocalVariable(com.sun.source.tree.Tree tree) Returns true if the tree is the declaration or use of a local variable.- Parameters:
tree- the tree to check- Returns:
- true if the tree is the declaration or use of a local variable
-
typeOf
Returns the type as a TypeMirror oftree. To obtaintree's AnnotatedTypeMirror, callAnnotatedTypeFactory.getAnnotatedType().- Returns:
- the type as a TypeMirror of
tree
-
findFunction
public static ExecutableElement findFunction(com.sun.source.tree.Tree tree, ProcessingEnvironment env) The type of the lambda or method reference tree is a functional interface type. This method returns the single abstract method declared by that functional interface. (The type of this method is referred to as the function type.)- Parameters:
tree- lambda or member reference treeenv- ProcessingEnvironment- Returns:
- the single abstract method declared by the type of the tree
-
isImplicitlyTypedLambda
public static boolean isImplicitlyTypedLambda(com.sun.source.tree.Tree tree) Returns true iftreeis an implicitly typed lambda.A lambda expression whose formal type parameters have inferred types is an implicitly typed lambda. (See JLS 15.27.1)
- Parameters:
tree- any kind of tree- Returns:
- true iff
treeis an implicitly typed lambda
-
isExprConstTrue
public static boolean isExprConstTrue(com.sun.source.tree.ExpressionTree tree) Determine whether an expressionExpressionTreehas the constant value true, according to the compiler logic.- Parameters:
tree- the expression to be checked- Returns:
- true if
treehas the constant value true
-
toStringOneLine
Return toString(), but without line separators.- Parameters:
tree- a tree- Returns:
- a one-line string representation of the tree
-
toStringTruncated
Return eithertoStringOneLine(com.sun.source.tree.Tree)if it is no more thanlengthcharacters, ortoStringOneLine(com.sun.source.tree.Tree)quoted and truncated.- Parameters:
tree- a treelength- the maximum length for the result; must be at least 6- Returns:
- a one-line string representation of the tree that is no longer than
lengthcharacters long
-
nameExpressionToString
Given a javac ExpressionTree representing a fully qualified name such as "java.lang.Object", creates a String containing the name.- Parameters:
nameExpr- an ExpressionTree representing a fully qualified name- Returns:
- a String representation of the fully qualified name
-
isWideningBinary
public static boolean isWideningBinary(com.sun.source.tree.BinaryTree tree) Returns true if the binary operator may do a widening primitive conversion. See JLS chapter 5.- Parameters:
tree- a binary tree- Returns:
- true if the tree's operator does numeric promotion on its arguments
-
getExplicitAnnotationTrees
public static List<? extends com.sun.source.tree.AnnotationTree> getExplicitAnnotationTrees(@Nullable List<? extends com.sun.source.tree.AnnotationTree> annoTrees, com.sun.source.tree.Tree typeTree) Returns the annotations explicitly written on the given type.- Parameters:
annoTrees- annotations written before a variable/method declaration; null if this type is not from such a location. This might contain type annotations that the Java parser attached to the declaration rather than to the type.typeTree- the type whose annotations to return- Returns:
- the annotations explicitly written on the given type
-
getDefaultValueTree
public static com.sun.source.tree.LiteralTree getDefaultValueTree(TypeMirror typeMirror, ProcessingEnvironment processingEnv) Return a tree for the default value of the given type. The default value is 0, false, or null.- Parameters:
typeMirror- a typeprocessingEnv- the processing environment- Returns:
- a tree for
type's default value
-
createLiteral
public static com.sun.source.tree.LiteralTree createLiteral(com.sun.tools.javac.code.TypeTag typeTag, @Nullable Object value, TypeMirror typeMirror, ProcessingEnvironment processingEnv) Creates a LiteralTree for the given value.- Parameters:
typeTag- the literal's type tagvalue- a wrapped primitive, null, or a StringtypeMirror- the typeMirror for the literalprocessingEnv- the processing environment- Returns:
- a LiteralTree for the given type tag and value
-
isNullExpression
public static boolean isNullExpression(com.sun.source.tree.Tree t) Returns true if the given tree evaluates tonull.- Parameters:
t- a tree- Returns:
- true if the given tree evaluates to
null
-
sameTree
public static boolean sameTree(com.sun.source.tree.ExpressionTree expr1, com.sun.source.tree.ExpressionTree expr2) Returns true if two expressions originating from the same scope are identical, i.e. they are syntactically represented in the same way (modulo parentheses) and represent the same value.If the expression includes one or more method calls, assumes the method calls are deterministic.
- Parameters:
expr1- the first expression to compareexpr2- the second expression to compare; expr2 must originate from the same scope as expr1- Returns:
- true if the expressions expr1 and expr2 are syntactically identical
-
isDefaultCaseTree
public static boolean isDefaultCaseTree(com.sun.source.tree.CaseTree caseTree) Returns true if this is the default case for a switch statement or expression.- Parameters:
caseTree- a case tree- Returns:
- true if
caseTreeis the default case for a switch statement or expression
-
isCaseRule
public static boolean isCaseRule(com.sun.source.tree.CaseTree caseTree) Returns true if this is a case rule (as opposed to a case statement).- Parameters:
caseTree- a case tree- Returns:
- true if
caseTreeis a case rule
-
caseTreeGetExpressions
public static List<? extends com.sun.source.tree.ExpressionTree> caseTreeGetExpressions(com.sun.source.tree.CaseTree caseTree) Get the list of expressions from a case expression. For the default case, this is empty. Otherwise, in JDK 11 and earlier, this is a singleton list. In JDK 12 onwards, there can be multiple expressions per case.- Parameters:
caseTree- the case expression to get the expressions from- Returns:
- the list of expressions in the case
-
caseTreeGetBody
public static @Nullable com.sun.source.tree.Tree caseTreeGetBody(com.sun.source.tree.CaseTree caseTree) Returns the body of the case statement if it is of the formcase <expression> -> <expression>. This method should only be called ifCaseTree.getStatements()returns null.- Parameters:
caseTree- the case expression to get the body from- Returns:
- the body of the case tree
-
bindingPatternTreeGetVariable
public static com.sun.source.tree.VariableTree bindingPatternTreeGetVariable(com.sun.source.tree.Tree bindingPatternTree) Returns the binding variable ofbindingPatternTree.- Parameters:
bindingPatternTree- the BindingPatternTree whose binding variable is returned- Returns:
- the binding variable of
bindingPatternTree
-
instanceOfGetPattern
public static @Nullable com.sun.source.tree.Tree instanceOfGetPattern(com.sun.source.tree.InstanceOfTree instanceOfTree) Returns the pattern ofinstanceOfTreetree. Returns null if the instanceof does not have a pattern, including if the JDK version does not support instance-of patterns.- Parameters:
instanceOfTree- theInstanceOfTreewhose pattern is returned- Returns:
- the
PatternTreeofinstanceOfTreeor null if it doesn't exist
-
switchExpressionTreeGetExpression
public static com.sun.source.tree.ExpressionTree switchExpressionTreeGetExpression(com.sun.source.tree.Tree switchExpressionTree) Returns the selector expression ofswitchExpressionTree. For exampleswitch ( expression ) { ... }- Parameters:
switchExpressionTree- the switch expression whose selector expression is returned- Returns:
- the selector expression of
switchExpressionTree
-
switchExpressionTreeGetCases
public static List<? extends com.sun.source.tree.CaseTree> switchExpressionTreeGetCases(com.sun.source.tree.Tree switchExpressionTree) Returns the cases ofswitchExpressionTree. For exampleswitch ( expression ) { cases }- Parameters:
switchExpressionTree- the switch expression whose cases are returned- Returns:
- the cases of
switchExpressionTree
-
isSwitchStatement
public static boolean isSwitchStatement(com.sun.source.tree.Tree tree) Returns true if the given tree is a switch statement (as opposed to a switch expression).- Parameters:
tree- the switch statement or expression to check- Returns:
- true if the given tree is a switch statement (as opposed to a switch expression)
-
yieldTreeGetValue
public static com.sun.source.tree.ExpressionTree yieldTreeGetValue(com.sun.source.tree.Tree yieldTree) Returns the value (expression) foryieldTree.- Parameters:
yieldTree- the yield tree- Returns:
- the value (expression) for
yieldTree
-
isVarArgs
public static boolean isVarArgs(com.sun.source.tree.Tree tree) Returns true if the given method/constructor invocation is a varargs invocation.- Parameters:
tree- a method/constructor invocation- Returns:
- true if the given method/constructor invocation is a varargs invocation
-
isVarArgs
public static boolean isVarArgs(com.sun.source.tree.MethodInvocationTree invok) Returns true if the given method invocation is a varargs invocation.- Parameters:
invok- the method invocation- Returns:
- true if the given method invocation is a varargs invocation
-
isVarArgs
public static boolean isVarArgs(com.sun.source.tree.NewClassTree newClassTree) Returns true if the given constructor invocation is a varargs invocation.- Parameters:
newClassTree- the constructor invocation- Returns:
- true if the given method invocation is a varargs invocation
-
getKindRecordAsClass
public static com.sun.source.tree.Tree.Kind getKindRecordAsClass(com.sun.source.tree.Tree tree) Calls getKind() on the given tree, but returns CLASS if the Kind is RECORD. This is needed because the Checker Framework runs on JDKs before the RECORD item was added, so RECORD can't be used in case statements, and usually we want to treat them the same as classes.- Parameters:
tree- the tree to get the kind for- Returns:
- the kind of the tree, but CLASS if the kind was RECORD
-
isBinaryComparison
public static boolean isBinaryComparison(com.sun.source.tree.BinaryTree tree) Returns true if thetreeis a binary tree that performs a comparison.- Parameters:
tree- the tree to check- Returns:
- whether the tree represents a binary comparison
-