站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

TreeMaker (Java Source) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.java.source 0.13.0 1

org.netbeans.api.java.source
Class TreeMaker

java.lang.Object
  extended by org.netbeans.api.java.source.TreeMaker

public final class TreeMaker
extends Object

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
        }
        ...
    }; 
 

See Also:
How do I do modification to a source file?

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.
<N extends Tree>
N
setInitialValue(N node, ExpressionTree initializer)
          Replaces initializer in appropriate element.
<N extends Tree>
N
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

Annotation

public AnnotationTree Annotation(Tree type,
                                 List<? extends ExpressionTree> arguments)
Creates a new AnnotationTree.

Parameters:
type - the annotation type.
arguments - the arguments for this annotation, or an empty list.
See Also:
AnnotationTree

ArrayAccess

public ArrayAccessTree ArrayAccess(ExpressionTree array,
                                   ExpressionTree index)
Creates a new ArrayAccessTree.

Parameters:
array - the array expression.
index - the array index.
See Also:
ArrayAccessTree

ArrayType

public ArrayTypeTree ArrayType(Tree type)
Creates a new ArrayTypeTree.

Parameters:
type - the array type.
See Also:
ArrayTypeTree

Assert

public AssertTree Assert(ExpressionTree condition,
                         ExpressionTree detail)
Creates a new AssertTree.

Parameters:
condition - the boolean expression to test.
detail - the detail message to include if the assertion fails.
See Also:
AssertTree

Assignment

public AssignmentTree Assignment(ExpressionTree variable,
                                 ExpressionTree expression)
Creates a new AssignmentTree.

Parameters:
variable - the variable the expression is assigned to.
expression - the expression to assign to the variable.
See Also:
AssignmentTree

Binary

public BinaryTree Binary(Tree.Kind operator,
                         ExpressionTree left,
                         ExpressionTree right)
Creates a new BinaryTree.

Parameters:
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.
See Also:
BinaryTree, Tree.Kind

Block

public BlockTree Block(List<? extends StatementTree> statements,
                       boolean isStatic)
Creates a new BlockTree.

Parameters:
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();
See Also:
BlockTree

Break

public BreakTree Break(CharSequence label)
Creates a new BreakTree.

Parameters:
label - the label to break to, or null if there is no label.
See Also:
BreakTree

Case

public CaseTree Case(ExpressionTree expression,
                     List<? extends StatementTree> statements)
Creates a new CaseTree.

Parameters:
expression - the label for this case statement.
statements - the list of statements.
See Also:
CaseTree

Catch

public CatchTree Catch(VariableTree parameter,
                       BlockTree block)
Creates a new CatchTree.

Parameters:
parameter - the exception variable declaration.
block - the block of statements executed by this catch statement.
See Also:
CatchTree

Class

public ClassTree Class(ModifiersTree modifiers,
                       CharSequence simpleName,
                       List<? extends TypeParameterTree> typeParameters,
                       Tree extendsClause,
                       List<? extends Tree> implementsClauses,
                       List<? extends Tree> memberDecls)
Creates a new ClassTree.

Parameters:
modifiers - the modifiers declaration
simpleName - 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.
See Also:
ClassTree

Interface

public ClassTree Interface(ModifiersTree modifiers,
                           CharSequence simpleName,
                           List<? extends TypeParameterTree> typeParameters,
                           List<? extends Tree> extendsClauses,
                           List<? extends Tree> memberDecls)
Creates a new ClassTree representing interface.

Parameters:
modifiers - the modifiers declaration
simpleName - 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.
See Also:
ClassTree

AnnotationType

public ClassTree AnnotationType(ModifiersTree modifiers,
                                CharSequence simpleName,
                                List<? extends Tree> memberDecls)
Creates a new ClassTree representing annotation type.

Parameters:
modifiers - the modifiers declaration
simpleName - 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.
See Also:
ClassTree

Enum

public ClassTree Enum(ModifiersTree modifiers,
                      CharSequence simpleName,
                      List<? extends Tree> implementsClauses,
                      List<? extends Tree> memberDecls)
Creates a new ClassTree representing enum.

Parameters:
modifiers - the modifiers declaration
simpleName - 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.
See Also:
ClassTree

CompilationUnit

public CompilationUnitTree CompilationUnit(ExpressionTree packageName,
                                           List<? extends ImportTree> imports,
                                           List<? extends Tree> typeDeclarations,
                                           JavaFileObject sourceFile)
Creates a new CompilationUnitTree.

Parameters:
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.
See Also:
CompilationUnitTree

CompoundAssignment

public CompoundAssignmentTree CompoundAssignment(Tree.Kind operator,
                                                 ExpressionTree variable,
                                                 ExpressionTree expression)
Creates a new CompoundAssignmentTree.

Parameters:
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.
See Also:
CompoundAssignmentTree

ConditionalExpression

public ConditionalExpressionTree ConditionalExpression(ExpressionTree condition,
                                                       ExpressionTree trueExpression,
                                                       ExpressionTree falseExpression)
Creates a new ConditionalExpressionTree.

Parameters:
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.
See Also:
ConditionalExpressionTree

Constructor

public MethodTree Constructor(ModifiersTree modifiers,
                              List<? extends TypeParameterTree> typeParameters,
                              List<? extends VariableTree> parameters,
                              List<? extends ExpressionTree> throwsList,
                              BlockTree body)
Creates a new MethodTree representing constructor.

Parameters:
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.
See Also:
MethodTree

Constructor

public MethodTree Constructor(ModifiersTree modifiers,
                              List<? extends TypeParameterTree> typeParameters,
                              List<? extends VariableTree> parameters,
                              List<? extends ExpressionTree> throwsList,
                              String bodyText)
Creates a new MethodTree representing constructor.

Parameters:
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 text
See Also:
MethodTree

Continue

public ContinueTree Continue(CharSequence label)
Creates a new ContinueTree.

Parameters:
label - the label to break to, or null if there is no label.
See Also:
ContinueTree

DoWhileLoop

public DoWhileLoopTree DoWhileLoop(ExpressionTree condition,
                                   StatementTree statement)
Creates a new DoWhileLoopTree.

Parameters:
condition - the boolean expression to test.
statement - the statement to execute while the condition is true.
See Also:
DoWhileLoopTree

EmptyStatement

public EmptyStatementTree EmptyStatement()
Creates a new EmptyStatementTree.

See Also:
EmptyStatementTree

EnhancedForLoop

public EnhancedForLoopTree EnhancedForLoop(VariableTree variable,
                                           ExpressionTree expression,
                                           StatementTree statement)
Creates a new EnhancedForLoopTree.

Parameters:
variable - the loop variable declaration.
expression - the expression to be iterated.
statement - the statement to execute each iteration.
See Also:
EnhancedForLoopTree

Erroneous

public ErroneousTree Erroneous(List<? extends Tree> errorTrees)
Creates a new ErroneousTree.

Parameters:
errorTrees - a list of trees with possible errors.
See Also:
ErroneousTree

ExpressionStatement

public ExpressionStatementTree ExpressionStatement(ExpressionTree expression)
Creates a new ExpressionStatementTree.

Parameters:
expression - the expression body for this statement.
See Also:
ExpressionStatementTree

ForLoop

public ForLoopTree ForLoop(List<? extends StatementTree> initializer,
                           ExpressionTree condition,
                           List<? extends ExpressionStatementTree> update,
                           StatementTree statement)
Creates a new ForLoopTree.

Parameters:
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.
See Also:
ForLoopTree

Identifier

public IdentifierTree Identifier(CharSequence name)
Creates a new IdentifierTree.

Parameters:
name - the name of the identifier.
See Also:
IdentifierTree

Identifier

public IdentifierTree Identifier(Element element)
Creates a new IdentifierTree from an Element.

Parameters:
element - the element from which to extract the identifier name.
See Also:
IdentifierTree, Element

If

public IfTree If(ExpressionTree condition,
                 StatementTree thenStatement,
                 StatementTree elseStatement)
Creates a new IfTree.

Parameters:
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.
See Also:
IfTree

Import

public ImportTree Import(Tree qualid,
                         boolean importStatic)
Creates a new ImportTree.

Parameters:
qualid - fully qualified identifier.
importStatic - true if static import statement.
See Also:
ImportTree

InstanceOf

public InstanceOfTree InstanceOf(ExpressionTree expression,
                                 Tree type)
Creates a new InstanceOfTree.

Parameters:
expression - the expression whose type is being checked.
type - the type to compare to.
See Also:
InstanceOfTree

LabeledStatement

public LabeledStatementTree LabeledStatement(CharSequence label,
                                             StatementTree statement)
Creates a new LabeledStatementTree.

Parameters:
label - the label string.
statement - the statement being labeled.
See Also:
LabeledStatementTree

Literal

public LiteralTree Literal(Object value)
Creates a new LiteralTree. Only literals which are wrappers for primitive types (Integer, Boolean, etc.) and String instances can be literals.

Parameters:
value - the value of the literal.
Throws:
IllegalArgumentException - for illegal literal values.
See Also:
LiteralTree

MemberSelect

public MemberSelectTree MemberSelect(ExpressionTree expression,
                                     CharSequence identifier)
Creates a new MemberSelectTree. A MemberSelectTree consists of an expression and an identifier. Valid expressions include things like packages, class and field references, etc., while the identifier is a "child" of the expression. For example, "System.out" is represented by MemberSelectTree which has an ExpressionTree representing "System" and an identifier of "out".

Parameters:
expression - the expression the identifier is part of.
identifier - the element to select.
See Also:
MemberSelectTree

MemberSelect

public MemberSelectTree MemberSelect(ExpressionTree expression,
                                     Element element)
Creates a new MemberSelectTree from an expression and an element.

Parameters:
expression - the expression the identifier is part of.
element - the element that provides the identifier name.
See Also:
MemberSelectTree, Element

MethodInvocation

public MethodInvocationTree MethodInvocation(List<? extends ExpressionTree> typeArguments,
                                             ExpressionTree method,
                                             List<? extends ExpressionTree> arguments)
Creates a new MethodInvocationTree.

Parameters:
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.
See Also:
MethodInvocationTree

Method

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)
Creates a new MethodTree.

Parameters:
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.
See Also:
MethodTree

Method

public MethodTree Method(ExecutableElement element,
                         BlockTree body)
Creates a new MethodTree from an ExecutableElement and a BlockTree.

Parameters:
element - the executable element of this method.
body - the method's code block, or null for native, abstract, and interface methods.
See Also:
MethodTree, ExecutableElement

Modifiers

public ModifiersTree Modifiers(Set<Modifier> flags,
                               List<? extends AnnotationTree> annotations)
Creates a new ModifiersTree with a new set of flags and annotations.

Parameters:
flags - the set of modifier flags
annotations - a list of annotations, or an empty list.
See Also:
ModifiersTree, Modifier

Modifiers

public ModifiersTree Modifiers(long flags,
                               List<? extends AnnotationTree> annotations)
Creates a new ModifiersTree with a new flags and annotation.

Parameters:
flags - modifier flags
See Also:
ModifiersTree

Modifiers

public ModifiersTree Modifiers(Set<Modifier> flags)
Creates a new ModifiersTree without any annotations specified.

Parameters:
flags - the set of modifier flags
See Also:
ModifiersTree, Modifier

Modifiers

public ModifiersTree Modifiers(ModifiersTree oldMods,
                               List<? extends AnnotationTree> annotations)
Creates a new ModifiersTree with a new set of annotations. The existing flags are copied from the old tree; this preserves private javac flags.

Parameters:
oldMods - the old ModifiersTree, from which the flags are copied.
annotations - a list of annotations, or an empty list.
See Also:
ModifiersTree, Modifier

NewArray

public NewArrayTree NewArray(Tree elemtype,
                             List<? extends ExpressionTree> dimensions,
                             List<? extends ExpressionTree> initializers)
Creates a new NewArrayTree.

Parameters:
elemtype - the element type.
dimensions - the list of array dimensions.
initializers - the list of initializer statements, or an empty list.
See Also:
NewArrayTree

NewClass

public NewClassTree NewClass(ExpressionTree enclosingExpression,
                             List<? extends ExpressionTree> typeArguments,
                             ExpressionTree identifier,
                             List<? extends ExpressionTree> arguments,
                             ClassTree classBody)
Creates a new NewClassTree.

Parameters:
enclosingExpression - the enclosing expression, or null.
typeArguments - the list of generic type arguments, or an empty list.
identifier - the class name expression
arguments - the list of constructor arguments, or an empty list.
classBody - the class definition, or null if there is no definition.
See Also:
NewClassTree

ParameterizedType

public ParameterizedTypeTree ParameterizedType(Tree type,
                                               List<? extends ExpressionTree> typeArguments)
Creates a new ParameterizedTypeTree.

Parameters:
type - the generic type
typeArguments - the list of generic type arguments, or an empty list.
See Also:
ParameterizedTypeTree

Parenthesized

public ParenthesizedTree Parenthesized(ExpressionTree expression)
Creates a new ParenthesizedTree.

Parameters:
expression - the expression within the parentheses.
See Also:
ParenthesizedTree

PrimitiveType

public PrimitiveTypeTree PrimitiveType(TypeKind typekind)
Creates a new PrimitiveTypeTree.

Parameters:
typekind - the primitive type.
See Also:
PrimitiveTypeTree, TypeKind

QualIdent

public ExpressionTree QualIdent(Element element)
Creates a qualified identifier from an element.

Parameters:
element - the element to use.

Return

public ReturnTree Return(ExpressionTree expression)
Creates a new ReturnTree.

Parameters:
expression - the expression to be returned.
See Also:
ReturnTree

Switch

public SwitchTree Switch(ExpressionTree expression,
                         List<? extends CaseTree> cases)
Creates a new SwitchTree.

Parameters:
expression - the expression which provides the value to be switched.
cases - the list of cases, or an empty list.
See Also:
SwitchTree

Synchronized

public SynchronizedTree Synchronized(ExpressionTree expression,
                                     BlockTree block)
Creates a new SynchronizedTree.

Parameters:
expression - the expression defining the object being synchronized.
block - the block of statements executed by this statement.
See Also:
SynchronizedTree

Throw

public ThrowTree Throw(ExpressionTree expression)
Creates a new ThrowTree.

Parameters:
expression - the exception to be thrown.
See Also:
ThrowTree

Try

public TryTree Try(BlockTree tryBlock,
                   List<? extends CatchTree> catches,
                   BlockTree finallyBlock)
Creates a new TryTree.

Parameters:
tryBlock - the statement block in the try clause.
catches - the list of catch clauses, or an empty list.
finallyBlock - the finally clause, or null.
See Also:
TryTree

Type

public Tree Type(TypeMirror type)
Creates a new Tree for a given TypeMirror.

Parameters:
type - TypeMirror for which a Tree should be created
See Also:
ExpressionTree

TypeCast

public TypeCastTree TypeCast(Tree type,
                             ExpressionTree expression)
Creates a new TypeCastTree.

Parameters:
type - the class or interface to cast.
expression - the expression being cast.
See Also:
TypeCastTree

TypeParameter

public TypeParameterTree TypeParameter(CharSequence name,
                                       List<? extends ExpressionTree> bounds)
Creates a new TypeParameterTree.

Parameters:
name - the name of this type parameter.
bounds - the bounds of this parameter.
See Also:
TypeParameterTree

Unary

public UnaryTree Unary(Tree.Kind operator,
                       ExpressionTree arg)
Creates a new UnaryTree.

Parameters:
operator - the operator for this tree, such as Tree.Kind.PLUS.
arg - the operand of the tree.
See Also:
UnaryTree, Tree.Kind

Variable

public VariableTree Variable(ModifiersTree modifiers,
                             CharSequence name,
                             Tree type,
                             ExpressionTree initializer)
Creates a new VariableTree.

Parameters:
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.
See Also:
VariableTree

Variable

public VariableTree Variable(VariableElement variable,
                             ExpressionTree initializer)
Creates a new VariableTree from a VariableElement.

Parameters:
variable - the VariableElement to reference.
initializer - the initialization expression, or null.
See Also:
VariableTree, VariableElement

WhileLoop

public WhileLoopTree WhileLoop(ExpressionTree condition,
                               StatementTree statement)
Creates a new WhileLoopTree.

Parameters:
condition - the boolean expression to test.
statement - the statement to execute while the condition is true.
See Also:
WhileLoopTree

Wildcard

public WildcardTree Wildcard(Tree.Kind kind,
                             Tree type)
Creates a new WildcardTree.

Parameters:
kind - the kind of wildcard to create.
type - the type (class, interface or enum) of this wildcard.
See Also:
WildcardTree

addAnnotationAttrValue

public AnnotationTree addAnnotationAttrValue(AnnotationTree annotation,
                                             ExpressionTree attrValue)
Appends specified element attrValue to the end of attribute values list.

Parameters:
annotation - annotation tree containing attribute values list.
attrValue - element to be appended to attribute values list.
Returns:
annotation tree with modified attribute values.

insertAnnotationAttrValue

public AnnotationTree insertAnnotationAttrValue(AnnotationTree annotation,
                                                int index,
                                                ExpressionTree attrValue)
Inserts the specified element attrValue at the specified position in attribute values list.

Parameters:
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.
Returns:
annotation tree with modified attribute values.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeAnnotationAttrValue

public AnnotationTree removeAnnotationAttrValue(AnnotationTree annotation,
                                                ExpressionTree attrValue)
Removes the first occurrence in attribute values list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
annotation - annotation tree with attribute values list.
attrValue - element to be removed from this list, if present.
Returns:
annotation tree with modified attribute values.

removeAnnotationAttrValue

public AnnotationTree removeAnnotationAttrValue(AnnotationTree annotation,
                                                int index)
Removes the element at the specified position in attribute values list. Returns the modified annotation tree.

Parameters:
annotation - annotation tree with attribute values list.
index - the index of the element to be removed.
Returns:
annotation tree with modified attribute values.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addBlockStatement

public BlockTree addBlockStatement(BlockTree block,
                                   StatementTree statement)
Appends specified element statement to the end of statements list.

Parameters:
block - block tree containing statements list.
statement - element to be appended to statements list.
Returns:
block tree with modified statements

insertBlockStatement

public BlockTree insertBlockStatement(BlockTree block,
                                      int index,
                                      StatementTree statement)
Inserts the specified element statement at the specified position in statements list.

Parameters:
block - block tree with statements list
index - index at which the specified element is to be inserted.
statement - element to be inserted to statements list.
Returns:
block tree with modified statements
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeBlockStatement

public BlockTree removeBlockStatement(BlockTree block,
                                      StatementTree statement)
Removes the first occurrence in statements list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
block - block tree with statements list
statement - element to be removed from this list, if present.
Returns:
block tree with modified statements

removeBlockStatement

public BlockTree removeBlockStatement(BlockTree block,
                                      int index)
Removes the element at the specified position in statements list. Returns the modified block tree.

Parameters:
block - block tree with statements list
index - the index of the element to be removed.
Returns:
block tree with modified statements
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addCaseStatement

public CaseTree addCaseStatement(CaseTree kejs,
                                 StatementTree statement)
Appends specified element statement to the end of statements list.

Parameters:
kejs - case tree containing statements list.
statement - element to be appended to statements list.
Returns:
case tree with modified statements.

insertCaseStatement

public CaseTree insertCaseStatement(CaseTree kejs,
                                    int index,
                                    StatementTree statement)
Inserts the specified element statement at the specified position in statements list.

Parameters:
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.
Returns:
case tree with modified statements.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeCaseStatement

public CaseTree removeCaseStatement(CaseTree kejs,
                                    StatementTree statement)
Removes the first occurrence in statements list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
kejs - case tree containing statements list.
statement - element to be removed from this list, if present.
Returns:
case tree with modified statements.

removeCaseStatement

public CaseTree removeCaseStatement(CaseTree kejs,
                                    int index)
Removes the element at the specified position in statements list. Returns the modified case tree.

Parameters:
kejs - case tree containing statements list.
index - the index of the element to be removed.
Returns:
case tree with modified statements.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addClassMember

public ClassTree addClassMember(ClassTree clazz,
                                Tree member)
Appends specified element member to the end of members list. Consider you want to add such a method to the end of class:
   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 parList = 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));
 

Parameters:
clazz - class tree containing members list.
member - element to be appended to members list.
Returns:
class tree with modified members.

insertClassMember

public ClassTree insertClassMember(ClassTree clazz,
                                   int index,
                                   Tree member)
Inserts the specified element member at the specified position in members list.

Parameters:
clazz - class tree with members list
index - index at which the specified element is to be inserted.
member - element to be inserted to members list.
Returns:
class tree with modified members.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeClassMember

public ClassTree removeClassMember(ClassTree clazz,
                                   Tree member)
Removes the first occurrence in members list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
clazz - class tree with members list
member - element to be removed from this list, if present.
Returns:
class tree with modified members.

removeClassMember

public ClassTree removeClassMember(ClassTree clazz,
                                   int index)
Removes the element at the specified position in members list. Returns the modified class tree.

Parameters:
clazz - class tree with members list.
index - the index of the element to be removed.
Returns:
class tree with modified members.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addClassTypeParameter

public ClassTree addClassTypeParameter(ClassTree clazz,
                                       TypeParameterTree typeParameter)
Appends specified element typeParameter to the end of type parameters list.

Parameters:
clazz - class tree containing type parameters list.
typeParameter - element to be appended to type parameters list.
Returns:
class tree with modified type parameters.

insertClassTypeParameter

public ClassTree insertClassTypeParameter(ClassTree clazz,
                                          int index,
                                          TypeParameterTree typeParameter)
Inserts the specified element member at the specified position in type parameters list.

Parameters:
clazz - class tree with type parameters list
index - index at which the specified element is to be inserted.
typeParameter - element to be inserted to type parameters list.
Returns:
class tree with modified type parameters.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeClassTypeParameter

public ClassTree removeClassTypeParameter(ClassTree clazz,
                                          TypeParameterTree typeParameter)
Removes the first occurrence in type parameters list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
clazz - class tree with type parameters list
typeParameter - element to be removed from this list, if present.
Returns:
class tree with modified type parameters.

removeClassTypeParameter

public ClassTree removeClassTypeParameter(ClassTree clazz,
                                          int index)
Removes the element at the specified position in type parameters list. Returns the modified class tree.

Parameters:
clazz - class tree with type parameters list.
index - the index of the element to be removed.
Returns:
class tree with modified type parameters.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addClassImplementsClause

public ClassTree addClassImplementsClause(ClassTree clazz,
                                          Tree implementsClause)
Appends specified element implementsClause to the end of implements list.

Parameters:
clazz - class tree containing implements list.
implementsClause - element to be appended to implements list.
Returns:
class tree with modified implements.

insertClassImplementsClause

public ClassTree insertClassImplementsClause(ClassTree clazz,
                                             int index,
                                             Tree implementsClause)
Inserts the specified element implementsClause at the specified position in implements list.

Parameters:
clazz - class tree with implements list
index - index at which the specified element is to be inserted.
implementsClause - element to be inserted to implements list.
Returns:
class tree with modified implements.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeClassImplementsClause

public ClassTree removeClassImplementsClause(ClassTree clazz,
                                             Tree implementsClause)
Removes the first occurrence in implements list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
clazz - class tree with implements list
implementsClause - element to be removed from this list, if present.
Returns:
class tree with modified implements.

removeClassImplementsClause

public ClassTree removeClassImplementsClause(ClassTree clazz,
                                             int index)
Removes the element at the specified position in implements list. Returns the modified class tree.

Parameters:
clazz - class tree with implements list.
index - the index of the element to be removed.
Returns:
class tree with modified implements.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addCompUnitTypeDecl

public CompilationUnitTree addCompUnitTypeDecl(CompilationUnitTree compilationUnit,
                                               Tree typeDeclaration)
Appends specified element typeDeclaration to the end of type declarations list.

Parameters:
compilationUnit - compilation unit tree containing type declarations list.
typeDeclaration - element to be appended to type declarations list.
Returns:
compilation unit tree with modified type declarations.

insertCompUnitTypeDecl

public CompilationUnitTree insertCompUnitTypeDecl(CompilationUnitTree compilationUnit,
                                                  int index,
                                                  Tree typeDeclaration)
Inserts the specified element typeDeclaration at the specified position in type declarations list.

Parameters:
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.
Returns:
compilation unit tree with modified type declarations.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeCompUnitTypeDecl

public CompilationUnitTree removeCompUnitTypeDecl(CompilationUnitTree compilationUnit,
                                                  Tree typeDeclaration)
Removes the first occurrence in type declarations list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
compilationUnit - compilation unit tree containing type declarations list.
typeDeclaration - element to be removed from this list, if present.
Returns:
compilation unit tree with modified type declarations.

removeCompUnitTypeDecl

public CompilationUnitTree removeCompUnitTypeDecl(CompilationUnitTree compilationUnit,
                                                  int index)
Removes the element at the specified position in type declarations list. Returns the modified compilation unit tree.

Parameters:
compilationUnit - compilation unit tree containing type declarations list.
index - the index of the element to be removed.
Returns:
compilation unit tree with modified type declarations.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addCompUnitImport

public CompilationUnitTree addCompUnitImport(CompilationUnitTree compilationUnit,
                                             ImportTree importt)
Appends specified element importt to the end of imports list.

Parameters:
compilationUnit - compilation unit tree containing imports list.
importt - element to be appended to list of imports.
Returns:
compilation unit tree with modified imports.

insertCompUnitImport

public CompilationUnitTree insertCompUnitImport(CompilationUnitTree compilationUnit,
                                                int index,
                                                ImportTree importt)
Inserts the specified element importt at the specified position in imports list.

Parameters:
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.
Returns:
compilation unit tree with modified imports.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeCompUnitImport

public CompilationUnitTree removeCompUnitImport(CompilationUnitTree compilationUnit,
                                                ImportTree importt)
Removes the first occurrence in imports list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
compilationUnit - compilation unit tree containing import list.
importt - element to be removed from this list, if present.
Returns:
compilation unit tree with modified imports.

removeCompUnitImport

public CompilationUnitTree removeCompUnitImport(CompilationUnitTree compilationUnit,
                                                int index)
Removes the element at the specified position in import list. Returns the modified compilation unit tree.

Parameters:
compilationUnit - compilation unit tree containing import list.
index - the index of the element to be removed.
Returns:
compilation unit tree with modified imports.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addForLoopInitializer

public ForLoopTree addForLoopInitializer(ForLoopTree forLoop,
                                         StatementTree initializer)
Appends specified element initializer to the end of initializers list.

Parameters:
forLoop - for loop tree containing initializers list.
initializer - element to be appended to initializers list.
Returns:
for loop tree with modified initializers.

insertForLoopInitializer

public ForLoopTree insertForLoopInitializer(ForLoopTree forLoop,
                                            int index,
                                            StatementTree initializer)
Inserts the specified element initializer at the specified position in initializers list.

Parameters:
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.
Returns:
for loop tree with modified initializers.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeForLoopInitializer

public ForLoopTree removeForLoopInitializer(ForLoopTree forLoop,
                                            StatementTree initializer)
Removes the first occurrence in initializers list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
forLoop - for loop tree containing initializers list.
initializer - element to be removed from this list, if present.
Returns:
for loop tree with modified initializers.

removeForLoopInitializer

public ForLoopTree removeForLoopInitializer(ForLoopTree forLoop,
                                            int index)
Removes the element at the specified position in initializers list. Returns the modified for loop tree.

Parameters:
forLoop - for loop tree containing initializers list.
index - the index of the element to be removed.
Returns:
for loop tree with modified initializers.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addForLoopUpdate

public ForLoopTree addForLoopUpdate(ForLoopTree forLoop,
                                    ExpressionStatementTree update)
Appends specified element update to the end of updates list.

Parameters:
forLoop - for loop tree containing updates list.
update - element to be appended to updates list.
Returns:
for loop tree with modified updates.

insertForLoopUpdate

public ForLoopTree insertForLoopUpdate(ForLoopTree forLoop,
                                       int index,
                                       ExpressionStatementTree update)
Inserts the specified element update at the specified position in updates list.

Parameters:
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.
Returns:
for loop tree with modified updates.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeForLoopUpdate

public ForLoopTree removeForLoopUpdate(ForLoopTree forLoop,
                                       ExpressionStatementTree update)
Removes the first occurrence in updates list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
forLoop - for loop tree containing updates list.
update - element to be removed from this list, if present.
Returns:
for loop tree with modified updates.

removeForLoopUpdate

public ForLoopTree removeForLoopUpdate(ForLoopTree forLoop,
                                       int index)
Removes the element at the specified position in updates list. Returns the modified for loop tree.

Parameters:
forLoop - for loop tree containing updates list.
index - the index of the element to be removed.
Returns:
for loop tree with modified updates.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addMethodInvocationArgument

public MethodInvocationTree addMethodInvocationArgument(MethodInvocationTree methodInvocation,
                                                        ExpressionTree argument,
                                                        ExpressionTree typeArgument)
Appends specified element argument with related typeArgument to the end of arguments/type arguments list.

Parameters:
methodInvocation - method invocation tree containing arguments list.
argument - element to be appended to arguments list.
typeArgument - element to be appended to type arguments list.
Returns:
method invocation tree with modified arguments and type arguments.

insertMethodInvocationArgument

public 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.

Parameters:
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.
Returns:
method invocation tree with modified type arguments and type arguments.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeMethodInvocationArgument

public MethodInvocationTree removeMethodInvocationArgument(MethodInvocationTree methodInvocation,
                                                           ExpressionTree argument,
                                                           ExpressionTree typeArgument)
TODO: Strange method - different arguments/type arguments can be removed. just argument should be passed to the method. Removes the first occurrence in arguments and type arguments list of the specified elements. If this list do not contain the elements, it is unchanged.

Parameters:
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.
Returns:
method invocation tree with modified arguments and type arguments.

removeMethodInvocationArgument

public MethodInvocationTree removeMethodInvocationArgument(MethodInvocationTree methodInvocation,
                                                           int index)
Removes the element at the specified position in arguments and type arguments list. Returns the modified method invocation tree.

Parameters:
methodInvocation - method invocation tree containing arguments list.
index - the index of the element to be removed.
Returns:
method invocation tree with modified arguments and type arguments.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addMethodParameter

public MethodTree addMethodParameter(MethodTree method,
                                     VariableTree parameter)
Appends specified element parameter to the end of parameters list.

Parameters:
method - method tree containing parameters list.
parameter - element to be appended to parameters list.
Returns:
method tree with modified parameters.

insertMethodParameter

public MethodTree insertMethodParameter(MethodTree method,
                                        int index,
                                        VariableTree parameter)
Inserts the specified element parameter at the specified position in parameters list.

Parameters:
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.
Returns:
method tree with modified parameters.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeMethodParameter

public MethodTree removeMethodParameter(MethodTree method,
                                        VariableTree parameter)
Removes the first occurrence in parameters list of the specified elements. If this list do not contain the element, it is unchanged.

Parameters:
method - method tree containing parameters list.
parameter - element to be removed from this list, if present.
Returns:
method tree with modified parameters and type parameters.

removeMethodParameter

public MethodTree removeMethodParameter(MethodTree method,
                                        int index)
Removes the element at the specified position in parameters list. Returns the modified method tree.

Parameters:
method - method tree containing parameters list.
index - the index of the element to be removed.
Returns:
method tree with modified parameters.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addMethodTypeParameter

public MethodTree addMethodTypeParameter(MethodTree method,
                                         TypeParameterTree typeParameter)
Appends specified element typeParameter to the end of type parameters list.

Parameters:
method - method tree containing type parameters list.
typeParameter - element to be appended to type parameters list.
Returns:
method tree with modified type parameters.

insertMethodTypeParameter

public MethodTree insertMethodTypeParameter(MethodTree method,
                                            int index,
                                            TypeParameterTree typeParameter)
Inserts the specified element typeParameter at the specified position in type parameters list.

Parameters:
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.
Returns:
method tree with modified type parameters.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeMethodTypeParameter

public MethodTree removeMethodTypeParameter(MethodTree method,
                                            TypeParameterTree typeParameter)
Removes the first occurrence in type parameters list of the specified elements. If this list do not contain the element, it is unchanged.

Parameters:
method - method tree containing type parameters list.
typeParameter - element to be removed from this list, if present.
Returns:
method tree with modified type parameters.

removeMethodTypeParameter

public MethodTree removeMethodTypeParameter(MethodTree method,
                                            int index)
Removes the element at the specified position in type parameters list. Returns the modified method tree.

Parameters:
method - method tree containing type parameters list.
index - the index of the element to be removed.
Returns:
method tree with modified type parameters.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addMethodThrows

public MethodTree addMethodThrows(MethodTree method,
                                  ExpressionTree throwz)
Appends specified element throwz to the end of throws list.

Parameters:
method - method tree containing throws list.
throwz - element to be appended to throws list.
Returns:
method tree with modified throws.

insertMethodThrows

public MethodTree insertMethodThrows(MethodTree method,
                                     int index,
                                     ExpressionTree throwz)
Inserts the specified element throws at the specified position in throws list.

Parameters:
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.
Returns:
method tree with modified throws.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeMethodThrows

public MethodTree removeMethodThrows(MethodTree method,
                                     ExpressionTree throwz)
Removes the first occurrence in throws list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
method - method tree containing throws list.
throwz - element to be removed from this list, if present.
Returns:
method tree with modified throws.

removeMethodThrows

public MethodTree removeMethodThrows(MethodTree method,
                                     int index)
Removes the element at the specified position in throws list. Returns the modified method tree.

Parameters:
method - method tree containing throws list.
index - the index of the element to be removed.
Returns:
method tree with modified throws.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addModifiersAnnotation

public ModifiersTree addModifiersAnnotation(ModifiersTree modifiers,
                                            AnnotationTree annotation)
Appends specified element annotation to the end of annotations list.

Parameters:
modifiers - modifiers tree containing annotations list.
annotation - element to be appended to annotations list.
Returns:
modifiers tree with modified annotations.

insertModifiersAnnotation

public ModifiersTree insertModifiersAnnotation(ModifiersTree modifiers,
                                               int index,
                                               AnnotationTree annotation)
Inserts the specified element annotation at the specified position in annotations list.

Parameters:
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.
Returns:
modifiers tree with modified annotations.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeModifiersAnnotation

public ModifiersTree removeModifiersAnnotation(ModifiersTree modifiers,
                                               AnnotationTree annotation)
Removes the first occurrence in annotations list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
modifiers - modifiers tree containing annotations list.
annotation - element to be removed from this list, if present.
Returns:
modifiers tree with modified annotations.

removeModifiersAnnotation

public ModifiersTree removeModifiersAnnotation(ModifiersTree modifiers,
                                               int index)
Removes the element at the specified position in annotations list. Returns the modified modifiers tree.

Parameters:
modifiers - modifiers tree containing annotations list.
index - the index of the element to be removed.
Returns:
modifiers tree with modified annotations.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addNewArrayDimension

public NewArrayTree addNewArrayDimension(NewArrayTree newArray,
                                         ExpressionTree dimension)
Appends specified element dimension to the end of dimensions list.

Parameters:
newArray - new array tree containing dimensions list.
dimension - element to be appended to dimensions list.
Returns:
new array tree with modified dimensions.

insertNewArrayDimension

public NewArrayTree insertNewArrayDimension(NewArrayTree newArray,
                                            int index,
                                            ExpressionTree dimension)
Inserts the specified element dimension at the specified position in dimensions list.

Parameters:
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.
Returns:
new array tree with modified dimensions.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeNewArrayDimension

public NewArrayTree removeNewArrayDimension(NewArrayTree newArray,
                                            ExpressionTree dimension)
Removes the first occurrence in dimensions list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
newArray - new array tree containing dimensions list.
dimension - element to be removed from this list, if present.
Returns:
new array tree with modified dimensions.

removeNewArrayDimension

public NewArrayTree removeNewArrayDimension(NewArrayTree newArray,
                                            int index)
Removes the element at the specified position in dimensions list. Returns the modified new array tree.

Parameters:
newArray - new array tree containing dimensions list.
index - the index of the element to be removed.
Returns:
new array tree with modified dimensions.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addNewArrayInitializer

public NewArrayTree addNewArrayInitializer(NewArrayTree newArray,
                                           ExpressionTree initializer)
Appends specified element initializer to the end of initializers list.

Parameters:
newArray - new array tree containing initializers list.
initializer - element to be appended to initializers list.
Returns:
new array tree with modified initializers.

insertNewArrayInitializer

public NewArrayTree insertNewArrayInitializer(NewArrayTree newArray,
                                              int index,
                                              ExpressionTree initializer)
Inserts the specified element initializer at the specified position in initializers list.

Parameters:
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.
Returns:
new array tree with modified initializers.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeNewArrayInitializer

public NewArrayTree removeNewArrayInitializer(NewArrayTree newArray,
                                              ExpressionTree initializer)
Removes the first occurrence in initializers list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
newArray - new array tree containing initializers list.
initializer - element to be removed from this list, if present.
Returns:
new array tree with modified initializers.

removeNewArrayInitializer

public NewArrayTree removeNewArrayInitializer(NewArrayTree newArray,
                                              int index)
Removes the element at the specified position in initializers list. Returns the modified new array tree.

Parameters:
newArray - new array tree containinginitializers list.
index - the index of the element to be removed.
Returns:
new array tree with modified initializers.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addNewClassArgument

public NewClassTree addNewClassArgument(NewClassTree newClass,
                                        ExpressionTree typeArgument,
                                        ExpressionTree argument)
Appends specified element argument with related typeArgument to the end of arguments/type arguments list.

Parameters:
newClass - new class tree containing arguments list.
typeArgument - element to be appended to type arguments list.
argument - element to be appended to arguments list.
Returns:
new class tree with modified arguments and type arguments.

insertNewClassArgument

public 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.

Parameters:
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.
Returns:
new class tree with modified type arguments and type arguments.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeNewClassArgument

public NewClassTree removeNewClassArgument(NewClassTree newClass,
                                           ExpressionTree typeArgument,
                                           ExpressionTree argument)
TODO: Strange method - different arguments/type arguments can be removed. just argument should be passed to the method. Removes the first occurrence in arguments and type arguments list of the specified elements. If this list do not contain the elements, it is unchanged.

Parameters:
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.
Returns:
new class tree with modified arguments and type arguments.

removeNewClassArgument

public NewClassTree removeNewClassArgument(NewClassTree newClass,
                                           int index)
Removes the element at the specified position in arguments and type arguments list. Returns the modified new class tree.

Parameters:
newClass - new class tree containing type arguments list.
index - the index of the element to be removed.
Returns:
new class tree with modified arguments and type arguments.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addParameterizedTypeTypeArgument

public ParameterizedTypeTree addParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType,
                                                              ExpressionTree argument)
Appends specified element argument to the end of type arguments list.

Parameters:
parameterizedType - parameterized type tree containing type arguments list.
argument - element to be appended to type arguments list.
Returns:
parameterized type tree with modified type arguments.

insertParameterizedTypeTypeArgument

public ParameterizedTypeTree insertParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType,
                                                                 int index,
                                                                 ExpressionTree argument)
Inserts the specified element argument at the specified position in type arguments list.

Parameters:
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.
Returns:
parameterized type tree with modified type arguments.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeParameterizedTypeTypeArgument

public ParameterizedTypeTree removeParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType,
                                                                 ExpressionTree argument)
Removes the first occurrence in type arguments list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
parameterizedType - parameterized type tree containing type arguments list.
argument - element to be removed from this list, if present.
Returns:
parameterized type tree with modified type arguments.

removeParameterizedTypeTypeArgument

public ParameterizedTypeTree removeParameterizedTypeTypeArgument(ParameterizedTypeTree parameterizedType,
                                                                 int index)
Removes the element at the specified position in type arguments list. Returns the modified parameterized type tree.

Parameters:
parameterizedType - parameterized type tree containing type arguments list.
index - the index of the element to be removed.
Returns:
parameterized type tree with modified type arguments.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addSwitchCase

public SwitchTree addSwitchCase(SwitchTree swic,
                                CaseTree kejs)
Appends specified element kejs to the end of cases list.

Parameters:
swic - switch tree containing cases list.
kejs - element to be appended to cases list.
Returns:
switch tree with modified cases.

insertSwitchCase

public SwitchTree insertSwitchCase(SwitchTree swic,
                                   int index,
                                   CaseTree kejs)
Inserts the specified element kejs at the specified position in cases list.

Parameters:
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.
Returns:
switch tree with modified cases.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeSwitchCase

public SwitchTree removeSwitchCase(SwitchTree swic,
                                   CaseTree kejs)
Removes the first occurrence in cases list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
swic - switch tree containing cases list.
kejs - element to be removed from this list, if present.
Returns:
switch tree with modified cases.

removeSwitchCase

public SwitchTree removeSwitchCase(SwitchTree swic,
                                   int index)
Removes the element at the specified position in cases list. Returns the modified switch tree.

Parameters:
swic - switch tree containing cases list.
index - the index of the element to be removed.
Returns:
switch tree with modified cases.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addTryCatch

public TryTree addTryCatch(TryTree traj,
                           CatchTree kec)
Appends specified element kec to the end of catches list.

Parameters:
traj - try tree containing catches list.
kec - element to be appended to catches list.
Returns:
try tree with modified catches.

insertTryCatch

public TryTree insertTryCatch(TryTree traj,
                              int index,
                              CatchTree kec)
Inserts the specified element kec at the specified position in catches list.

Parameters:
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.
Returns:
try tree with modified catches.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeTryCatch

public TryTree removeTryCatch(TryTree traj,
                              CatchTree kec)
Removes the first occurrence in catches list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
traj - try tree containing catches list.
kec - element to be removed from this list, if present.
Returns:
try tree with modified catches.

removeTryCatch

public TryTree removeTryCatch(TryTree traj,
                              int index)
Removes the element at the specified position in catches list. Returns the modified try tree.

Parameters:
traj - try tree containing catches list.
index - the index of the element to be removed.
Returns:
try tree with modified catches.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

addTypeParameterBound

public TypeParameterTree addTypeParameterBound(TypeParameterTree typeParameter,
                                               ExpressionTree bound)
Appends specified element bound to the end of bounds list.

Parameters:
typeParameter - type parameter tree containing bounds list.
bound - element to be appended to bounds list.
Returns:
type parameter tree with modified bounds.

insertTypeParameterBound

public TypeParameterTree insertTypeParameterBound(TypeParameterTree typeParameter,
                                                  int index,
                                                  ExpressionTree bound)
Inserts the specified element bound at the specified position in bounds list.

Parameters:
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.
Returns:
type parameter tree with modified bounds.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

removeTypeParameterBound

public TypeParameterTree removeTypeParameterBound(TypeParameterTree typeParameter,
                                                  ExpressionTree bound)
Removes the first occurrence in bounds list of the specified element. If this list does not contain the element, it is unchanged.

Parameters:
typeParameter - type parameter tree containing bounds list.
bound - element to be removed from this list, if present.
Returns:
type parameter tree with modified bounds.

removeTypeParameterBound

public TypeParameterTree removeTypeParameterBound(TypeParameterTree typeParameter,
                                                  int index)
Removes the element at the specified position in bounds list. Returns the modified type parameter tree.

Parameters:
typeParameter - type parameter tree containing bounds list.
index - the index of the element to be removed.
Returns:
type parameter tree with modified bounds.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

setLabel

public <N extends Tree> N setLabel(N node,
                                   CharSequence aLabel)
Replaces the original node's label with new one provided in aLabel argument. Throws IllegalArgumentException if node's kind is invalid. Valid node's kinds are:
BREAK, CLASS, CONTINUE, IDENTIFIER, LABELED_STATEMENT, MEMBER_SELECT, METHOD, TYPE_PARAMETER, VARIABLE.

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 {
       ...
   }
 

Parameters:
node - argument will be duplicated and its label replaced with aLabel
aLabel - represents new node's name or other label
Returns:
duplicated node with a new name
Throws:
IllegalArgumentException - if the user provides illegal node's kind, i.e. if the provided node does not contain any name or String.

setExtends

public ClassTree setExtends(ClassTree node,
                            ExpressionTree extendz)
Replaces extends clause in class declaration. Consider you want to make 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.

Parameters:
node - class where the extends clause will be replaced
extendz - new extends identifier or member select.
Returns:
node's copy with new extends clause

setInitialValue

public <N extends Tree> N setInitialValue(N node,
                                          ExpressionTree initializer)
Replaces initializer in appropriate element. Allowed types for node are 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.";
 

Parameters:
node - replace the initial value in node
initializer - new initial value
Returns:
node's copy with new initializer
Throws:
IllegalArgumentException - if the user provides illegal node's kind, i.e. if the provided node is neither MethodTree nor VariableTree

addComment

public void addComment(Tree tree,
                       Comment comment,
                       boolean preceding)
                throws IllegalStateException
Append a comment to the list of comments attached to a given tree.

Parameters:
tree - to which comment should added
comment - to add
preceding - true if preceding comments should be added, false if trailing comments should be added.
Throws:
IllegalStateException - if the method is called outside the runModificationTask

insertComment

public void insertComment(Tree tree,
                          Comment comment,
                          int index,
                          boolean preceding)
                   throws IllegalStateException
Insert a comment to the list of comments attached to a given tree (to a specified position).

Parameters:
tree - to which comment should added
comment - to add
index - -1 to add comment to the end of the list or index at which the comment should be added
preceding - true if preceding comments should be added, false if trailing comments should be added.
Throws:
IllegalStateException - if the method is called outside the runModificationTask

removeComment

public void removeComment(Tree tree,
                          int index,
                          boolean preceding)
                   throws IllegalStateException
Remove a comment from the list of comments attached to a given tree.

Parameters:
tree - to which comment should added
index - comment to remove
Throws:
IllegalStateException - if the method is called outside the runModificationTask

createMethodBody

public BlockTree createMethodBody(MethodTree method,
                                  String bodyText)
Creates a new BlockTree for provided bodyText.

Parameters:
method - figures out the scope for attribution.
bodyText - text which will be used for method body creation.
Returns:
a new tree for bodyText.

Method

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)
Creates a new MethodTree.

Parameters:
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 text
defaultValue - the default value, used by annotation types.
See Also:
MethodTree

org.netbeans.modules.java.source 0.13.0 1

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.