|
org.netbeans.modules.java.source 0.13.0 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.api.java.source.TreeMaker
public final class TreeMaker
Factory interface for creating new com.sun.source.tree instances. The
parameters for each method correspond as closely as possible to the
accessor methods for each tree interface.
You can obtain appropriate instance of this class by getting it from working
copy:
CancellableTask task = new CancellableTask() { public void run(WorkingCopy workingCopy) throws Exception { TreeMaker make = workingCopy.getTreeMaker(); ... your modification code here } ... };
Method Summary | ||
---|---|---|
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. |
|
MethodInvocationTree |
addMethodInvocationArgument(MethodInvocationTree methodInvocation,
ExpressionTree argument,
ExpressionTree typeArgument)
Appends specified element argument with related typeArgument to the end of arguments/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. |
|
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 typeArgument,
ExpressionTree argument)
Appends specified element argument with related typeArgument to the end of arguments/type arguments 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. |
|
AssertTree |
Assert(ExpressionTree condition,
ExpressionTree detail)
Creates a new AssertTree. |
|
AssignmentTree |
Assignment(ExpressionTree variable,
ExpressionTree expression)
Creates a new AssignmentTree. |
|
BinaryTree |
Binary(Tree.Kind operator,
ExpressionTree left,
ExpressionTree right)
Creates a new BinaryTree. |
|
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. |
|
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. |
|
CompilationUnitTree |
CompilationUnit(ExpressionTree packageName,
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 |
createMethodBody(MethodTree method,
String bodyText)
Creates a new BlockTree for provided bodyText. |
|
DoWhileLoopTree |
DoWhileLoop(ExpressionTree condition,
StatementTree statement)
Creates a new DoWhileLoopTree. |
|
EmptyStatementTree |
EmptyStatement()
Creates a new EmptyStatementTree. |
|
EnhancedForLoopTree |
EnhancedForLoop(VariableTree variable,
ExpressionTree expression,
StatementTree statement)
Creates a new EnhancedForLoopTree. |
|
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. |
|
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. |
|
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. |
|
MethodInvocationTree |
insertMethodInvocationArgument(MethodInvocationTree methodInvocation,
int index,
ExpressionTree argument,
ExpressionTree typeArgument)
Inserts the specified element argument with related typeArgument at the specified position in arguments/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. |
|
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 typeArgument,
ExpressionTree argument)
Inserts the specified element argument with related typeArgument at the specified position in arguments/type arguments 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. |
|
LiteralTree |
Literal(Object value)
Creates a new LiteralTree. |
|
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)
Creates a new MethodTree from an ExecutableElement and a BlockTree. |
|
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,
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. |
|
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. |
|
ParameterizedTypeTree |
ParameterizedType(Tree type,
List<? extends ExpressionTree> typeArguments)
Creates a new ParameterizedTypeTree. |
|
ParenthesizedTree |
Parenthesized(ExpressionTree expression)
Creates a new ParenthesizedTree. |
|
PrimitiveTypeTree |
PrimitiveType(TypeKind typekind)
Creates a new PrimitiveTypeTree. |
|
ExpressionTree |
QualIdent(Element element)
Creates a qualified identifier from an element. |
|
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. |
|
MethodInvocationTree |
removeMethodInvocationArgument(MethodInvocationTree methodInvocation,
ExpressionTree argument,
ExpressionTree typeArgument)
TODO: Strange method - different arguments/type arguments can be removed. |
|
MethodInvocationTree |
removeMethodInvocationArgument(MethodInvocationTree methodInvocation,
int index)
Removes the element at the specified position in arguments and type arguments list. |
|
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. |
|
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 typeArgument,
ExpressionTree argument)
TODO: Strange method - different arguments/type arguments can be removed. |
|
NewClassTree |
removeNewClassArgument(NewClassTree newClass,
int index)
Removes the element at the specified position in arguments and type arguments 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. |
|
ReturnTree |
Return(ExpressionTree expression)
Creates a new ReturnTree. |
|
ClassTree |
setExtends(ClassTree node,
ExpressionTree extendz)
Replaces extends clause in class declaration. |
|
|
setInitialValue(N node,
ExpressionTree initializer)
Replaces initializer in appropriate element. |
|
|
setLabel(N node,
CharSequence aLabel)
Replaces the original node's label with new one provided in aLabel argument. |
|
SwitchTree |
Switch(ExpressionTree expression,
List<? extends CaseTree> cases)
Creates a new SwitchTree. |
|
SynchronizedTree |
Synchronized(ExpressionTree expression,
BlockTree block)
Creates a new SynchronizedTree. |
|
ThrowTree |
Throw(ExpressionTree expression)
Creates a new ThrowTree. |
|
TryTree |
Try(BlockTree tryBlock,
List<? extends CatchTree> catches,
BlockTree finallyBlock)
Creates a new TryTree. |
|
Tree |
Type(TypeMirror type)
Creates a new Tree for a given TypeMirror. |
|
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. |
|
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. |
|
WhileLoopTree |
WhileLoop(ExpressionTree condition,
StatementTree statement)
Creates a new WhileLoopTree. |
|
WildcardTree |
Wildcard(Tree.Kind kind,
Tree type)
Creates a new WildcardTree. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
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 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 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 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 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 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
- the name of the identifier.IdentifierTree
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 LiteralTree Literal(Object value)
value
- the value of the literal.
IllegalArgumentException
- for illegal literal values.LiteralTree
public 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(ExecutableElement element, BlockTree body)
element
- the executable element of this method.body
- the method's code block, or null for native, abstract,
and interface methods.MethodTree
,
ExecutableElement
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 ParameterizedTypeTree ParameterizedType(Tree type, List<? extends ExpressionTree> 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
public PrimitiveTypeTree PrimitiveType(TypeKind typekind)
typekind
- the primitive type.PrimitiveTypeTree
,
TypeKind
public ExpressionTree QualIdent(Element element)
element
- the element to use.public 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 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 Tree Type(TypeMirror type)
type
- TypeMirror for which a Tree should be createdExpressionTree
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 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 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 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); ListparList = new ArrayList (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, make.addClassMember(node, newMethod));
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 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, ExpressionTree typeArgument)
methodInvocation
- method invocation tree containing arguments list.argument
- element to be appended to arguments list.typeArgument
- element to be appended to type arguments list.
public MethodInvocationTree insertMethodInvocationArgument(MethodInvocationTree methodInvocation, int index, ExpressionTree argument, ExpressionTree typeArgument)
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.typeArgument
- element to be inserted to type arguments list.
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public MethodInvocationTree removeMethodInvocationArgument(MethodInvocationTree methodInvocation, ExpressionTree argument, ExpressionTree typeArgument)
methodInvocation
- method invocation tree containing arguments list.argument
- element to be removed from this list, if present.typeArgument
- 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 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 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 typeArgument, ExpressionTree argument)
newClass
- new class tree containing arguments list.typeArgument
- element to be appended to type arguments list.argument
- element to be appended to arguments list.
public NewClassTree insertNewClassArgument(NewClassTree newClass, int index, ExpressionTree typeArgument, ExpressionTree argument)
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.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 typeArgument, ExpressionTree argument)
newClass
- new class tree containing type arguments list.typeArgument
- element to be removed from this list, if present.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 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)
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 label
IllegalArgumentException
- 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 value
IllegalArgumentException
- 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 remove
IllegalStateException
- if the method is called outside the runModificationTaskpublic BlockTree createMethodBody(MethodTree method, String bodyText)
method
- figures out the scope for attribution.bodyText
- text which will be used for method 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
|
org.netbeans.modules.java.source 0.13.0 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |