APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.tree

public Class TreeInfo

extends Object
Class Inheritance
Imports
com.sun.source.tree.Tree, com.sun.source.util.TreePath, com.sun.tools.javac.code.*, .Symbol.RecordComponent, .Symbol.VarSymbol, com.sun.tools.javac.comp.Env, com.sun.tools.javac.tree.JCTree.*, com.sun.tools.javac.tree.JCTree.JCPolyExpression.*, com.sun.tools.javac.util.*, .JCDiagnostic.DiagnosticPosition, javax.lang.model.element.ElementKind, javax.tools.JavaFileObject, java.util.function.Function, .Predicate, .ToIntFunction

Utility class containing inspector methods for trees.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
TreeInfo.ConstructorCallFinder

Finds all calls to this() and/or super() in a given constructor.

private static class
public static enum
private static class
TreeInfo.SuperCallTranslator

Finds all super() invocations and translates them somehow.

private static class

Field Summary

Modifier and TypeField and Description
public static final int
addPrec

Operator precedences values.

public static final int
andPrec

Operator precedences values.

public static final int
assignopPrec

Operator precedences values.

public static final int
assignPrec

Operator precedences values.

public static final int
bitandPrec

Operator precedences values.

public static final int
bitorPrec

Operator precedences values.

public static final int
bitxorPrec

Operator precedences values.

public static final int
condPrec

Operator precedences values.

public static final int
eqPrec

Operator precedences values.

public static final int
mulPrec

Operator precedences values.

public static final int
noPrec

Operator precedences values.

public static final int
notExpression

Operator precedences values.

public static final int
ordPrec

Operator precedences values.

public static final int
orPrec

Operator precedences values.

public static final int
postfixPrec

Operator precedences values.

public static final int
precCount

Operator precedences values.

public static final int
prefixPrec

Operator precedences values.

public static final int
shiftPrec

Operator precedences values.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static List<JCTree.JCExpression>
public static Name
calledMethodName(JCTree tree)

If the expression is a method call, return the method name, null otherwise.

public static boolean
public static JCTree
declarationFor(final Symbol sym, final JCTree tree)

Find the declaration for a symbol, where that symbol is defined somewhere in the given tree.

public static JCDiagnostic.DiagnosticPosition
diagEndPos(final JCTree tree)

A DiagnosticPosition with the preferred position set to the closing brace position of given tree, if it is a block with defined closing brace position.

public static JCDiagnostic.DiagnosticPosition
diagnosticPositionFor(final Symbol sym, final JCTree tree)

Find the position for reporting an error about a symbol, where that symbol is defined somewhere in the given tree.

public static JCDiagnostic.DiagnosticPosition
diagnosticPositionFor(final Symbol sym, final JCTree tree, boolean returnNullIfNotFound)

public static JCDiagnostic.DiagnosticPosition
diagnosticPositionFor(final Symbol sym, final JCTree tree, boolean returnNullIfNotFound, Predicate<? super JCTree> filter)

public static JCDiagnostic.DiagnosticPosition
diagnosticPositionFor(final Symbol sym, final List<? extends JCTree> trees)

public static int
endPos(JCTree tree)

The closing brace position of given tree, if it is a block with defined bracePos.

public static boolean
public static int
finalizerPos(JCTree tree, TreeInfo.PosKind posKind)

The position of the finalizer of given try/synchronized statement.

public static JCTree.JCMethodInvocation
findConstructorCall(JCTree.JCMethodDecl md)

Find the first super() or init() call in the given constructor.

public static long
firstFlag(long flags)

Return first (smallest) flag in `flags': pre: flags != 0

public static int
firstStatPos(JCTree tree)

The position of the first statement in a block, or the position of the block itself if it is empty.

public static String
flagNames(long flags)

Return flags as a string, separated by " ".

public static long
flags(JCTree tree)

If this tree is a declaration or a block, return its flags field, otherwise return 0.

public static Name
fullName(JCTree tree)

If this tree is a qualified identifier, its return fully qualified name, otherwise return null.

public static String
getCommentText(Env<?> env, JCTree tree)

public static int
getEndPos(JCTree tree)

The end position of given tree, given a table of end positions generated by the parser

public static JCTree.JCModifiers
getModifiers(JCTree tree)

If this tree has a modifiers field, return it otherwise return null

public static int
getStartPos(JCTree
The tree node
tree
)

Get the start position for a tree node.

public static boolean
hasAnyConstructorCall(JCTree.JCMethodDecl tree)

Is the given method a constructor containing a super() or this() call?

public static boolean
hasConstructorCall(JCTree.JCMethodDecl tree, Name target)

Is the given method a constructor containing a super() and/or this() call?

public static boolean
hasConstructors(List<JCTree> trees)

Is there a constructor declaration in the given list of trees?

public static JCTree
innermostType(JCTree type, boolean skipAnnos)

public static boolean
public static boolean
public static boolean
public static boolean
isConstructor(JCTree tree)

Is tree a constructor declaration?

public static boolean
isConstructorCall(JCTree.JCMethodInvocation invoke)

Is the given method invocation an invocation of this(...) or super(...)?

public static boolean
public static boolean
isDiamond(JCTree tree)

Return true if a tree represents a diamond new expr.

public static boolean
public static boolean
public static boolean
isExplicitThisReference(Types types, Type.ClassType currentClass, JCTree tree)

Check if the given tree is an explicit reference to the 'this' instance of the class currently being compiled.

public static boolean
isExpressionStatement(JCTree.JCExpression tree)

Return true if the tree corresponds to an expression statement

public static boolean
isIdentOrThisDotIdent(JCTree tree)

Is this tree an identifier, possibly qualified by 'this'?

public static boolean
isInAnnotation(Env<?> env, JCTree tree)

Return true iff this tree is a child of some annotation.

public static boolean
public static boolean
public static boolean
isNull(JCTree tree)

Return true if a tree represents the null literal.

public static boolean
public static boolean
public static boolean
public static boolean
isStatement(JCTree tree)

Return true if the tree corresponds to a statement

public static boolean
isStaticSelector(JCTree base, Names names)

Return true if the AST corresponds to a static select of the kind A.B

private static boolean
public static boolean
isSuperCall(JCTree tree)

Is this a call to super?

public static boolean
isSyntheticInit(JCTree stat)

Is statement an initializer for a synthetic field?

public static boolean
isThisQualifier(JCTree tree)

Is this tree a 'this' identifier?

public static boolean
isType(JCTree base, Names names)

private static boolean
isTypeSelector(JCTree base, Names names, Predicate<JCTree> checkStaticSym)

public static void
mapSuperCalls(JCTree.JCBlock block, Function<? super JCTree.JCExpressionStatement, ? extends JCTree.JCStatement> mapper)

Finds super() invocations and translates them using the given mapping.

public static Name
name(JCTree tree)

If this tree is an identifier or a field or a parameterized type, return its name, otherwise return null.

public static boolean
nonstaticSelect(JCTree tree)

Return true if this is a nonstatic selection.

public static int
opPrec(JCTree.Tag op)

Map operators to their precedence levels.

public static int
positionFor(final Symbol sym, final JCTree tree)

Find the position for reporting an error about a symbol, where that symbol is defined somewhere in the given tree.

public static Type
public static JCTree
public static List<JCTree.JCVariableDecl>
public static List<Type>
public static JCTree
referencedStatement(JCTree.JCLabeledStatement tree)

Return the statement referenced by a label.

public static void
setPolyKind(JCTree tree, JCTree.JCPolyExpression.PolyKind pkind)

set 'polyKind' on given tree

public static void
setSymbol(JCTree tree, Symbol sym)

If this tree is an identifier or a field, set its symbol, otherwise skip.

public static void
setVarargsElement(JCTree tree, Type varargsElement)

set 'varargsElement' on given tree

public static JCTree.JCExpression
skipParens(JCTree.JCExpression tree)

Skip parens and return the enclosed expression

public static JCTree
skipParens(JCTree tree)

Skip parens and return the enclosed expression

public static Symbol
symbol(JCTree tree)

If this tree is an identifier or a field, return its symbol, otherwise return null.

public static Symbol
private static Symbol
pack-priv static Tree.Kind
public static JCTree.JCExpression
typeIn(JCTree.JCExpression tree)

Returns the underlying type of the tree if it is an annotated type, or the tree itself otherwise.

public static List<Type>
types(List<? extends JCTree> trees)

Return the types of a list of trees.

public static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait