public class TreeBuilder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected javax.lang.model.util.Elements |
elements |
protected javax.annotation.processing.ProcessingEnvironment |
env |
protected com.sun.tools.javac.code.Types |
javacTypes |
protected com.sun.tools.javac.tree.TreeMaker |
maker |
protected javax.lang.model.util.Types |
modelTypes |
protected com.sun.tools.javac.util.Names |
names |
protected com.sun.tools.javac.code.Symtab |
symtab |
Constructor and Description |
---|
TreeBuilder(javax.annotation.processing.ProcessingEnvironment env) |
Modifier and Type | Method and Description |
---|---|
com.sun.source.tree.ArrayAccessTree |
buildArrayAccess(com.sun.source.tree.ExpressionTree array,
com.sun.source.tree.ExpressionTree index)
Builds an AST Tree to dereference an array.
|
com.sun.source.tree.MemberSelectTree |
buildArrayLengthAccess(com.sun.source.tree.ExpressionTree expression)
Builds an AST Tree to dereference the length field of an array
|
com.sun.source.tree.AssignmentTree |
buildAssignment(com.sun.source.tree.ExpressionTree lhs,
com.sun.source.tree.ExpressionTree rhs)
Builds an AST Tree to assign an RHS expression to an LHS expression.
|
com.sun.source.tree.StatementTree |
buildAssignment(com.sun.source.tree.VariableTree variable,
com.sun.source.tree.ExpressionTree expr)
Builds an AST Tree to assign an expression to a variable.
|
com.sun.source.tree.BinaryTree |
buildBinary(javax.lang.model.type.TypeMirror type,
com.sun.source.tree.Tree.Kind op,
com.sun.source.tree.ExpressionTree left,
com.sun.source.tree.ExpressionTree right)
Builds an AST Tree to perform a binary operation.
|
com.sun.source.tree.IdentifierTree |
buildClassUse(javax.lang.model.element.Element elt)
Builds an AST Tree to refer to a class name.
|
com.sun.source.tree.MemberSelectTree |
buildHasNextMethodAccess(com.sun.source.tree.ExpressionTree iteratorExpr)
Builds an AST Tree to access the hasNext() method of an iterator.
|
com.sun.source.tree.MemberSelectTree |
buildIteratorMethodAccess(com.sun.source.tree.ExpressionTree iterableExpr)
Builds an AST Tree to access the iterator() method of some iterable expression.
|
com.sun.source.tree.BinaryTree |
buildLessThan(com.sun.source.tree.ExpressionTree left,
com.sun.source.tree.ExpressionTree right)
Builds an AST Tree to compare two operands with less than.
|
com.sun.source.tree.LiteralTree |
buildLiteral(java.lang.Object value)
Builds an AST Tree representing a literal value of primitive or String type.
|
com.sun.source.tree.MethodInvocationTree |
buildMethodInvocation(com.sun.source.tree.ExpressionTree methodExpr)
Builds an AST Tree to call a method designated by the argument expression.
|
com.sun.source.tree.MethodInvocationTree |
buildMethodInvocation(com.sun.source.tree.ExpressionTree methodExpr,
com.sun.source.tree.ExpressionTree argExpr)
Builds an AST Tree to call a method designated by methodExpr, with one argument designated by
argExpr.
|
com.sun.source.tree.NewArrayTree |
buildNewArray(javax.lang.model.type.TypeMirror componentType,
java.util.List<com.sun.source.tree.ExpressionTree> elems)
Builds an AST Tree to create a new array with initializers.
|
com.sun.source.tree.MemberSelectTree |
buildNextMethodAccess(com.sun.source.tree.ExpressionTree iteratorExpr)
Builds an AST Tree to access the next() method of an iterator.
|
com.sun.source.tree.MemberSelectTree |
buildPrimValueMethodAccess(com.sun.source.tree.Tree expr)
Builds an AST Tree to access the *Value() method of a boxed type such as Short or Float,
where * is the corresponding primitive type (i.e.
|
com.sun.source.tree.TypeCastTree |
buildTypeCast(javax.lang.model.type.TypeMirror type,
com.sun.source.tree.ExpressionTree expr)
Builds an AST Tree to cast the type of an expression.
|
com.sun.source.tree.MemberSelectTree |
buildValueOfMethodAccess(com.sun.source.tree.Tree expr)
Builds an AST Tree to access the valueOf() method of boxed type such as Short or Float.
|
com.sun.source.tree.VariableTree |
buildVariableDecl(com.sun.source.tree.Tree type,
java.lang.String name,
javax.lang.model.element.Element owner,
com.sun.source.tree.ExpressionTree initializer)
Builds an AST Tree to declare and initialize a variable.
|
com.sun.source.tree.VariableTree |
buildVariableDecl(javax.lang.model.type.TypeMirror type,
java.lang.String name,
javax.lang.model.element.Element owner,
com.sun.source.tree.ExpressionTree initializer)
Builds an AST Tree to declare and initialize a variable, with no modifiers.
|
com.sun.source.tree.IdentifierTree |
buildVariableUse(com.sun.source.tree.VariableTree decl)
Builds an AST Tree to refer to a variable.
|
<T extends com.sun.source.tree.Tree> |
copy(T input)
Copy an AST Tree, including types and symbols in the tree.
|
static com.sun.tools.javac.code.Symbol.MethodSymbol |
getValueOfMethod(javax.annotation.processing.ProcessingEnvironment env,
javax.lang.model.type.TypeMirror boxedType)
Returns the valueOf method of a boxed type such as Short or Float.
|
com.sun.tools.javac.tree.JCTree.Tag |
kindToTag(com.sun.source.tree.Tree.Kind kind)
Map public AST Tree.Kinds to internal javac JCTree.Tags.
|
protected final javax.lang.model.util.Elements elements
protected final javax.lang.model.util.Types modelTypes
protected final com.sun.tools.javac.code.Types javacTypes
protected final com.sun.tools.javac.tree.TreeMaker maker
protected final com.sun.tools.javac.util.Names names
protected final com.sun.tools.javac.code.Symtab symtab
protected final javax.annotation.processing.ProcessingEnvironment env
public TreeBuilder(javax.annotation.processing.ProcessingEnvironment env)
public <T extends com.sun.source.tree.Tree> T copy(T input)
input
- a tree to be copiedpublic com.sun.source.tree.MemberSelectTree buildIteratorMethodAccess(com.sun.source.tree.ExpressionTree iterableExpr)
iterableExpr
- an expression whose type is a subtype of Iterablepublic com.sun.source.tree.MemberSelectTree buildHasNextMethodAccess(com.sun.source.tree.ExpressionTree iteratorExpr)
iteratorExpr
- an expression whose type is a subtype of Iteratorpublic com.sun.source.tree.MemberSelectTree buildNextMethodAccess(com.sun.source.tree.ExpressionTree iteratorExpr)
iteratorExpr
- an expression whose type is a subtype of Iteratorpublic com.sun.source.tree.MemberSelectTree buildArrayLengthAccess(com.sun.source.tree.ExpressionTree expression)
expression
- the array expression whose length is being accessedpublic com.sun.source.tree.MethodInvocationTree buildMethodInvocation(com.sun.source.tree.ExpressionTree methodExpr)
methodExpr
- an expression denoting a method with no argumentspublic com.sun.source.tree.MethodInvocationTree buildMethodInvocation(com.sun.source.tree.ExpressionTree methodExpr, com.sun.source.tree.ExpressionTree argExpr)
methodExpr
- an expression denoting a method with one argumentargExpr
- an expression denoting an argument to the methodpublic com.sun.source.tree.VariableTree buildVariableDecl(javax.lang.model.type.TypeMirror type, java.lang.String name, javax.lang.model.element.Element owner, com.sun.source.tree.ExpressionTree initializer)
type
- the type of the variablename
- the name of the variableowner
- the element containing the new symbolinitializer
- the initializer expressionpublic com.sun.source.tree.VariableTree buildVariableDecl(com.sun.source.tree.Tree type, java.lang.String name, javax.lang.model.element.Element owner, com.sun.source.tree.ExpressionTree initializer)
type
- the type of the variable, as a Treename
- the name of the variableowner
- the element containing the new symbolinitializer
- the initializer expressionpublic com.sun.source.tree.IdentifierTree buildVariableUse(com.sun.source.tree.VariableTree decl)
decl
- the declaration of the variablepublic com.sun.source.tree.TypeCastTree buildTypeCast(javax.lang.model.type.TypeMirror type, com.sun.source.tree.ExpressionTree expr)
type
- the type to cast toexpr
- the expression to be castpublic com.sun.source.tree.StatementTree buildAssignment(com.sun.source.tree.VariableTree variable, com.sun.source.tree.ExpressionTree expr)
variable
- the declaration of the variable to assign toexpr
- the expression to be assignedpublic com.sun.source.tree.AssignmentTree buildAssignment(com.sun.source.tree.ExpressionTree lhs, com.sun.source.tree.ExpressionTree rhs)
lhs
- the expression to be assigned torhs
- the expression to be assignedpublic com.sun.source.tree.LiteralTree buildLiteral(java.lang.Object value)
public com.sun.source.tree.BinaryTree buildLessThan(com.sun.source.tree.ExpressionTree left, com.sun.source.tree.ExpressionTree right)
left
- the left operand treeright
- the right operand treepublic com.sun.source.tree.ArrayAccessTree buildArrayAccess(com.sun.source.tree.ExpressionTree array, com.sun.source.tree.ExpressionTree index)
array
- the array to dereferenceindex
- the index at which to dereferencepublic com.sun.source.tree.IdentifierTree buildClassUse(javax.lang.model.element.Element elt)
elt
- an element representing the classpublic com.sun.source.tree.MemberSelectTree buildValueOfMethodAccess(com.sun.source.tree.Tree expr)
expr
- an expression whose type is a boxed typepublic static com.sun.tools.javac.code.Symbol.MethodSymbol getValueOfMethod(javax.annotation.processing.ProcessingEnvironment env, javax.lang.model.type.TypeMirror boxedType)
public com.sun.source.tree.MemberSelectTree buildPrimValueMethodAccess(com.sun.source.tree.Tree expr)
expr
- an expression whose type is a boxed typepublic com.sun.tools.javac.tree.JCTree.Tag kindToTag(com.sun.source.tree.Tree.Kind kind)
public com.sun.source.tree.BinaryTree buildBinary(javax.lang.model.type.TypeMirror type, com.sun.source.tree.Tree.Kind op, com.sun.source.tree.ExpressionTree left, com.sun.source.tree.ExpressionTree right)
type
- result type of the operationop
- AST Tree operatorleft
- the left operand treeright
- the right operand treepublic com.sun.source.tree.NewArrayTree buildNewArray(javax.lang.model.type.TypeMirror componentType, java.util.List<com.sun.source.tree.ExpressionTree> elems)
componentType
- component type of the new arrayelems
- expression trees of initializers