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 |
---|---|
ArrayAccessTree |
buildArrayAccess(ExpressionTree array,
ExpressionTree index)
Builds an AST Tree to dereference an array.
|
MemberSelectTree |
buildArrayLengthAccess(ExpressionTree expression)
Builds an AST Tree to dereference the length field of an array
|
AssignmentTree |
buildAssignment(ExpressionTree lhs,
ExpressionTree rhs)
Builds an AST Tree to assign an RHS expression to an LHS expression.
|
StatementTree |
buildAssignment(VariableTree variable,
ExpressionTree expr)
Builds an AST Tree to assign an expression to a variable.
|
BinaryTree |
buildBinary(javax.lang.model.type.TypeMirror type,
Tree.Kind op,
ExpressionTree left,
ExpressionTree right)
Builds an AST Tree to perform a binary operation.
|
IdentifierTree |
buildClassUse(javax.lang.model.element.Element elt)
Builds an AST Tree to refer to a class name.
|
MemberSelectTree |
buildHasNextMethodAccess(ExpressionTree iteratorExpr)
Builds an AST Tree to access the hasNext() method of an iterator.
|
MemberSelectTree |
buildIteratorMethodAccess(ExpressionTree iterableExpr)
Builds an AST Tree to access the iterator() method of some iterable expression.
|
BinaryTree |
buildLessThan(ExpressionTree left,
ExpressionTree right)
Builds an AST Tree to compare two operands with less than.
|
LiteralTree |
buildLiteral(java.lang.Object value)
Builds an AST Tree representing a literal value of primitive or String type.
|
MethodInvocationTree |
buildMethodInvocation(ExpressionTree methodExpr)
Builds an AST Tree to call a method designated by the argument expression.
|
MethodInvocationTree |
buildMethodInvocation(ExpressionTree methodExpr,
ExpressionTree argExpr)
Builds an AST Tree to call a method designated by methodExpr, with one argument designated by
argExpr.
|
NewArrayTree |
buildNewArray(javax.lang.model.type.TypeMirror componentType,
java.util.List<ExpressionTree> elems)
Builds an AST Tree to create a new array with initializers.
|
MemberSelectTree |
buildNextMethodAccess(ExpressionTree iteratorExpr)
Builds an AST Tree to access the next() method of an iterator.
|
MemberSelectTree |
buildPrimValueMethodAccess(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.
|
TypeCastTree |
buildTypeCast(javax.lang.model.type.TypeMirror type,
ExpressionTree expr)
Builds an AST Tree to cast the type of an expression.
|
MemberSelectTree |
buildValueOfMethodAccess(Tree expr)
Builds an AST Tree to access the valueOf() method of boxed type such as Short or Float.
|
VariableTree |
buildVariableDecl(Tree type,
java.lang.String name,
javax.lang.model.element.Element owner,
ExpressionTree initializer)
Builds an AST Tree to declare and initialize a variable.
|
VariableTree |
buildVariableDecl(javax.lang.model.type.TypeMirror type,
java.lang.String name,
javax.lang.model.element.Element owner,
ExpressionTree initializer)
Builds an AST Tree to declare and initialize a variable, with no modifiers.
|
IdentifierTree |
buildVariableUse(VariableTree decl)
Builds an AST Tree to refer to a variable.
|
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(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 MemberSelectTree buildIteratorMethodAccess(ExpressionTree iterableExpr)
iterableExpr
- an expression whose type is a subtype of Iterablepublic MemberSelectTree buildHasNextMethodAccess(ExpressionTree iteratorExpr)
iteratorExpr
- an expression whose type is a subtype of Iteratorpublic MemberSelectTree buildNextMethodAccess(ExpressionTree iteratorExpr)
iteratorExpr
- an expression whose type is a subtype of Iteratorpublic MemberSelectTree buildArrayLengthAccess(ExpressionTree expression)
expression
- the array expression whose length is being accessedpublic MethodInvocationTree buildMethodInvocation(ExpressionTree methodExpr)
methodExpr
- an expression denoting a method with no argumentspublic MethodInvocationTree buildMethodInvocation(ExpressionTree methodExpr, ExpressionTree argExpr)
methodExpr
- an expression denoting a method with one argumentargExpr
- an expression denoting an argument to the methodpublic VariableTree buildVariableDecl(javax.lang.model.type.TypeMirror type, java.lang.String name, javax.lang.model.element.Element owner, ExpressionTree initializer)
type
- the type of the variablename
- the name of the variableowner
- the element containing the new symbolinitializer
- the initializer expressionpublic VariableTree buildVariableDecl(Tree type, java.lang.String name, javax.lang.model.element.Element owner, 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 IdentifierTree buildVariableUse(VariableTree decl)
decl
- the declaration of the variablepublic TypeCastTree buildTypeCast(javax.lang.model.type.TypeMirror type, ExpressionTree expr)
type
- the type to cast toexpr
- the expression to be castpublic StatementTree buildAssignment(VariableTree variable, ExpressionTree expr)
variable
- the declaration of the variable to assign toexpr
- the expression to be assignedpublic AssignmentTree buildAssignment(ExpressionTree lhs, ExpressionTree rhs)
lhs
- the expression to be assigned torhs
- the expression to be assignedpublic LiteralTree buildLiteral(java.lang.Object value)
public BinaryTree buildLessThan(ExpressionTree left, ExpressionTree right)
left
- the left operand treeright
- the right operand treepublic ArrayAccessTree buildArrayAccess(ExpressionTree array, ExpressionTree index)
array
- the array to dereferenceindex
- the index at which to dereferencepublic IdentifierTree buildClassUse(javax.lang.model.element.Element elt)
elt
- an element representing the classpublic MemberSelectTree buildValueOfMethodAccess(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 MemberSelectTree buildPrimValueMethodAccess(Tree expr)
expr
- an expression whose type is a boxed typepublic com.sun.tools.javac.tree.JCTree.Tag kindToTag(Tree.Kind kind)
public BinaryTree buildBinary(javax.lang.model.type.TypeMirror type, Tree.Kind op, ExpressionTree left, ExpressionTree right)
type
- result type of the operationop
- AST Tree operatorleft
- the left operand treeright
- the right operand treepublic NewArrayTree buildNewArray(javax.lang.model.type.TypeMirror componentType, java.util.List<ExpressionTree> elems)
componentType
- component type of the new arrayelems
- expression trees of initializers