public final class TreeMaker extends Object
CancellableTask task = new CancellableTask<WorkingCopy>() {
public void run(WorkingCopy workingCopy) throws Exception {
<b>TreeMaker make = workingCopy.getTreeMaker()</b>;
... your modification code here
}
...
};
Modifier and Type | Method and Description |
---|---|
AnnotationTree |
addAnnotationAttrValue(AnnotationTree annotation,
ExpressionTree attrValue)
Appends specified element attrValue to the end of attribute
values list.
|
BlockTree |
addBlockStatement(BlockTree block,
StatementTree statement)
Appends specified element statement to the end of statements
list.
|
CaseTree |
addCaseStatement(CaseTree kejs,
StatementTree statement)
Appends specified element statement to the end of statements
list.
|
ClassTree |
addClassImplementsClause(ClassTree clazz,
Tree implementsClause)
Appends specified element implementsClause to the end of implements
list.
|
ClassTree |
addClassMember(ClassTree clazz,
Tree member)
Appends specified element member to the end of members
list.
|
ClassTree |
addClassTypeParameter(ClassTree clazz,
TypeParameterTree typeParameter)
Appends specified element typeParameter to the end of type parameters
list.
|
void |
addComment(Tree tree,
Comment comment,
boolean preceding)
Append a comment to the list of comments attached to a given tree.
|
CompilationUnitTree |
addCompUnitImport(CompilationUnitTree compilationUnit,
ImportTree importt)
Appends specified element importt to the end of imports list.
|
CompilationUnitTree |
addCompUnitTypeDecl(CompilationUnitTree compilationUnit,
Tree typeDeclaration)
Appends specified element typeDeclaration to the end of type
declarations list.
|
ForLoopTree |
addForLoopInitializer(ForLoopTree forLoop,
StatementTree initializer)
Appends specified element initializer to the end of initializers
list.
|
ForLoopTree |
addForLoopUpdate(ForLoopTree forLoop,
ExpressionStatementTree update)
Appends specified element update to the end of updates
list.
|
LambdaExpressionTree |
addLambdaParameter(LambdaExpressionTree method,
VariableTree parameter)
Appends specified element parameter
to the end of parameters list.
|
MethodInvocationTree |
addMethodInvocationArgument(MethodInvocationTree methodInvocation,
ExpressionTree argument)
Appends specified element argument.
|
MethodInvocationTree |
addMethodInvocationTypeArgument(MethodInvocationTree methodInvocation,
ExpressionTree typeArgument)
Appends specified element type argument
to the end of type arguments list.
|
MethodTree |
addMethodParameter(MethodTree method,
VariableTree parameter)
Appends specified element parameter
to the end of parameters list.
|
MethodTree |
addMethodThrows(MethodTree method,
ExpressionTree throwz)
Appends specified element throwz to the end of throws
list.
|
MethodTree |
addMethodTypeParameter(MethodTree method,
TypeParameterTree typeParameter)
Appends specified element typeParameter
to the end of type parameters list.
|
ModifiersTree |
addModifiersAnnotation(ModifiersTree modifiers,
AnnotationTree annotation)
Appends specified element annotation to the end of annotations
list.
|
ModifiersTree |
addModifiersModifier(ModifiersTree modifiers,
Modifier modifier) |
ModuleTree |
addModuleDirective(ModuleTree modle,
DirectiveTree directive)
Appends specified directive to the end of directives list.
|
NewArrayTree |
addNewArrayDimension(NewArrayTree newArray,
ExpressionTree dimension)
Appends specified element dimension to the end of dimensions
list.
|
NewArrayTree |
addNewArrayInitializer(NewArrayTree newArray,
ExpressionTree initializer)
Appends specified element initializer to the end of initializers
list.
|
NewClassTree |
addNewClassArgument(NewClassTree newClass,
ExpressionTree argument)
Appends specified element argument
to the end of arguments list.
|
NewClassTree |
addNewClassTypeArgument(NewClassTree newClass,
ExpressionTree typeArgument)
Appends specified element typeArgument
to the end of type arguments list.
|
CompilationUnitTree |
addPackageAnnotation(CompilationUnitTree cut,
AnnotationTree annotation)
Appends specified element annotation to the end of package annotations
list.
|
ParameterizedTypeTree |
addParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType,
ExpressionTree argument)
Appends specified element argument to the end of type arguments
list.
|
SwitchTree |
addSwitchCase(SwitchTree swic,
CaseTree kejs)
Appends specified element kejs to the end of cases
list.
|
TryTree |
addTryCatch(TryTree traj,
CatchTree kec)
Appends specified element kec to the end of catches
list.
|
TypeParameterTree |
addTypeParameterBound(TypeParameterTree typeParameter,
ExpressionTree bound)
Appends specified element bound to the end of bounds
list.
|
AnnotationTree |
Annotation(Tree type,
List<? extends ExpressionTree> arguments)
Creates a new AnnotationTree.
|
ClassTree |
AnnotationType(ModifiersTree modifiers,
CharSequence simpleName,
List<? extends Tree> memberDecls)
Creates a new ClassTree representing annotation type.
|
ArrayAccessTree |
ArrayAccess(ExpressionTree array,
ExpressionTree index)
Creates a new ArrayAccessTree.
|
ArrayTypeTree |
ArrayType(Tree type)
Creates a new ArrayTypeTree.
|
<T extends Tree> |
asNew(T tree)
Marks the tree as new.
|
<T extends Tree> |
asRemoved(T tree)
Marks the tree as removed.
|
<T extends Tree> |
asReplacementOf(T treeNew,
Tree treeOld)
Marks a tree as a replacement of some old one.
|
<T extends Tree> |
asReplacementOf(T treeNew,
Tree treeOld,
boolean defaultOnly)
Marks a tree as a replacement of some old one.
|
AssertTree |
Assert(ExpressionTree condition,
ExpressionTree detail)
Creates a new AssertTree.
|
AssignmentTree |
Assignment(ExpressionTree variable,
ExpressionTree expression)
Creates a new AssignmentTree.
|
com.sun.source.doctree.AttributeTree |
Attribute(CharSequence name,
com.sun.source.doctree.AttributeTree.ValueKind vkind,
List<? extends com.sun.source.doctree.DocTree> value)
Creates the DocTree's HTML AttributeTree.
|
com.sun.source.doctree.AuthorTree |
Author(List<? extends com.sun.source.doctree.DocTree> name)
Creates the DocTree's AuthorTree.
|
BinaryTree |
Binary(Tree.Kind operator,
ExpressionTree left,
ExpressionTree right)
Creates a new BinaryTree.
|
Tree |
BindingPattern(CharSequence name,
Tree type)
Deprecated.
|
Tree |
BindingPattern(VariableTree vt)
Creates a new Tree for a given VariableTree
specication : 15.20.2
|
BlockTree |
Block(List<? extends StatementTree> statements,
boolean isStatic)
Creates a new BlockTree.
|
BreakTree |
Break(CharSequence label)
Creates a new BreakTree.
|
CaseTree |
Case(ExpressionTree expression,
List<? extends StatementTree> statements)
Creates a new CaseTree.
|
CaseTree |
Case(List<? extends ExpressionTree> patterns,
Tree body)
Creates a new CaseTree for a rule case (case <constants> -> <body>).
|
CaseTree |
CaseMultipleLabels(List<? extends ExpressionTree> patterns,
List<? extends StatementTree> statements)
Creates a new CaseTree.
|
CaseTree |
CasePatterns(List<? extends Tree> patterns,
ExpressionTree guard,
List<? extends StatementTree> statements)
Creates a new CaseTree.
|
CaseTree |
CasePatterns(List<? extends Tree> patterns,
ExpressionTree guard,
Tree body)
Creates a new CaseTree for a rule case (case <constants> -> <body>).
|
CaseTree |
CasePatterns(List<? extends Tree> patterns,
List<? extends StatementTree> statements)
Creates a new CaseTree.
|
CaseTree |
CasePatterns(List<? extends Tree> patterns,
Tree body)
Creates a new CaseTree for a rule case (case <constants> -> <body>).
|
CatchTree |
Catch(VariableTree parameter,
BlockTree block)
Creates a new CatchTree.
|
ClassTree |
Class(ModifiersTree modifiers,
CharSequence simpleName,
List<? extends TypeParameterTree> typeParameters,
Tree extendsClause,
List<? extends Tree> implementsClauses,
List<? extends Tree> memberDecls)
Creates a new ClassTree.
|
com.sun.source.doctree.LiteralTree |
Code(com.sun.source.doctree.TextTree text)
Creates the DocTree's LiteralTree for a verbatim code.
|
com.sun.source.doctree.CommentTree |
Comment(String text)
Creates the DocTree's HTML CommentTree.
|
CompilationUnitTree |
CompilationUnit(ExpressionTree packageName,
List<? extends ImportTree> imports,
List<? extends Tree> typeDeclarations,
JavaFileObject sourceFile)
Creates a new CompilationUnitTree.
|
CompilationUnitTree |
CompilationUnit(FileObject sourceRoot,
String path,
List<? extends ImportTree> imports,
List<? extends Tree> typeDeclarations)
Creates a new CompilationUnitTree.
|
CompilationUnitTree |
CompilationUnit(List<? extends AnnotationTree> packageAnnotations,
ExpressionTree packageName,
List<? extends ImportTree> imports,
List<? extends Tree> typeDeclarations,
JavaFileObject sourceFile)
Creates a new CompilationUnitTree.
|
CompilationUnitTree |
CompilationUnit(List<? extends AnnotationTree> packageAnnotations,
FileObject sourceRoot,
String path,
List<? extends ImportTree> imports,
List<? extends Tree> typeDeclarations)
Creates a new CompilationUnitTree.
|
CompilationUnitTree |
CompilationUnit(PackageTree pkg,
List<? extends ImportTree> imports,
List<? extends Tree> typeDeclarations,
JavaFileObject sourceFile)
Creates a new CompilationUnitTree.
|
CompoundAssignmentTree |
CompoundAssignment(Tree.Kind operator,
ExpressionTree variable,
ExpressionTree expression)
Creates a new CompoundAssignmentTree.
|
ConditionalExpressionTree |
ConditionalExpression(ExpressionTree condition,
ExpressionTree trueExpression,
ExpressionTree falseExpression)
Creates a new ConditionalExpressionTree.
|
MethodTree |
Constructor(ModifiersTree modifiers,
List<? extends TypeParameterTree> typeParameters,
List<? extends VariableTree> parameters,
List<? extends ExpressionTree> throwsList,
BlockTree body)
Creates a new MethodTree representing constructor.
|
MethodTree |
Constructor(ModifiersTree modifiers,
List<? extends TypeParameterTree> typeParameters,
List<? extends VariableTree> parameters,
List<? extends ExpressionTree> throwsList,
String bodyText)
Creates a new MethodTree representing constructor.
|
ContinueTree |
Continue(CharSequence label)
Creates a new ContinueTree.
|
BlockTree |
createLambdaBody(LambdaExpressionTree lambda,
String bodyText)
Creates a new BlockTree for provided bodyText.
|
ExpressionTree |
createLambdaExpression(LambdaExpressionTree lambda,
String bodyText)
Creates a new ExpressionTree for provided bodyText.
|
BlockTree |
createMethodBody(MethodTree method,
String bodyText)
Creates a new BlockTree for provided bodyText.
|
com.sun.source.doctree.DeprecatedTree |
Deprecated(List<? extends com.sun.source.doctree.DocTree> text)
Creates the DocTree's DeprecatedTree.
|
com.sun.source.doctree.DocCommentTree |
DocComment(List<? extends com.sun.source.doctree.DocTree> fullBody,
List<? extends com.sun.source.doctree.DocTree> tags)
Creates a new javadoc comment.
|
com.sun.source.doctree.DocCommentTree |
DocComment(List<? extends com.sun.source.doctree.DocTree> firstSentence,
List<? extends com.sun.source.doctree.DocTree> body,
List<? extends com.sun.source.doctree.DocTree> tags)
Creates a new javadoc comment.
|
com.sun.source.doctree.IdentifierTree |
DocIdentifier(CharSequence name)
Creates the DocTree's IdentifierTree.
|
com.sun.source.doctree.LiteralTree |
DocLiteral(com.sun.source.doctree.TextTree text)
Creates the DocTree's LiteralTree.
|
com.sun.source.doctree.ReturnTree |
DocReturn(List<? extends com.sun.source.doctree.DocTree> description)
Creates the DocTree's ReturnTree.
|
com.sun.source.doctree.DocRootTree |
DocRoot()
Creates the DocTree's DocRootTree.
|
DoWhileLoopTree |
DoWhileLoop(ExpressionTree condition,
StatementTree statement)
Creates a new DoWhileLoopTree.
|
EmptyStatementTree |
EmptyStatement()
Creates a new EmptyStatementTree.
|
com.sun.source.doctree.EndElementTree |
EndElement(CharSequence name)
Creates the DocTree's HTML EndElementTree.
|
EnhancedForLoopTree |
EnhancedForLoop(VariableTree variable,
ExpressionTree expression,
StatementTree statement)
Creates a new EnhancedForLoopTree.
|
com.sun.source.doctree.EntityTree |
Entity(CharSequence name)
Creates the DocTree's HTML EntityTree.
|
ClassTree |
Enum(ModifiersTree modifiers,
CharSequence simpleName,
List<? extends Tree> implementsClauses,
List<? extends Tree> memberDecls)
Creates a new ClassTree representing enum.
|
ErroneousTree |
Erroneous(List<? extends Tree> errorTrees)
Creates a new ErroneousTree.
|
com.sun.source.doctree.ThrowsTree |
Exception(com.sun.source.doctree.ReferenceTree name,
List<? extends com.sun.source.doctree.DocTree> description)
Creates the DocTree's ThrowsTree that will produce @exception.
|
ExportsTree |
Exports(ExpressionTree qualId,
List<? extends ExpressionTree> moduleNames)
Creates a new ExportsTree.
|
ExpressionStatementTree |
ExpressionStatement(ExpressionTree expression)
Creates a new ExpressionStatementTree.
|
ForLoopTree |
ForLoop(List<? extends StatementTree> initializer,
ExpressionTree condition,
List<? extends ExpressionStatementTree> update,
StatementTree statement)
Creates a new ForLoopTree.
|
IdentifierTree |
Identifier(CharSequence name)
Creates a new IdentifierTree.
|
IdentifierTree |
Identifier(Element element)
Creates a new IdentifierTree from an Element.
|
IfTree |
If(ExpressionTree condition,
StatementTree thenStatement,
StatementTree elseStatement)
Creates a new IfTree.
|
ImportTree |
Import(Tree qualid,
boolean importStatic)
Creates a new ImportTree.
|
com.sun.source.doctree.InheritDocTree |
InheritDoc()
Creates the DocTree's InheritDocTree.
|
AnnotationTree |
insertAnnotationAttrValue(AnnotationTree annotation,
int index,
ExpressionTree attrValue)
Inserts the specified element attrValue at the specified
position in attribute values list.
|
BlockTree |
insertBlockStatement(BlockTree block,
int index,
StatementTree statement)
Inserts the specified element statement at the specified
position in statements list.
|
CaseTree |
insertCaseStatement(CaseTree kejs,
int index,
StatementTree statement)
Inserts the specified element statement at the specified
position in statements list.
|
ClassTree |
insertClassImplementsClause(ClassTree clazz,
int index,
Tree implementsClause)
Inserts the specified element implementsClause at the specified
position in implements list.
|
ClassTree |
insertClassMember(ClassTree clazz,
int index,
Tree member)
Inserts the specified element member at the specified
position in members list.
|
ClassTree |
insertClassTypeParameter(ClassTree clazz,
int index,
TypeParameterTree typeParameter)
Inserts the specified element member at the specified
position in type parameters list.
|
void |
insertComment(Tree tree,
Comment comment,
int index,
boolean preceding)
Insert a comment to the list of comments attached to a given tree (to a specified position).
|
CompilationUnitTree |
insertCompUnitImport(CompilationUnitTree compilationUnit,
int index,
ImportTree importt)
Inserts the specified element importt at the specified
position in imports list.
|
CompilationUnitTree |
insertCompUnitTypeDecl(CompilationUnitTree compilationUnit,
int index,
Tree typeDeclaration)
Inserts the specified element typeDeclaration at the specified
position in type declarations list.
|
ForLoopTree |
insertForLoopInitializer(ForLoopTree forLoop,
int index,
StatementTree initializer)
Inserts the specified element initializer at the specified
position in initializers list.
|
ForLoopTree |
insertForLoopUpdate(ForLoopTree forLoop,
int index,
ExpressionStatementTree update)
Inserts the specified element update at the specified
position in updates list.
|
LambdaExpressionTree |
insertLambdaParameter(LambdaExpressionTree method,
int index,
VariableTree parameter)
Inserts the specified element parameter
at the specified position in parameters list.
|
MethodInvocationTree |
insertMethodInvocationArgument(MethodInvocationTree methodInvocation,
int index,
ExpressionTree argument)
Inserts the specified element argument.
|
MethodInvocationTree |
insertMethodInvocationTypeArgument(MethodInvocationTree methodInvocation,
int index,
ExpressionTree typeArgument)
Inserts the specified element typeArgument
at the specified position in type arguments list.
|
MethodTree |
insertMethodParameter(MethodTree method,
int index,
VariableTree parameter)
Inserts the specified element parameter
at the specified position in parameters list.
|
MethodTree |
insertMethodThrows(MethodTree method,
int index,
ExpressionTree throwz)
Inserts the specified element throws at the specified
position in throws list.
|
MethodTree |
insertMethodTypeParameter(MethodTree method,
int index,
TypeParameterTree typeParameter)
Inserts the specified element typeParameter
at the specified position in type parameters list.
|
ModifiersTree |
insertModifiersAnnotation(ModifiersTree modifiers,
int index,
AnnotationTree annotation)
Inserts the specified element annotation at the specified
position in annotations list.
|
ModuleTree |
insertModuleDirective(ModuleTree modle,
int index,
DirectiveTree directive)
Inserts the specified directive at the specified position
in directives list.
|
NewArrayTree |
insertNewArrayDimension(NewArrayTree newArray,
int index,
ExpressionTree dimension)
Inserts the specified element dimension at the specified
position in dimensions list.
|
NewArrayTree |
insertNewArrayInitializer(NewArrayTree newArray,
int index,
ExpressionTree initializer)
Inserts the specified element initializer at the specified
position in initializers list.
|
NewClassTree |
insertNewClassArgument(NewClassTree newClass,
int index,
ExpressionTree argument)
Inserts the specified element argument
at the specified position in type arguments list.
|
NewClassTree |
insertNewClassTypeArgument(NewClassTree newClass,
int index,
ExpressionTree typeArgument)
Inserts the specified element typeArgument
at the specified position in type arguments list.
|
CompilationUnitTree |
insertPackageAnnotation(CompilationUnitTree cut,
int index,
AnnotationTree annotation)
Inserts the specified element annotation at the specified
position in package annotations list.
|
ParameterizedTypeTree |
insertParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType,
int index,
ExpressionTree argument)
Inserts the specified element argument at the specified
position in type arguments list.
|
SwitchTree |
insertSwitchCase(SwitchTree swic,
int index,
CaseTree kejs)
Inserts the specified element kejs at the specified
position in cases list.
|
TryTree |
insertTryCatch(TryTree traj,
int index,
CatchTree kec)
Inserts the specified element kec at the specified
position in catches list.
|
TypeParameterTree |
insertTypeParameterBound(TypeParameterTree typeParameter,
int index,
ExpressionTree bound)
Inserts the specified element bound at the specified
position in bounds list.
|
InstanceOfTree |
InstanceOf(ExpressionTree expression,
Tree type)
Creates a new InstanceOfTree.
|
ClassTree |
Interface(ModifiersTree modifiers,
CharSequence simpleName,
List<? extends TypeParameterTree> typeParameters,
List<? extends Tree> extendsClauses,
List<? extends Tree> memberDecls)
Creates a new ClassTree representing interface.
|
LabeledStatementTree |
LabeledStatement(CharSequence label,
StatementTree statement)
Creates a new LabeledStatementTree.
|
LambdaExpressionTree |
LambdaExpression(List<? extends VariableTree> parameters,
Tree body)
Creates a new LambdaExpressionTree
|
com.sun.source.doctree.LinkTree |
Link(com.sun.source.doctree.ReferenceTree ref,
List<? extends com.sun.source.doctree.DocTree> label)
Creates the DocTree's LinkTree.
|
com.sun.source.doctree.LinkTree |
LinkPlain(com.sun.source.doctree.ReferenceTree ref,
List<? extends com.sun.source.doctree.DocTree> label)
Creates the DocTree's LinkTree for
@linkplain . |
LiteralTree |
Literal(Object value)
Creates a new LiteralTree.
|
MemberReferenceTree |
MemberReference(MemberReferenceTree.ReferenceMode refMode,
ExpressionTree expression,
CharSequence name,
List<? extends ExpressionTree> typeArguments)
Creates a new MemberReferenceTree.
|
MemberSelectTree |
MemberSelect(ExpressionTree expression,
CharSequence identifier)
Creates a new MemberSelectTree.
|
MemberSelectTree |
MemberSelect(ExpressionTree expression,
Element element)
Creates a new MemberSelectTree from an expression and an element.
|
MethodTree |
Method(ExecutableElement element,
BlockTree body)
Deprecated.
this method produces different output than usually expected -
use one of the other "Method" methods in this class or
GeneratorUtilities . |
MethodTree |
Method(ModifiersTree modifiers,
CharSequence name,
Tree returnType,
List<? extends TypeParameterTree> typeParameters,
List<? extends VariableTree> parameters,
List<? extends ExpressionTree> throwsList,
BlockTree body,
ExpressionTree defaultValue)
Creates a new MethodTree.
|
MethodTree |
Method(ModifiersTree modifiers,
CharSequence name,
Tree returnType,
List<? extends TypeParameterTree> typeParameters,
List<? extends VariableTree> parameters,
List<? extends ExpressionTree> throwsList,
BlockTree body,
ExpressionTree defaultValue,
boolean isVarArg)
Creates a new MethodTree.
|
MethodTree |
Method(ModifiersTree modifiers,
CharSequence name,
Tree returnType,
List<? extends TypeParameterTree> typeParameters,
List<? extends VariableTree> parameters,
List<? extends ExpressionTree> throwsList,
String bodyText,
ExpressionTree defaultValue)
Creates a new MethodTree.
|
MethodInvocationTree |
MethodInvocation(List<? extends ExpressionTree> typeArguments,
ExpressionTree method,
List<? extends ExpressionTree> arguments)
Creates a new MethodInvocationTree.
|
ModifiersTree |
Modifiers(long flags,
List<? extends AnnotationTree> annotations)
Creates a new ModifiersTree with a new flags and annotation.
|
ModifiersTree |
Modifiers(ModifiersTree oldMods,
List<? extends AnnotationTree> annotations)
Creates a new ModifiersTree with a new set of annotations.
|
ModifiersTree |
Modifiers(Set<Modifier> flags)
Creates a new ModifiersTree without any annotations specified.
|
ModifiersTree |
Modifiers(Set<Modifier> flags,
List<? extends AnnotationTree> annotations)
Creates a new ModifiersTree with a new set of flags and annotations.
|
ModuleTree |
Module(ModifiersTree modifiers,
ModuleTree.ModuleKind kind,
ExpressionTree qualid,
List<? extends DirectiveTree> directives)
Creates a new ModuleTree with a new qualified name and directives.
|
NewArrayTree |
NewArray(Tree elemtype,
List<? extends ExpressionTree> dimensions,
List<? extends ExpressionTree> initializers)
Creates a new NewArrayTree.
|
NewClassTree |
NewClass(ExpressionTree enclosingExpression,
List<? extends ExpressionTree> typeArguments,
ExpressionTree identifier,
List<? extends ExpressionTree> arguments,
ClassTree classBody)
Creates a new NewClassTree.
|
OpensTree |
Opens(ExpressionTree qualId,
List<? extends ExpressionTree> moduleNames)
Creates a new OpensTree.
|
com.sun.source.doctree.ParamTree |
Param(boolean isTypeParameter,
com.sun.source.doctree.IdentifierTree name,
List<? extends com.sun.source.doctree.DocTree> description)
Creates the DocTree's ParamTree.
|
ParameterizedTypeTree |
ParameterizedType(Tree type,
List<? extends Tree> typeArguments)
Creates a new ParameterizedTypeTree.
|
ParenthesizedTree |
Parenthesized(ExpressionTree expression)
Creates a new ParenthesizedTree.
|
PrimitiveTypeTree |
PrimitiveType(TypeKind typekind)
Creates a new PrimitiveTypeTree.
|
ProvidesTree |
Provides(ExpressionTree serviceName,
List<? extends ExpressionTree> implNames)
Creates a new ProvidesTree.
|
ExpressionTree |
QualIdent(Element element)
Creates a qualified identifier from an element.
|
ExpressionTree |
QualIdent(String name)
Creates a qualified identifier for a given String.
|
VariableTree |
RecordComponent(ModifiersTree modifiers,
CharSequence name,
Tree type)
Creates a new VariableTree for a record component.
|
DeconstructionPatternTree |
RecordPattern(ExpressionTree deconstructor,
List<PatternTree> nested,
VariableTree vt)
Creates a new Tree for a given DeconstructionPatternTree
|
com.sun.source.doctree.ReferenceTree |
Reference(ExpressionTree qualExpr,
CharSequence member,
List<? extends Tree> paramTypes)
Creates the DocTree's ReferenceTree.
|
AnnotationTree |
removeAnnotationAttrValue(AnnotationTree annotation,
ExpressionTree attrValue)
Removes the first occurrence in attribute values list of the specified
element.
|
AnnotationTree |
removeAnnotationAttrValue(AnnotationTree annotation,
int index)
Removes the element at the specified position in attribute values list.
|
BlockTree |
removeBlockStatement(BlockTree block,
int index)
Removes the element at the specified position in statements list.
|
BlockTree |
removeBlockStatement(BlockTree block,
StatementTree statement)
Removes the first occurrence in statements list of the specified
element.
|
CaseTree |
removeCaseStatement(CaseTree kejs,
int index)
Removes the element at the specified position in statements list.
|
CaseTree |
removeCaseStatement(CaseTree kejs,
StatementTree statement)
Removes the first occurrence in statements list of the specified
element.
|
ClassTree |
removeClassImplementsClause(ClassTree clazz,
int index)
Removes the element at the specified position in implements list.
|
ClassTree |
removeClassImplementsClause(ClassTree clazz,
Tree implementsClause)
Removes the first occurrence in implements list of the specified
element.
|
ClassTree |
removeClassMember(ClassTree clazz,
int index)
Removes the element at the specified position in members list.
|
ClassTree |
removeClassMember(ClassTree clazz,
Tree member)
Removes the first occurrence in members list of the specified
element.
|
ClassTree |
removeClassTypeParameter(ClassTree clazz,
int index)
Removes the element at the specified position in type parameters list.
|
ClassTree |
removeClassTypeParameter(ClassTree clazz,
TypeParameterTree typeParameter)
Removes the first occurrence in type parameters list of the specified
element.
|
void |
removeComment(Tree tree,
int index,
boolean preceding)
Remove a comment from the list of comments attached to a given tree.
|
CompilationUnitTree |
removeCompUnitImport(CompilationUnitTree compilationUnit,
ImportTree importt)
Removes the first occurrence in imports list of the specified
element.
|
CompilationUnitTree |
removeCompUnitImport(CompilationUnitTree compilationUnit,
int index)
Removes the element at the specified position in import list.
|
CompilationUnitTree |
removeCompUnitTypeDecl(CompilationUnitTree compilationUnit,
int index)
Removes the element at the specified position in type declarations list.
|
CompilationUnitTree |
removeCompUnitTypeDecl(CompilationUnitTree compilationUnit,
Tree typeDeclaration)
Removes the first occurrence in type declarations list of the specified
element.
|
ForLoopTree |
removeForLoopInitializer(ForLoopTree forLoop,
int index)
Removes the element at the specified position in initializers list.
|
ForLoopTree |
removeForLoopInitializer(ForLoopTree forLoop,
StatementTree initializer)
Removes the first occurrence in initializers list of the specified
element.
|
ForLoopTree |
removeForLoopUpdate(ForLoopTree forLoop,
ExpressionStatementTree update)
Removes the first occurrence in updates list of the specified
element.
|
ForLoopTree |
removeForLoopUpdate(ForLoopTree forLoop,
int index)
Removes the element at the specified position in updates list.
|
LambdaExpressionTree |
removeLambdaParameter(LambdaExpressionTree method,
int index)
Removes the element at the specified position in parameters list.
|
LambdaExpressionTree |
removeLambdaParameter(LambdaExpressionTree method,
VariableTree parameter)
Removes the first occurrence in parameters list of the specified
elements.
|
MethodInvocationTree |
removeMethodInvocationArgument(MethodInvocationTree methodInvocation,
ExpressionTree argument)
Removes the first occurrence in arguments list of the specified
element.
|
MethodInvocationTree |
removeMethodInvocationArgument(MethodInvocationTree methodInvocation,
int index)
Removes the element at the specified position in arguments
list.
|
MethodInvocationTree |
removeMethodInvocationTypeArgument(MethodInvocationTree methodInvocation,
ExpressionTree typeArgument)
Removes the first occurrence in type arguments list of the specified
elements.
|
MethodInvocationTree |
removeMethodInvocationTypeArgument(MethodInvocationTree methodInvocation,
int index)
Removes the element at the specified position in type arguments.
|
MethodTree |
removeMethodParameter(MethodTree method,
int index)
Removes the element at the specified position in parameters list.
|
MethodTree |
removeMethodParameter(MethodTree method,
VariableTree parameter)
Removes the first occurrence in parameters list of the specified
elements.
|
MethodTree |
removeMethodThrows(MethodTree method,
ExpressionTree throwz)
Removes the first occurrence in throws list of the specified
element.
|
MethodTree |
removeMethodThrows(MethodTree method,
int index)
Removes the element at the specified position in throws list.
|
MethodTree |
removeMethodTypeParameter(MethodTree method,
int index)
Removes the element at the specified position in type parameters list.
|
MethodTree |
removeMethodTypeParameter(MethodTree method,
TypeParameterTree typeParameter)
Removes the first occurrence in type parameters list of the specified
elements.
|
ModifiersTree |
removeModifiersAnnotation(ModifiersTree modifiers,
AnnotationTree annotation)
Removes the first occurrence in annotations list of the specified
element.
|
ModifiersTree |
removeModifiersAnnotation(ModifiersTree modifiers,
int index)
Removes the element at the specified position in annotations list.
|
ModifiersTree |
removeModifiersModifier(ModifiersTree modifiers,
Modifier modifier) |
ModuleTree |
removeModuleDirective(ModuleTree modle,
DirectiveTree directive)
Removes the first occurrence in directives list of the specified
directive.
|
ModuleTree |
removeModuleDirective(ModuleTree modle,
int index)
Removes the directive at the specified position in directives list.
|
NewArrayTree |
removeNewArrayDimension(NewArrayTree newArray,
ExpressionTree dimension)
Removes the first occurrence in dimensions list of the specified
element.
|
NewArrayTree |
removeNewArrayDimension(NewArrayTree newArray,
int index)
Removes the element at the specified position in dimensions list.
|
NewArrayTree |
removeNewArrayInitializer(NewArrayTree newArray,
ExpressionTree initializer)
Removes the first occurrence in initializers list of the specified
element.
|
NewArrayTree |
removeNewArrayInitializer(NewArrayTree newArray,
int index)
Removes the element at the specified position in initializers list.
|
NewClassTree |
removeNewClassArgument(NewClassTree newClass,
ExpressionTree argument)
Removes the first occurrence in arguments of the specified elements.
|
NewClassTree |
removeNewClassArgument(NewClassTree newClass,
int index)
Removes the element at the specified position in arguments
list.
|
NewClassTree |
removeNewClassTypeArgument(NewClassTree newClass,
ExpressionTree typeArgument)
Removes the first occurrence in type arguments list of the specified elements.
|
NewClassTree |
removeNewClassTypeArgument(NewClassTree newClass,
int index)
Removes the element at the specified position in type arguments
list.
|
CompilationUnitTree |
removePackageAnnotation(CompilationUnitTree cut,
AnnotationTree annotation)
Removes the first occurrence in package annotations list of the specified
element.
|
CompilationUnitTree |
removePackageAnnotation(CompilationUnitTree cut,
int index)
Removes the element at the specified position in package annotations list.
|
ParameterizedTypeTree |
removeParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType,
ExpressionTree argument)
Removes the first occurrence in type arguments list of the specified
element.
|
ParameterizedTypeTree |
removeParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType,
int index)
Removes the element at the specified position in type arguments list.
|
SwitchTree |
removeSwitchCase(SwitchTree swic,
CaseTree kejs)
Removes the first occurrence in cases list of the specified
element.
|
SwitchTree |
removeSwitchCase(SwitchTree swic,
int index)
Removes the element at the specified position in cases list.
|
TryTree |
removeTryCatch(TryTree traj,
CatchTree kec)
Removes the first occurrence in catches list of the specified
element.
|
TryTree |
removeTryCatch(TryTree traj,
int index)
Removes the element at the specified position in catches list.
|
TypeParameterTree |
removeTypeParameterBound(TypeParameterTree typeParameter,
ExpressionTree bound)
Removes the first occurrence in bounds list of the specified
element.
|
TypeParameterTree |
removeTypeParameterBound(TypeParameterTree typeParameter,
int index)
Removes the element at the specified position in bounds list.
|
RequiresTree |
Requires(boolean isTransitive,
boolean isStatic,
ExpressionTree qualId)
Creates a new RequiresTree.
|
ReturnTree |
Return(ExpressionTree expression)
Creates a new ReturnTree.
|
com.sun.source.doctree.SeeTree |
See(List<? extends com.sun.source.doctree.DocTree> reference)
Creates the DocTree's SeeTree.
|
com.sun.source.doctree.SerialTree |
Serial(List<? extends com.sun.source.doctree.DocTree> description)
Creates the DocTree's SerialTree.
|
com.sun.source.doctree.SerialDataTree |
SerialData(List<? extends com.sun.source.doctree.DocTree> description)
Creates the DocTree's SerialDataTree.
|
com.sun.source.doctree.SerialFieldTree |
SerialField(com.sun.source.doctree.IdentifierTree name,
com.sun.source.doctree.ReferenceTree type,
List<? extends com.sun.source.doctree.DocTree> description)
Creates the DocTree's SerialFieldTree.
|
ClassTree |
setExtends(ClassTree node,
ExpressionTree extendz)
Replaces extends clause in class declaration.
|
<N extends Tree> |
setInitialValue(N node,
ExpressionTree initializer)
Replaces initializer in appropriate element.
|
<N extends Tree> |
setLabel(N node,
CharSequence aLabel)
Replaces the original node's label with new one provided in
aLabel argument.
|
LambdaExpressionTree |
setLambdaBody(LambdaExpressionTree method,
Tree newBody)
Creates a new lambda expression as a copy of the given lambda expression
with the specified body.
|
com.sun.source.doctree.SinceTree |
Since(List<? extends com.sun.source.doctree.DocTree> text)
Creates the DocTree's SinceTree.
|
com.sun.source.doctree.StartElementTree |
StartElement(CharSequence name,
List<? extends com.sun.source.doctree.DocTree> attrs,
boolean selfClosing)
Creates the DocTree's HTML StartElementTree.
|
SwitchTree |
Switch(ExpressionTree expression,
List<? extends CaseTree> cases)
Creates a new SwitchTree.
|
Tree |
SwitchExpression(ExpressionTree expression,
List<? extends CaseTree> cases)
Creates a new SwitchExpressionTree.
|
SynchronizedTree |
Synchronized(ExpressionTree expression,
BlockTree block)
Creates a new SynchronizedTree.
|
com.sun.source.doctree.TextTree |
Text(String text)
Creates the DocTree's TextTree.
|
ThrowTree |
Throw(ExpressionTree expression)
Creates a new ThrowTree.
|
com.sun.source.doctree.ThrowsTree |
Throws(com.sun.source.doctree.ReferenceTree name,
List<? extends com.sun.source.doctree.DocTree> description)
Creates the DocTree's ThrowsTree that will produce @throws.
|
TryTree |
Try(BlockTree tryBlock,
List<? extends CatchTree> catches,
BlockTree finallyBlock)
Creates a new TryTree.
|
TryTree |
Try(List<? extends Tree> resources,
BlockTree tryBlock,
List<? extends CatchTree> catches,
BlockTree finallyBlock)
Creates a new TryTree.
|
Tree |
Type(String type)
Creates a new Tree for a given String type specification.
|
Tree |
Type(TypeMirror type)
Creates a new Tree for a given TypeMirror.
|
AnnotationTree |
TypeAnnotation(Tree type,
List<? extends ExpressionTree> arguments)
Creates a new type AnnotationTree.
|
TypeCastTree |
TypeCast(Tree type,
ExpressionTree expression)
Creates a new TypeCastTree.
|
TypeParameterTree |
TypeParameter(CharSequence name,
List<? extends ExpressionTree> bounds)
Creates a new TypeParameterTree.
|
UnaryTree |
Unary(Tree.Kind operator,
ExpressionTree arg)
Creates a new UnaryTree.
|
UnionTypeTree |
UnionType(List<? extends Tree> typeComponents)
Creates new UnionTypeTree.
|
com.sun.source.doctree.UnknownBlockTagTree |
UnknownBlockTag(CharSequence name,
List<? extends com.sun.source.doctree.DocTree> content)
Creates the DocTree's UnknownBlockTagTree.
|
com.sun.source.doctree.UnknownInlineTagTree |
UnknownInlineTag(CharSequence name,
List<? extends com.sun.source.doctree.DocTree> content)
Creates the DocTree's UnknownInlineTagTree.
|
UsesTree |
Uses(ExpressionTree qualId)
Creates a new UsesTree.
|
com.sun.source.doctree.ValueTree |
Value(com.sun.source.doctree.ReferenceTree ref)
Creates the DocTree's ValueTree.
|
VariableTree |
Variable(ModifiersTree modifiers,
CharSequence name,
Tree type,
ExpressionTree initializer)
Creates a new VariableTree.
|
VariableTree |
Variable(VariableElement variable,
ExpressionTree initializer)
Creates a new VariableTree from a VariableElement.
|
com.sun.source.doctree.VersionTree |
Version(List<? extends com.sun.source.doctree.DocTree> text)
Creates the DocTree's VersionTree.
|
WhileLoopTree |
WhileLoop(ExpressionTree condition,
StatementTree statement)
Creates a new WhileLoopTree.
|
WildcardTree |
Wildcard(Tree.Kind kind,
Tree type)
Creates a new WildcardTree.
|
public AnnotationTree Annotation(Tree type, List<? extends ExpressionTree> arguments)
type
- the annotation type.arguments
- the arguments for this annotation, or an empty list.AnnotationTree
public AnnotationTree TypeAnnotation(Tree type, List<? extends ExpressionTree> arguments)
type
- the annotation type.arguments
- the arguments for this annotation, or an empty list.AnnotationTree
public ArrayAccessTree ArrayAccess(ExpressionTree array, ExpressionTree index)
array
- the array expression.index
- the array index.ArrayAccessTree
public ArrayTypeTree ArrayType(Tree type)
type
- the array type.ArrayTypeTree
public AssertTree Assert(ExpressionTree condition, ExpressionTree detail)
condition
- the boolean expression to test.detail
- the detail message to include if the assertion fails.AssertTree
public AssignmentTree Assignment(ExpressionTree variable, ExpressionTree expression)
variable
- the variable the expression is assigned to.expression
- the expression to assign to the variable.AssignmentTree
public BinaryTree Binary(Tree.Kind operator, ExpressionTree left, ExpressionTree right)
operator
- the operator for this tree, such as Tree.Kind.PLUS.left
- the left operand of the tree.right
- the right operand of the tree.BinaryTree
,
Tree.Kind
public BlockTree Block(List<? extends StatementTree> statements, boolean isStatic)
statements
- the list of statements to be contained within the block.isStatic
- true if the block defines a static initializer for a class. ExpressionTree getCondition();
ExpressionTree getDetail();BlockTree
public BreakTree Break(CharSequence label)
label
- the label to break to, or null if there is no label.BreakTree
public CaseTree Case(ExpressionTree expression, List<? extends StatementTree> statements)
expression
- the label for this case statement.statements
- the list of statements.CaseTree
public CaseTree CaseMultipleLabels(List<? extends ExpressionTree> patterns, List<? extends StatementTree> statements)
patterns
- the labels for this case statement.statements
- the list of statements.CaseTree
public CaseTree Case(List<? extends ExpressionTree> patterns, Tree body)
patterns
- the labels for this case statement.body
- the case's bodyCaseTree
public CaseTree CasePatterns(List<? extends Tree> patterns, Tree body)
patterns
- the labels for this case statement.body
- the case's bodyCaseTree
public CaseTree CasePatterns(List<? extends Tree> patterns, ExpressionTree guard, Tree body)
patterns
- the labels for this case statement.guard
- the case's guardbody
- the case's bodyCaseTree
public CaseTree CasePatterns(List<? extends Tree> patterns, List<? extends StatementTree> statements)
patterns
- the labels for this case statement.statements
- the list of statements.CaseTree
public CaseTree CasePatterns(List<? extends Tree> patterns, ExpressionTree guard, List<? extends StatementTree> statements)
patterns
- the labels for this case statement.guard
- the case's guardstatements
- the list of statements.CaseTree
public CatchTree Catch(VariableTree parameter, BlockTree block)
parameter
- the exception variable declaration.block
- the block of statements executed by this catch statement.CatchTree
public ClassTree Class(ModifiersTree modifiers, CharSequence simpleName, List<? extends TypeParameterTree> typeParameters, Tree extendsClause, List<? extends Tree> implementsClauses, List<? extends Tree> memberDecls)
modifiers
- the modifiers declarationsimpleName
- the name of the class without its package, such
as "String" for the class "java.lang.String".typeParameters
- the list of type parameters, or an empty list.extendsClause
- the name of the class this class extends, or null.implementsClauses
- the list of the interfaces this class
implements, or an empty list.memberDecls
- the list of fields defined by this class, or an
empty list.ClassTree
public ClassTree Interface(ModifiersTree modifiers, CharSequence simpleName, List<? extends TypeParameterTree> typeParameters, List<? extends Tree> extendsClauses, List<? extends Tree> memberDecls)
modifiers
- the modifiers declarationsimpleName
- the name of the class without its package, such
as "String" for the class "java.lang.String".typeParameters
- the list of type parameters, or an empty list.extendsClauses
- the list of the interfaces this class
extends, or an empty list.memberDecls
- the list of fields defined by this class, or an
empty list.ClassTree
public ClassTree AnnotationType(ModifiersTree modifiers, CharSequence simpleName, List<? extends Tree> memberDecls)
modifiers
- the modifiers declarationsimpleName
- the name of the class without its package, such
as "String" for the class "java.lang.String".memberDecls
- the list of fields defined by this class, or an
empty list.ClassTree
public ClassTree Enum(ModifiersTree modifiers, CharSequence simpleName, List<? extends Tree> implementsClauses, List<? extends Tree> memberDecls)
modifiers
- the modifiers declarationsimpleName
- the name of the class without its package, such
as "String" for the class "java.lang.String".implementsClauses
- the list of the interfaces this class
implements, or an empty list.memberDecls
- the list of fields defined by this class, or an
empty list.ClassTree
public CompilationUnitTree CompilationUnit(ExpressionTree packageName, List<? extends ImportTree> imports, List<? extends Tree> typeDeclarations, JavaFileObject sourceFile)
packageName
- a tree representing the package name.imports
- a list of import statements.typeDeclarations
- a list of type (class, interface or enum) declarations.sourceFile
- the source file associated with this compilation unit.CompilationUnitTree
public CompilationUnitTree CompilationUnit(List<? extends AnnotationTree> packageAnnotations, ExpressionTree packageName, List<? extends ImportTree> imports, List<? extends Tree> typeDeclarations, JavaFileObject sourceFile)
packageAnnotations
- package annotationspackageName
- a tree representing the package name.imports
- a list of import statements.typeDeclarations
- a list of type (class, interface or enum) declarations.sourceFile
- the source file associated with this compilation unit.CompilationUnitTree
public CompilationUnitTree CompilationUnit(PackageTree pkg, List<? extends ImportTree> imports, List<? extends Tree> typeDeclarations, JavaFileObject sourceFile)
pkg
- a tree representing the package statement.imports
- a list of import statements.typeDeclarations
- a list of type (class, interface or enum) declarations.sourceFile
- the source file associated with this compilation unit.CompilationUnitTree
public CompilationUnitTree CompilationUnit(FileObject sourceRoot, String path, List<? extends ImportTree> imports, List<? extends Tree> typeDeclarations)
sourceRoot
- a source root under which the new file is createdpath
- a relative path to file separated by '/'imports
- a list of import statements.typeDeclarations
- a list of type (class, interface or enum) declarations.CompilationUnitTree
public CompilationUnitTree CompilationUnit(List<? extends AnnotationTree> packageAnnotations, FileObject sourceRoot, String path, List<? extends ImportTree> imports, List<? extends Tree> typeDeclarations)
packageAnnotations
- package annotationssourceRoot
- a source root under which the new file is createdpath
- a relative path to file separated by '/'imports
- a list of import statements.typeDeclarations
- a list of type (class, interface or enum) declarations.CompilationUnitTree
public CompoundAssignmentTree CompoundAssignment(Tree.Kind operator, ExpressionTree variable, ExpressionTree expression)
operator
- the operator for this tree, such as Tree.Kind.PLUS_ASSIGNMENT.variable
- the variable the expression is assigned to.expression
- the expression to assign to the variable.CompoundAssignmentTree
public ConditionalExpressionTree ConditionalExpression(ExpressionTree condition, ExpressionTree trueExpression, ExpressionTree falseExpression)
condition
- the boolean expression to test.trueExpression
- the expression to be executed when the
condition is true.falseExpression
- the expression to be executed when the
condition is false.ConditionalExpressionTree
public MethodTree Constructor(ModifiersTree modifiers, List<? extends TypeParameterTree> typeParameters, List<? extends VariableTree> parameters, List<? extends ExpressionTree> throwsList, BlockTree body)
modifiers
- the modifiers of this method.typeParameters
- the list of generic type parameters, or an empty list.parameters
- the list of parameters, or an empty list.throwsList
- the list of throws clauses, or an empty list.body
- the method's code block.MethodTree
public MethodTree Constructor(ModifiersTree modifiers, List<? extends TypeParameterTree> typeParameters, List<? extends VariableTree> parameters, List<? extends ExpressionTree> throwsList, String bodyText)
modifiers
- the modifiers of this method.typeParameters
- the list of generic type parameters, or an empty list.parameters
- the list of parameters, or an empty list.throwsList
- the list of throws clauses, or an empty list.bodyText
- the method's code block provided as a plain textMethodTree
public ContinueTree Continue(CharSequence label)
label
- the label to break to, or null if there is no label.ContinueTree
public UnionTypeTree UnionType(List<? extends Tree> typeComponents)
typeComponents
- components from which the DisjunctiveTypeTree should be created.
The components should either be ExpressionTree
(qualified or unqualified identifier),
PrimitiveTypeTree
, WildcardTree
, ParameterizedTypeTree
or ArrayTypeTree
.public DoWhileLoopTree DoWhileLoop(ExpressionTree condition, StatementTree statement)
condition
- the boolean expression to test.statement
- the statement to execute while the condition is true.DoWhileLoopTree
public EmptyStatementTree EmptyStatement()
EmptyStatementTree
public EnhancedForLoopTree EnhancedForLoop(VariableTree variable, ExpressionTree expression, StatementTree statement)
variable
- the loop variable declaration.expression
- the expression to be iterated.statement
- the statement to execute each iteration.EnhancedForLoopTree
public ErroneousTree Erroneous(List<? extends Tree> errorTrees)
errorTrees
- a list of trees with possible errors.ErroneousTree
public ExportsTree Exports(ExpressionTree qualId, List<? extends ExpressionTree> moduleNames)
qualId
- qualified name of the exported package.moduleNames
- names of the modules the package is exported to.ExportsTree
public ExpressionStatementTree ExpressionStatement(ExpressionTree expression)
expression
- the expression body for this statement.ExpressionStatementTree
public ForLoopTree ForLoop(List<? extends StatementTree> initializer, ExpressionTree condition, List<? extends ExpressionStatementTree> update, StatementTree statement)
initializer
- a list of initializer statements, or an empty list.condition
- the condition to evaluate after each iteration.update
- the statements to execute after each iteration.statement
- the statement to execute for each iteration.ForLoopTree
public IdentifierTree Identifier(CharSequence name)
name
exactly as passed to this method. No checks will be performed on the given name
.
Imports won't we resolved for fully qualified names. Consider using TreeMaker.QualIdent(Element)
,
TreeMaker.QualIdent(String)
, TreeMaker.Type(String)
or TreeMaker.Type(TypeMirror)
to
get automatically resolved imports for fully qualified names or types.name
- the name of the identifier.IdentifierTree
,
TreeMaker.QualIdent(Element)
,
TreeMaker.QualIdent(String)
,
TreeMaker.Type(String)
,
TreeMaker.Type(TypeMirror)
public IdentifierTree Identifier(Element element)
element
- the element from which to extract the identifier name.IdentifierTree
,
Element
public IfTree If(ExpressionTree condition, StatementTree thenStatement, StatementTree elseStatement)
condition
- the boolean expression to test.thenStatement
- the statement to execute if the condition is true.elseStatement
- the statement to execute if the condition if false.
A null value should be used if there is no else
statement.IfTree
public ImportTree Import(Tree qualid, boolean importStatic)
qualid
- fully qualified identifier.importStatic
- true if static import statement.ImportTree
public InstanceOfTree InstanceOf(ExpressionTree expression, Tree type)
expression
- the expression whose type is being checked.type
- the type to compare to.InstanceOfTree
public LabeledStatementTree LabeledStatement(CharSequence label, StatementTree statement)
label
- the label string.statement
- the statement being labeled.LabeledStatementTree
public LambdaExpressionTree LambdaExpression(List<? extends VariableTree> parameters, Tree body)
parameters
- the lambda's formal argumentsbody
- the lambda's bodypublic LiteralTree Literal(Object value)
value
- the value of the literal.IllegalArgumentException
- for illegal literal values.LiteralTree
public MemberReferenceTree MemberReference(MemberReferenceTree.ReferenceMode refMode, ExpressionTree expression, CharSequence name, List<? extends ExpressionTree> typeArguments)
refMode
- the desired reference mode
expression
- the class (or expression), from which a member is to be referencedname
- the name of the referenced membertypeArguments
- the reference's type argumentspublic MemberSelectTree MemberSelect(ExpressionTree expression, CharSequence identifier)
expression
- the expression the identifier is part of.identifier
- the element to select.MemberSelectTree
public MemberSelectTree MemberSelect(ExpressionTree expression, Element element)
expression
- the expression the identifier is part of.element
- the element that provides the identifier name.MemberSelectTree
,
Element
public MethodInvocationTree MethodInvocation(List<? extends ExpressionTree> typeArguments, ExpressionTree method, List<? extends ExpressionTree> arguments)
typeArguments
- the list of generic type arguments, or an empty list.method
- the method to be invoked.arguments
- the list of arguments to pass to the method, or an empty list.MethodInvocationTree
public MethodTree Method(ModifiersTree modifiers, CharSequence name, Tree returnType, List<? extends TypeParameterTree> typeParameters, List<? extends VariableTree> parameters, List<? extends ExpressionTree> throwsList, BlockTree body, ExpressionTree defaultValue)
modifiers
- the modifiers of this method.name
- the name of the method.returnType
- the return type for this method.typeParameters
- the list of generic type parameters, or an empty list.parameters
- the list of parameters, or an empty list.throwsList
- the list of throws clauses, or an empty list.body
- the method's code block.defaultValue
- the default value, used by annotation types.MethodTree
public MethodTree Method(ModifiersTree modifiers, CharSequence name, Tree returnType, List<? extends TypeParameterTree> typeParameters, List<? extends VariableTree> parameters, List<? extends ExpressionTree> throwsList, BlockTree body, ExpressionTree defaultValue, boolean isVarArg)
modifiers
- the modifiers of this method.name
- the name of the method.returnType
- the return type for this method.typeParameters
- the list of generic type parameters, or an empty list.parameters
- the list of parameters, or an empty list.throwsList
- the list of throws clauses, or an empty list.body
- the method's code block.defaultValue
- the default value, used by annotation types.isVarArg
- true if this method has variable number of parameters.MethodTree
@Deprecated public MethodTree Method(ExecutableElement element, BlockTree body)
GeneratorUtilities
.element
- the executable element of this method.body
- the method's code block, or null for native, abstract,
and interface methods.MethodTree
,
ExecutableElement
public ModuleTree Module(ModifiersTree modifiers, ModuleTree.ModuleKind kind, ExpressionTree qualid, List<? extends DirectiveTree> directives)
modifiers
- module modifierskind
- module kindqualid
- module namedirectives
- a list of module directives, or an empty list.ModuleTree
public ModifiersTree Modifiers(Set<Modifier> flags, List<? extends AnnotationTree> annotations)
flags
- the set of modifier flagsannotations
- a list of annotations, or an empty list.ModifiersTree
,
Modifier
public ModifiersTree Modifiers(long flags, List<? extends AnnotationTree> annotations)
flags
- modifier flagsModifiersTree
public ModifiersTree Modifiers(Set<Modifier> flags)
flags
- the set of modifier flagsModifiersTree
,
Modifier
public ModifiersTree Modifiers(ModifiersTree oldMods, List<? extends AnnotationTree> annotations)
oldMods
- the old ModifiersTree, from which the flags are copied.annotations
- a list of annotations, or an empty list.ModifiersTree
,
Modifier
public NewArrayTree NewArray(Tree elemtype, List<? extends ExpressionTree> dimensions, List<? extends ExpressionTree> initializers)
elemtype
- the element type.dimensions
- the list of array dimensions.initializers
- the list of initializer statements, or an empty list.NewArrayTree
public NewClassTree NewClass(ExpressionTree enclosingExpression, List<? extends ExpressionTree> typeArguments, ExpressionTree identifier, List<? extends ExpressionTree> arguments, ClassTree classBody)
enclosingExpression
- the enclosing expression, or null.typeArguments
- the list of generic type arguments, or an empty list.identifier
- the class name expressionarguments
- the list of constructor arguments, or an empty list.classBody
- the class definition, or null if there is no definition.NewClassTree
public OpensTree Opens(ExpressionTree qualId, List<? extends ExpressionTree> moduleNames)
qualId
- qualified name of the opened package.moduleNames
- names of the modules the package is opened to.OpensTree
public ParameterizedTypeTree ParameterizedType(Tree type, List<? extends Tree> typeArguments)
type
- the generic typetypeArguments
- the list of generic type arguments, or an empty list.ParameterizedTypeTree
public ParenthesizedTree Parenthesized(ExpressionTree expression)
expression
- the expression within the parentheses.ParenthesizedTree
@NonNull public PrimitiveTypeTree PrimitiveType(@NonNull TypeKind typekind)
typekind
- the primitive type.PrimitiveTypeTree
,
TypeKind
public ProvidesTree Provides(ExpressionTree serviceName, List<? extends ExpressionTree> implNames)
serviceName
- the name of the provided serviceimplNames
- the names of the implementation classesProvidesTree
public RequiresTree Requires(boolean isTransitive, boolean isStatic, ExpressionTree qualId)
isTransitive
- isStatic
- qualId
- the qualified name of the required moduleRequiresTree
@NonNull public ExpressionTree QualIdent(@NonNull Element element)
element
- the element to use.@NonNull public ExpressionTree QualIdent(@NonNull String name)
name
- FQN for which to create the QualIdentpublic ReturnTree Return(ExpressionTree expression)
expression
- the expression to be returned.ReturnTree
public SwitchTree Switch(ExpressionTree expression, List<? extends CaseTree> cases)
expression
- the expression which provides the value to be switched.cases
- the list of cases, or an empty list.SwitchTree
public Tree SwitchExpression(ExpressionTree expression, List<? extends CaseTree> cases)
expression
- the expression which provides the value to be switched.cases
- the list of cases, or an empty list.SwitchExpressionTree
public SynchronizedTree Synchronized(ExpressionTree expression, BlockTree block)
expression
- the expression defining the object being synchronized.block
- the block of statements executed by this statement.SynchronizedTree
public ThrowTree Throw(ExpressionTree expression)
expression
- the exception to be thrown.ThrowTree
public TryTree Try(BlockTree tryBlock, List<? extends CatchTree> catches, BlockTree finallyBlock)
tryBlock
- the statement block in the try clause.catches
- the list of catch clauses, or an empty list.finallyBlock
- the finally clause, or null.TryTree
public TryTree Try(List<? extends Tree> resources, BlockTree tryBlock, List<? extends CatchTree> catches, BlockTree finallyBlock)
resources
- the resources of the try clause. The elements of the list
should either be VariableTree
s or ExpressionTree
s.tryBlock
- the statement block in the try clause.catches
- the list of catch clauses, or an empty list.finallyBlock
- the finally clause, or null.TryTree
@NonNull public Tree Type(@NonNull TypeMirror type)
type
- TypeMirror for which a Tree should be createdExpressionTree
@NonNull public Tree Type(@NonNull String type)
type
- String type specificationExpressionTree
public TypeCastTree TypeCast(Tree type, ExpressionTree expression)
type
- the class or interface to cast.expression
- the expression being cast.TypeCastTree
public TypeParameterTree TypeParameter(CharSequence name, List<? extends ExpressionTree> bounds)
name
- the name of this type parameter.bounds
- the bounds of this parameter.TypeParameterTree
public UnaryTree Unary(Tree.Kind operator, ExpressionTree arg)
public UsesTree Uses(ExpressionTree qualId)
qualId
- qualified service name.UsesTree
public VariableTree Variable(ModifiersTree modifiers, CharSequence name, Tree type, ExpressionTree initializer)
modifiers
- the modifiers of this variable.name
- the name of the variable.type
- the type of this variable.initializer
- the initialization expression for this variable, or null.VariableTree
public VariableTree RecordComponent(ModifiersTree modifiers, CharSequence name, Tree type)
modifiers
- the modifiers of this record component.name
- the name of the record component.type
- the type of this record component.VariableTree
@Deprecated public Tree BindingPattern(CharSequence name, Tree type)
name
- name of the binding variabletype
- the type of the patternpublic Tree BindingPattern(VariableTree vt)
vt
- the VariableTree of the patternBindingPatternTree
public DeconstructionPatternTree RecordPattern(ExpressionTree deconstructor, List<PatternTree> nested, VariableTree vt)
deconstructor
- deconstructor of record patternnested
- list of nested patternsvt
- the variable of record pattern. This parameter is currently ignored.DeconstructionPatternTree
public VariableTree Variable(VariableElement variable, ExpressionTree initializer)
variable
- the VariableElement to reference.initializer
- the initialization expression, or null.VariableTree
,
VariableElement
public WhileLoopTree WhileLoop(ExpressionTree condition, StatementTree statement)
condition
- the boolean expression to test.statement
- the statement to execute while the condition is true.WhileLoopTree
public WildcardTree Wildcard(Tree.Kind kind, Tree type)
kind
- the kind of wildcard to create.type
- the type (class, interface or enum) of this wildcard.WildcardTree
public AnnotationTree addAnnotationAttrValue(AnnotationTree annotation, ExpressionTree attrValue)
annotation
- annotation tree containing attribute values list.attrValue
- element to be appended to attribute values list.public AnnotationTree insertAnnotationAttrValue(AnnotationTree annotation, int index, ExpressionTree attrValue)
annotation
- annotation tree with attribute values list.index
- index at which the specified element is to be inserted.attrValue
- element to be inserted to attribute values list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public AnnotationTree removeAnnotationAttrValue(AnnotationTree annotation, ExpressionTree attrValue)
annotation
- annotation tree with attribute values list.attrValue
- element to be removed from this list, if present.public AnnotationTree removeAnnotationAttrValue(AnnotationTree annotation, int index)
annotation
- annotation tree with attribute values list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public BlockTree addBlockStatement(BlockTree block, StatementTree statement)
block
- block tree containing statements list.statement
- element to be appended to statements list.public BlockTree insertBlockStatement(BlockTree block, int index, StatementTree statement)
block
- block tree with statements listindex
- index at which the specified element is to be inserted.statement
- element to be inserted to statements list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public BlockTree removeBlockStatement(BlockTree block, StatementTree statement)
block
- block tree with statements liststatement
- element to be removed from this list, if present.public BlockTree removeBlockStatement(BlockTree block, int index)
block
- block tree with statements listindex
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public CaseTree addCaseStatement(CaseTree kejs, StatementTree statement)
kejs
- case tree containing statements list.statement
- element to be appended to statements list.public CaseTree insertCaseStatement(CaseTree kejs, int index, StatementTree statement)
kejs
- case tree containing statements list.index
- index at which the specified element is to be inserted.statement
- element to be inserted to statements list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public CaseTree removeCaseStatement(CaseTree kejs, StatementTree statement)
kejs
- case tree containing statements list.statement
- element to be removed from this list, if present.public CaseTree removeCaseStatement(CaseTree kejs, int index)
kejs
- case tree containing statements list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public ModuleTree addModuleDirective(ModuleTree modle, DirectiveTree directive)
modle
- module tree with directives listdirective
- directive to be added to the listpublic ModuleTree insertModuleDirective(ModuleTree modle, int index, DirectiveTree directive)
modle
- module tree with directives listindex
- index at which the specified directive is to be inserted.directive
- directive to be inserted to the list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public ModuleTree removeModuleDirective(ModuleTree modle, DirectiveTree directive)
modle
- module tree with directives listdirective
- directive to be removed from this list, if present.public ModuleTree removeModuleDirective(ModuleTree modle, int index)
modle
- module tree with directives list.index
- the index of the directive to be removed.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public ClassTree addClassMember(ClassTree clazz, Tree member)
public void newlyCreatedMethod(int a, float b) throws java.io.IOException { }You can get it e.g. with this code:
TreeMaker make = workingCopy.getTreeMaker();
ClassTree node = ...;
// create method modifiers
ModifiersTree parMods = make.Modifiers(Collections.EMPTY_SET, Collections.EMPTY_LIST);
// create parameters
VariableTree par1 = make.Variable(parMods, "a", make.PrimitiveType(TypeKind.INT), null);
VariableTree par2 = make.Variable(parMods, "b", make.PrimitiveType(TypeKind.FLOAT), null);
List<VariableTree> parList = new ArrayList<VariableTree>(2);
parList.add(par1);
parList.add(par2);
// create method
MethodTree newMethod = make.Method(
make.Modifiers(
Collections.singleton(Modifier.PUBLIC), // modifiers
Collections.EMPTY_LIST // annotations
), // modifiers and annotations
"newlyCreatedMethod", // name
make.PrimitiveType(TypeKind.VOID), // return type
Collections.EMPTY_LIST, // type parameters for parameters
parList, // parameters
Collections.singletonList(make.Identifier("java.io.IOException")), // throws
make.Block(Collections.EMPTY_LIST, false), // empty statement block
null // default value - not applicable here, used by annotations
);
// rewrite the original class node with the new one containing newMethod
workingCopy.rewrite(node, <b>make.addClassMember(node, newMethod)</b>);
clazz
- class tree containing members list.member
- element to be appended to members list.public ClassTree insertClassMember(ClassTree clazz, int index, Tree member)
clazz
- class tree with members listindex
- index at which the specified element is to be inserted.member
- element to be inserted to members list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public ClassTree removeClassMember(ClassTree clazz, Tree member)
clazz
- class tree with members listmember
- element to be removed from this list, if present.public ClassTree removeClassMember(ClassTree clazz, int index)
clazz
- class tree with members list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public ClassTree addClassTypeParameter(ClassTree clazz, TypeParameterTree typeParameter)
clazz
- class tree containing type parameters list.typeParameter
- element to be appended to type parameters list.public ClassTree insertClassTypeParameter(ClassTree clazz, int index, TypeParameterTree typeParameter)
clazz
- class tree with type parameters listindex
- index at which the specified element is to be inserted.typeParameter
- element to be inserted to type parameters list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public ClassTree removeClassTypeParameter(ClassTree clazz, TypeParameterTree typeParameter)
clazz
- class tree with type parameters listtypeParameter
- element to be removed from this list, if present.public ClassTree removeClassTypeParameter(ClassTree clazz, int index)
clazz
- class tree with type parameters list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public ClassTree addClassImplementsClause(ClassTree clazz, Tree implementsClause)
clazz
- class tree containing implements list.implementsClause
- element to be appended to implements list.public ClassTree insertClassImplementsClause(ClassTree clazz, int index, Tree implementsClause)
clazz
- class tree with implements listindex
- index at which the specified element is to be inserted.implementsClause
- element to be inserted to implements list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public ClassTree removeClassImplementsClause(ClassTree clazz, Tree implementsClause)
clazz
- class tree with implements listimplementsClause
- element to be removed from this list, if present.public ClassTree removeClassImplementsClause(ClassTree clazz, int index)
clazz
- class tree with implements list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public CompilationUnitTree addCompUnitTypeDecl(CompilationUnitTree compilationUnit, Tree typeDeclaration)
compilationUnit
- compilation unit tree containing type declarations list.typeDeclaration
- element to be appended to type declarations list.public CompilationUnitTree insertCompUnitTypeDecl(CompilationUnitTree compilationUnit, int index, Tree typeDeclaration)
compilationUnit
- compilation unit tree containing type declarations list.index
- index at which the specified element is to be inserted.typeDeclaration
- element to be inserted to type declarations list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public CompilationUnitTree removeCompUnitTypeDecl(CompilationUnitTree compilationUnit, Tree typeDeclaration)
compilationUnit
- compilation unit tree containing type declarations list.typeDeclaration
- element to be removed from this list, if present.public CompilationUnitTree removeCompUnitTypeDecl(CompilationUnitTree compilationUnit, int index)
compilationUnit
- compilation unit tree containing type declarations list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public CompilationUnitTree addCompUnitImport(CompilationUnitTree compilationUnit, ImportTree importt)
compilationUnit
- compilation unit tree containing imports list.importt
- element to be appended to list of imports.public CompilationUnitTree insertCompUnitImport(CompilationUnitTree compilationUnit, int index, ImportTree importt)
compilationUnit
- compilation unit tree containing imports list.index
- index at which the specified element is to be inserted.importt
- element to be inserted to list of imports.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public CompilationUnitTree removeCompUnitImport(CompilationUnitTree compilationUnit, ImportTree importt)
compilationUnit
- compilation unit tree containing import list.importt
- element to be removed from this list, if present.public CompilationUnitTree removeCompUnitImport(CompilationUnitTree compilationUnit, int index)
compilationUnit
- compilation unit tree containing import list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public CompilationUnitTree addPackageAnnotation(CompilationUnitTree cut, AnnotationTree annotation)
cut
- compilation unit tree containing package annotations list.annotation
- element to be appended to annotations list.public CompilationUnitTree insertPackageAnnotation(CompilationUnitTree cut, int index, AnnotationTree annotation)
cut
- compilation unit tree containing package annotations list.index
- index at which the specified element is to be inserted.annotation
- element to be inserted to the package annotations list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public CompilationUnitTree removePackageAnnotation(CompilationUnitTree cut, AnnotationTree annotation)
cut
- compilation unit tree containing package annotations list.annotation
- element to be removed from this list, if present.public CompilationUnitTree removePackageAnnotation(CompilationUnitTree cut, int index)
cut
- compilation unit tree containing package annotations list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public ForLoopTree addForLoopInitializer(ForLoopTree forLoop, StatementTree initializer)
forLoop
- for loop tree containing initializers list.initializer
- element to be appended to initializers list.public ForLoopTree insertForLoopInitializer(ForLoopTree forLoop, int index, StatementTree initializer)
forLoop
- for loop tree containing initializers list.index
- index at which the specified element is to be inserted.initializer
- element to be inserted to initializers list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public ForLoopTree removeForLoopInitializer(ForLoopTree forLoop, StatementTree initializer)
forLoop
- for loop tree containing initializers list.initializer
- element to be removed from this list, if present.public ForLoopTree removeForLoopInitializer(ForLoopTree forLoop, int index)
forLoop
- for loop tree containing initializers list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public ForLoopTree addForLoopUpdate(ForLoopTree forLoop, ExpressionStatementTree update)
forLoop
- for loop tree containing updates list.update
- element to be appended to updates list.public ForLoopTree insertForLoopUpdate(ForLoopTree forLoop, int index, ExpressionStatementTree update)
forLoop
- for loop tree containing updates list.index
- index at which the specified element is to be inserted.update
- element to be inserted to updates list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public ForLoopTree removeForLoopUpdate(ForLoopTree forLoop, ExpressionStatementTree update)
forLoop
- for loop tree containing updates list.update
- element to be removed from this list, if present.public ForLoopTree removeForLoopUpdate(ForLoopTree forLoop, int index)
forLoop
- for loop tree containing updates list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public MethodInvocationTree addMethodInvocationArgument(MethodInvocationTree methodInvocation, ExpressionTree argument)
methodInvocation
- method invocation tree containing arguments list.argument
- element to be appended to arguments list.public MethodInvocationTree insertMethodInvocationArgument(MethodInvocationTree methodInvocation, int index, ExpressionTree argument)
methodInvocation
- method invocation tree containing arguments list.index
- index at which the specified elements is to be inserted.argument
- element to be inserted to arguments list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public MethodInvocationTree removeMethodInvocationArgument(MethodInvocationTree methodInvocation, ExpressionTree argument)
methodInvocation
- method invocation tree containing arguments list.argument
- element to be removed from this list, if present.public MethodInvocationTree removeMethodInvocationArgument(MethodInvocationTree methodInvocation, int index)
methodInvocation
- method invocation tree containing arguments list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public MethodInvocationTree addMethodInvocationTypeArgument(MethodInvocationTree methodInvocation, ExpressionTree typeArgument)
methodInvocation
- method invocation tree containing arguments list.typeArgument
- element to be appended to type arguments list.public MethodInvocationTree insertMethodInvocationTypeArgument(MethodInvocationTree methodInvocation, int index, ExpressionTree typeArgument)
methodInvocation
- method invocation tree containing arguments list.index
- index at which the specified elements is to be inserted.typeArgument
- element to be inserted to type arguments list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public MethodInvocationTree removeMethodInvocationTypeArgument(MethodInvocationTree methodInvocation, ExpressionTree typeArgument)
methodInvocation
- method invocation tree containing arguments list.typeArgument
- element to be removed from this list, if present.public MethodInvocationTree removeMethodInvocationTypeArgument(MethodInvocationTree methodInvocation, int index)
methodInvocation
- method invocation tree containing arguments list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public MethodTree addMethodParameter(MethodTree method, VariableTree parameter)
method
- method tree containing parameters list.parameter
- element to be appended to parameters list.public MethodTree insertMethodParameter(MethodTree method, int index, VariableTree parameter)
method
- method tree containing parameters list.index
- index at which the specified elements is to be inserted.parameter
- element to be inserted to parameters list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public MethodTree removeMethodParameter(MethodTree method, VariableTree parameter)
method
- method tree containing parameters list.parameter
- element to be removed from this list, if present.public MethodTree removeMethodParameter(MethodTree method, int index)
method
- method tree containing parameters list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public MethodTree addMethodTypeParameter(MethodTree method, TypeParameterTree typeParameter)
method
- method tree containing type parameters list.typeParameter
- element to be appended to type parameters list.public MethodTree insertMethodTypeParameter(MethodTree method, int index, TypeParameterTree typeParameter)
method
- method tree containing parameters list.index
- index at which the specified elements is to be inserted.typeParameter
- element to be inserted to type parameters list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public MethodTree removeMethodTypeParameter(MethodTree method, TypeParameterTree typeParameter)
method
- method tree containing type parameters list.typeParameter
- element to be removed from this list, if present.public MethodTree removeMethodTypeParameter(MethodTree method, int index)
method
- method tree containing type parameters list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public MethodTree addMethodThrows(MethodTree method, ExpressionTree throwz)
method
- method tree containing throws list.throwz
- element to be appended to throws list.public MethodTree insertMethodThrows(MethodTree method, int index, ExpressionTree throwz)
method
- method tree containing throws list.index
- index at which the specified element is to be inserted.throwz
- element to be inserted to throws list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public MethodTree removeMethodThrows(MethodTree method, ExpressionTree throwz)
method
- method tree containing throws list.throwz
- element to be removed from this list, if present.public MethodTree removeMethodThrows(MethodTree method, int index)
method
- method tree containing throws list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public ModifiersTree addModifiersAnnotation(ModifiersTree modifiers, AnnotationTree annotation)
modifiers
- modifiers tree containing annotations list.annotation
- element to be appended to annotations list.public ModifiersTree insertModifiersAnnotation(ModifiersTree modifiers, int index, AnnotationTree annotation)
modifiers
- modifiers tree containing annotations list.index
- index at which the specified element is to be inserted.annotation
- element to be inserted to annotations list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public ModifiersTree removeModifiersAnnotation(ModifiersTree modifiers, AnnotationTree annotation)
modifiers
- modifiers tree containing annotations list.annotation
- element to be removed from this list, if present.public ModifiersTree removeModifiersAnnotation(ModifiersTree modifiers, int index)
modifiers
- modifiers tree containing annotations list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public ModifiersTree addModifiersModifier(ModifiersTree modifiers, Modifier modifier)
public ModifiersTree removeModifiersModifier(ModifiersTree modifiers, Modifier modifier)
public NewArrayTree addNewArrayDimension(NewArrayTree newArray, ExpressionTree dimension)
newArray
- new array tree containing dimensions list.dimension
- element to be appended to dimensions list.public NewArrayTree insertNewArrayDimension(NewArrayTree newArray, int index, ExpressionTree dimension)
newArray
- new array tree containing dimensions list.index
- index at which the specified element is to be inserted.dimension
- element to be inserted to dimensions list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public NewArrayTree removeNewArrayDimension(NewArrayTree newArray, ExpressionTree dimension)
newArray
- new array tree containing dimensions list.dimension
- element to be removed from this list, if present.public NewArrayTree removeNewArrayDimension(NewArrayTree newArray, int index)
newArray
- new array tree containing dimensions list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public NewArrayTree addNewArrayInitializer(NewArrayTree newArray, ExpressionTree initializer)
newArray
- new array tree containing initializers list.initializer
- element to be appended to initializers list.public NewArrayTree insertNewArrayInitializer(NewArrayTree newArray, int index, ExpressionTree initializer)
newArray
- new array tree containing initializers list.index
- index at which the specified element is to be inserted.initializer
- element to be inserted to initializers list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public NewArrayTree removeNewArrayInitializer(NewArrayTree newArray, ExpressionTree initializer)
newArray
- new array tree containing initializers list.initializer
- element to be removed from this list, if present.public NewArrayTree removeNewArrayInitializer(NewArrayTree newArray, int index)
newArray
- new array tree containinginitializers list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public NewClassTree addNewClassArgument(NewClassTree newClass, ExpressionTree argument)
newClass
- new class tree containing arguments list.argument
- element to be appended to arguments list.public NewClassTree insertNewClassArgument(NewClassTree newClass, int index, ExpressionTree argument)
newClass
- new class tree containing type arguments list.index
- index at which the specified elements is to be inserted.argument
- element to be inserted to arguments list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public NewClassTree removeNewClassArgument(NewClassTree newClass, ExpressionTree argument)
newClass
- new class tree containing type arguments list.argument
- element to be removed from this list, if present.public NewClassTree removeNewClassArgument(NewClassTree newClass, int index)
newClass
- new class tree containing type arguments list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public NewClassTree addNewClassTypeArgument(NewClassTree newClass, ExpressionTree typeArgument)
newClass
- new class tree containing arguments list.typeArgument
- element to be appended to type arguments list.public NewClassTree insertNewClassTypeArgument(NewClassTree newClass, int index, ExpressionTree typeArgument)
newClass
- new class tree containing type arguments list.index
- index at which the specified elements is to be inserted.typeArgument
- element to be inserted to type arguments list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public NewClassTree removeNewClassTypeArgument(NewClassTree newClass, ExpressionTree typeArgument)
newClass
- new class tree containing type arguments list.typeArgument
- element to be removed from this list, if present.public NewClassTree removeNewClassTypeArgument(NewClassTree newClass, int index)
newClass
- new class tree containing type arguments list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public ParameterizedTypeTree addParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType, ExpressionTree argument)
parameterizedType
- parameterized type tree containing type arguments list.argument
- element to be appended to type arguments list.public ParameterizedTypeTree insertParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType, int index, ExpressionTree argument)
parameterizedType
- parameterized type tree containing type arguments list.index
- index at which the specified element is to be inserted.argument
- element to be inserted to type arguments list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public ParameterizedTypeTree removeParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType, ExpressionTree argument)
parameterizedType
- parameterized type tree containing type arguments list.argument
- element to be removed from this list, if present.public ParameterizedTypeTree removeParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType, int index)
parameterizedType
- parameterized type tree containing type arguments list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public SwitchTree addSwitchCase(SwitchTree swic, CaseTree kejs)
swic
- switch tree containing cases list.kejs
- element to be appended to cases list.public SwitchTree insertSwitchCase(SwitchTree swic, int index, CaseTree kejs)
swic
- switch tree containing cases list.index
- index at which the specified element is to be inserted.kejs
- element to be inserted to cases list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public SwitchTree removeSwitchCase(SwitchTree swic, CaseTree kejs)
swic
- switch tree containing cases list.kejs
- element to be removed from this list, if present.public SwitchTree removeSwitchCase(SwitchTree swic, int index)
swic
- switch tree containing cases list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public TryTree addTryCatch(TryTree traj, CatchTree kec)
traj
- try tree containing catches list.kec
- element to be appended to catches list.public TryTree insertTryCatch(TryTree traj, int index, CatchTree kec)
traj
- try tree containing catches list.index
- index at which the specified element is to be inserted.kec
- element to be inserted to catches list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public TryTree removeTryCatch(TryTree traj, CatchTree kec)
traj
- try tree containing catches list.kec
- element to be removed from this list, if present.public TryTree removeTryCatch(TryTree traj, int index)
traj
- try tree containing catches list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public TypeParameterTree addTypeParameterBound(TypeParameterTree typeParameter, ExpressionTree bound)
typeParameter
- type parameter tree containing bounds list.bound
- element to be appended to bounds list.public TypeParameterTree insertTypeParameterBound(TypeParameterTree typeParameter, int index, ExpressionTree bound)
typeParameter
- type parameter tree containing bounds list.index
- index at which the specified element is to be inserted.bound
- element to be inserted to bounds list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public TypeParameterTree removeTypeParameterBound(TypeParameterTree typeParameter, ExpressionTree bound)
typeParameter
- type parameter tree containing bounds list.bound
- element to be removed from this list, if present.public TypeParameterTree removeTypeParameterBound(TypeParameterTree typeParameter, int index)
typeParameter
- type parameter tree containing bounds list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public <N extends Tree> N setLabel(N node, CharSequence aLabel) throws IllegalArgumentException
Consider you want to change name of method fooMet to fooMethod:
public void fooMet() throws java.io.IOException { ... }You can get it e.g. with this code:
MethodTree footMet = contains footMet tree; MethodTree fooMethod = make.setLabel(fooMet, "fooMethod"); workingCopy.rewrite(node, njuMethod);This code will result to:
public void fooMethod() throws java.io.IOException { ... }
node
- argument will be duplicated and its label replaced
with aLabelaLabel
- represents new node's name or other labelIllegalArgumentException
- if the user provides
illegal node's kind, i.e. if the provided
node does not contain any name or String.public ClassTree setExtends(ClassTree node, ExpressionTree extendz)
Matricale
class extending class Yerba
.
You have the class available:
public class Matricale { ... }Running following code:
TreeMaker make = workingCopy.getTreeMaker(); ClassTree matricale = contains Matricale class; ClassTree modified = make.setExtends(matricale, make.Identifier("Yerba")); workingCopy.rewrite(matricale, modified);will result to:
public class Matricale extends Yerba { .... }Note: It does not apply for interface declaration. For interfaces declaration, use implements clause in
ClassTree
for
changed extends clause. It is a workaround allowing to extends more
interfaces.node
- class where the extends clause will be replacedextendz
- new extends identifier or member select.public <N extends Tree> N setInitialValue(N node, ExpressionTree initializer)
MethodTree
and VariableTree
. Initial
value is available for variables except the parameters. Fields and
local variables can be passed to the method. In addition to, annotation
attribute represented by MethodTree
is also valid value.
Consider you have declaration:
public static String cedron;Running following code:
TreeMaker make = workingCopy.getTreeMaker(); VariableTree cedron = contains cedron field; Literal initialValue = make.Literal("This is a cedron."); VariableTree modified = make.setInitialValue(cedron, literal); workingCopy.rewrite(matricale, modified);will result to:
public static String cedron = "This is a cedron.";
node
- replace the initial value in nodeinitializer
- new initial valueIllegalArgumentException
- if the user provides
illegal node
's kind, i.e. if the provided
node
is neither MethodTree
nor
VariableTree
public void addComment(Tree tree, Comment comment, boolean preceding) throws IllegalStateException
tree
- to which comment should addedcomment
- to addpreceding
- true if preceding comments should be added, false if trailing comments should be added.IllegalStateException
- if the method is called outside the runModificationTaskpublic void insertComment(Tree tree, Comment comment, int index, boolean preceding) throws IllegalStateException
tree
- to which comment should addedcomment
- to addindex
- -1 to add comment to the end of the list or index at which the comment should be addedpreceding
- true if preceding comments should be added, false if trailing comments should be added.IllegalStateException
- if the method is called outside the runModificationTaskpublic void removeComment(Tree tree, int index, boolean preceding) throws IllegalStateException
tree
- to which comment should addedindex
- comment to removeIllegalStateException
- if the method is called outside the runModificationTaskpublic <T extends Tree> T asNew(T tree)
T
- tree
- Tree instancepublic <T extends Tree> T asReplacementOf(T treeNew, Tree treeOld)
T
- treeNew
- the new tree instancetreeOld
- the old tree instanceTreeMaker.asReplacementOf(com.sun.source.tree.Tree, com.sun.source.tree.Tree, boolean)
public <T extends Tree> T asReplacementOf(T treeNew, Tree treeOld, boolean defaultOnly)
If 'defaultOnly' is true, the hint is only added if no previous hint exists. You generally want
to force the hint, in code manipulation operations. Bulk tree transformers should preserve existing
hints - the TreeUtilities.translate(com.sun.source.tree.Tree, java.util.Map<? extends com.sun.source.tree.Tree, ? extends com.sun.source.tree.Tree>)
preserves existing relationships.
T
- treeNew
- treeOld
- defaultOnly
- public <T extends Tree> T asRemoved(T tree)
T
- tree
- tree that has been removed.public BlockTree createMethodBody(MethodTree method, String bodyText)
method
- figures out the scope for attribution.bodyText
- text which will be used for method body creation.public BlockTree createLambdaBody(LambdaExpressionTree lambda, String bodyText)
lambda
- figures out the scope for attribution.bodyText
- text which will be used for lambda body creation.public ExpressionTree createLambdaExpression(LambdaExpressionTree lambda, String bodyText)
lambda
- figures out the scope for attribution.bodyText
- text which will be used for lambda body creation.public MethodTree Method(ModifiersTree modifiers, CharSequence name, Tree returnType, List<? extends TypeParameterTree> typeParameters, List<? extends VariableTree> parameters, List<? extends ExpressionTree> throwsList, String bodyText, ExpressionTree defaultValue)
modifiers
- the modifiers of this method.name
- the name of the method.returnType
- the return type for this method.typeParameters
- the list of generic type parameters, or an empty list.parameters
- the list of parameters, or an empty list.throwsList
- the list of throws clauses, or an empty list.bodyText
- the method's code block provided as a plain textdefaultValue
- the default value, used by annotation types.MethodTree
public com.sun.source.doctree.AttributeTree Attribute(CharSequence name, com.sun.source.doctree.AttributeTree.ValueKind vkind, List<? extends com.sun.source.doctree.DocTree> value)
name
- attribute namevkind
- attribute value kidvalue
- attribute valuepublic com.sun.source.doctree.AuthorTree Author(List<? extends com.sun.source.doctree.DocTree> name)
name
- the content of the treepublic com.sun.source.doctree.EntityTree Entity(CharSequence name)
name
- entity name/codepublic com.sun.source.doctree.DeprecatedTree Deprecated(List<? extends com.sun.source.doctree.DocTree> text)
text
- the deprecation messagepublic com.sun.source.doctree.DocCommentTree DocComment(List<? extends com.sun.source.doctree.DocTree> fullBody, List<? extends com.sun.source.doctree.DocTree> tags)
fullBody
- the entire body of the commenttags
- the block tags of the comment (after the main body)public com.sun.source.doctree.DocCommentTree DocComment(List<? extends com.sun.source.doctree.DocTree> firstSentence, List<? extends com.sun.source.doctree.DocTree> body, List<? extends com.sun.source.doctree.DocTree> tags)
firstSentence
- the javadoc comment's first sentencebody
- the main body of the commenttags
- the block tags of the comment (after the main body)public com.sun.source.doctree.ParamTree Param(boolean isTypeParameter, com.sun.source.doctree.IdentifierTree name, List<? extends com.sun.source.doctree.DocTree> description)
isTypeParameter
- true if and only if the parameter is a type parametername
- the name of the parameterdescription
- the description of the parameterpublic com.sun.source.doctree.LinkTree Link(com.sun.source.doctree.ReferenceTree ref, List<? extends com.sun.source.doctree.DocTree> label)
ref
- the reference linked by the @link
label
- the optional description of the referencepublic com.sun.source.doctree.LiteralTree DocLiteral(com.sun.source.doctree.TextTree text)
text
- the literal contentpublic com.sun.source.doctree.ReturnTree DocReturn(List<? extends com.sun.source.doctree.DocTree> description)
description
- the description of the method's returnpublic com.sun.source.doctree.ReferenceTree Reference(@NullAllowed ExpressionTree qualExpr, @NullAllowed CharSequence member, @NullAllowed List<? extends Tree> paramTypes)
qualExpr
- the type to to which the reference is being made (the part of the reference before '#'
)member
- the member to which the reference is being made (the part of the reference after '#'
)paramTypes
- optional parameter type of the methods to which this reference is being madepublic com.sun.source.doctree.SeeTree See(List<? extends com.sun.source.doctree.DocTree> reference)
reference
- to an element the tag refers topublic com.sun.source.doctree.SerialTree Serial(List<? extends com.sun.source.doctree.DocTree> description)
description
- the description of the fieldpublic com.sun.source.doctree.SerialDataTree SerialData(List<? extends com.sun.source.doctree.DocTree> description)
description
- the description of the serial datapublic com.sun.source.doctree.SerialFieldTree SerialField(com.sun.source.doctree.IdentifierTree name, com.sun.source.doctree.ReferenceTree type, List<? extends com.sun.source.doctree.DocTree> description)
name
- the name of the fieldtype
- the type of the fielddescription
- the description of the fieldpublic com.sun.source.doctree.SinceTree Since(List<? extends com.sun.source.doctree.DocTree> text)
text
- the content of the tagpublic com.sun.source.doctree.StartElementTree StartElement(CharSequence name, List<? extends com.sun.source.doctree.DocTree> attrs, boolean selfClosing)
name
- name of the elementattrs
- elements attributesselfClosing
- if the element is also the closing element (e.g. <br/>
).public com.sun.source.doctree.TextTree Text(String text)
text
- the textpublic com.sun.source.doctree.ThrowsTree Throws(com.sun.source.doctree.ReferenceTree name, List<? extends com.sun.source.doctree.DocTree> description)
name
- reference to the documented exceptiondescription
- the description of the thrown exceptionpublic com.sun.source.doctree.UnknownBlockTagTree UnknownBlockTag(CharSequence name, List<? extends com.sun.source.doctree.DocTree> content)
name
- the tag's namecontent
- the tag's contentpublic com.sun.source.doctree.UnknownInlineTagTree UnknownInlineTag(CharSequence name, List<? extends com.sun.source.doctree.DocTree> content)
name
- the tag's namecontent
- the tag's contentpublic com.sun.source.doctree.VersionTree Version(List<? extends com.sun.source.doctree.DocTree> text)
text
- the version's textpublic com.sun.source.doctree.ValueTree Value(com.sun.source.doctree.ReferenceTree ref)
ref
- the value's referencepublic com.sun.source.doctree.LiteralTree Code(com.sun.source.doctree.TextTree text)
text
- the text that should be wrapped by @code
public com.sun.source.doctree.CommentTree Comment(String text)
text
- the text that should be wrapped as HTML commentpublic com.sun.source.doctree.DocRootTree DocRoot()
public com.sun.source.doctree.EndElementTree EndElement(CharSequence name)
name
- name of the element to be closedpublic com.sun.source.doctree.ThrowsTree Exception(com.sun.source.doctree.ReferenceTree name, List<? extends com.sun.source.doctree.DocTree> description)
name
- reference to the documented exceptiondescription
- the description of the thrown exceptionpublic com.sun.source.doctree.IdentifierTree DocIdentifier(CharSequence name)
name
- the identifier namepublic com.sun.source.doctree.InheritDocTree InheritDoc()
public com.sun.source.doctree.LinkTree LinkPlain(com.sun.source.doctree.ReferenceTree ref, List<? extends com.sun.source.doctree.DocTree> label)
@linkplain
.ref
- the reference linked by the @link
label
- the optional description of the referencepublic LambdaExpressionTree addLambdaParameter(LambdaExpressionTree method, VariableTree parameter)
method
- lambda expression tree containing parameters list.parameter
- element to be appended to parameters list.public LambdaExpressionTree insertLambdaParameter(LambdaExpressionTree method, int index, VariableTree parameter)
method
- lambda expression tree containing parameters list.index
- index at which the specified elements is to be inserted.parameter
- element to be inserted to parameters list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public LambdaExpressionTree removeLambdaParameter(LambdaExpressionTree method, VariableTree parameter)
method
- lambda expression tree containing parameters list.parameter
- element to be removed from this list, if present.public LambdaExpressionTree removeLambdaParameter(LambdaExpressionTree method, int index)
method
- lambda expression tree containing parameters list.index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public LambdaExpressionTree setLambdaBody(LambdaExpressionTree method, Tree newBody)
method
- the source lambda expressionnewBody
- the new body