private void addNewLocals(TextEditGroup textEditGroup) { if (fLocals.isEmpty()) return; for (Iterator<VariableDeclarationStatement> iter= fLocals.iterator(); iter.hasNext();) { ASTNode element= iter.next(); fListRewrite.insertAt(element, fInsertionIndex++, textEditGroup); } }
private void addNewLocals(TextEditGroup textEditGroup) { if (fLocals.isEmpty()) return; for (Iterator<VariableDeclarationStatement> iter= fLocals.iterator(); iter.hasNext();) { ASTNode element= iter.next(); fListRewrite.insertAt(element, fInsertionIndex++, textEditGroup); } }
private void addNewLocals(TextEditGroup textEditGroup) { if (fLocals.isEmpty()) return; for (Iterator iter= fLocals.iterator(); iter.hasNext();) { ASTNode element= (ASTNode)iter.next(); fListRewrite.insertAt(element, fInsertionIndex++, textEditGroup); } }
public void insert(BodyDeclaration decl, TextEditGroup description) { List container= ASTNodes.getBodyDeclarations(fTypeNode); int index= ASTNodes.getInsertionIndex(decl, container); fListRewrite.insertAt(decl, index, description); } }
public void insert(BodyDeclaration decl, TextEditGroup description) { List<BodyDeclaration> container= ASTNodes.getBodyDeclarations(fTypeNode); int index= getInsertionIndex(decl, container); fListRewrite.insertAt(decl, index, description); }
public void insert(BodyDeclaration decl, TextEditGroup description) { List<BodyDeclaration> container= ASTNodes.getBodyDeclarations(fTypeNode); int index= ASTNodes.getInsertionIndex(decl, container); fListRewrite.insertAt(decl, index, description); } }
/** * Inserts the provided node at the specified index of the list in a node. * * @param listHolder the node holding the list where to insert * @param locationInParent the insert location description * @param nodeToInsert the node to insert * @param index the index where to insert the node in the list * @see ListRewrite#insertAt(ASTNode, int, org.eclipse.text.edits.TextEditGroup) */ public void insertAt( ASTNode listHolder, StructuralPropertyDescriptor locationInParent, ASTNode nodeToInsert, int index) { getListRewrite(listHolder, locationInParent).insertAt(nodeToInsert, index, null); addRefactoredNodes(listHolder); }
private void addFieldDeclaration(ASTRewrite rewrite) { FieldDeclaration[] fields= getFieldDeclarations(); ASTNode parent= getMethodDeclaration().getParent(); ChildListPropertyDescriptor descriptor= ASTNodes.getBodyDeclarationsProperty(parent); int insertIndex; if (fields.length == 0) insertIndex= 0; else insertIndex= ASTNodes.getBodyDeclarations(parent).indexOf(fields[fields.length - 1]) + 1; final FieldDeclaration declaration= createNewFieldDeclaration(rewrite); rewrite.getListRewrite(parent, descriptor).insertAt(declaration, insertIndex, null); }
private void addFieldDeclaration(ASTRewrite rewrite) { FieldDeclaration[] fields= getFieldDeclarations(); ASTNode parent= getMethodDeclaration().getParent(); ChildListPropertyDescriptor descriptor= ASTNodes.getBodyDeclarationsProperty(parent); int insertIndex; if (fields.length == 0) insertIndex= 0; else insertIndex= ASTNodes.getBodyDeclarations(parent).indexOf(fields[fields.length - 1]) + 1; final FieldDeclaration declaration= createNewFieldDeclaration(rewrite); rewrite.getListRewrite(parent, descriptor).insertAt(declaration, insertIndex, null); }
@Override protected ASTRewrite getRewrite() { AST ast= fCallerNode.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); ChildListPropertyDescriptor property= getProperty(); for (int i= 0; i < fInsertIndexes.length; i++) { int idx= fInsertIndexes[i]; String key= "newarg_" + i; //$NON-NLS-1$ Expression newArg= evaluateArgumentExpressions(ast, fParamTypes[idx], key); ListRewrite listRewriter= rewrite.getListRewrite(fCallerNode, property); listRewriter.insertAt(newArg, idx, null); } return rewrite; }
private static void insertToType(ASTRewrite rewrite, ASTNode node, AbstractTypeDeclaration typeDeclaration) { switch (node.getNodeType()) { case ASTNode.ANNOTATION_TYPE_DECLARATION: case ASTNode.ENUM_DECLARATION: case ASTNode.TYPE_DECLARATION: case ASTNode.METHOD_DECLARATION: case ASTNode.FIELD_DECLARATION: case ASTNode.INITIALIZER: rewrite.getListRewrite(typeDeclaration, typeDeclaration.getBodyDeclarationsProperty()).insertAt(node, ASTNodes.getInsertionIndex((BodyDeclaration) node, typeDeclaration.bodyDeclarations()), null); break; default: Assert.isTrue(false, String.valueOf(node.getNodeType())); } }
private static void insertToType(ASTRewrite rewrite, ASTNode node, AbstractTypeDeclaration typeDeclaration) { switch (node.getNodeType()) { case ASTNode.ANNOTATION_TYPE_DECLARATION: case ASTNode.ENUM_DECLARATION: case ASTNode.TYPE_DECLARATION: case ASTNode.METHOD_DECLARATION: case ASTNode.FIELD_DECLARATION: case ASTNode.INITIALIZER: rewrite.getListRewrite(typeDeclaration, typeDeclaration.getBodyDeclarationsProperty()).insertAt(node, BodyDeclarationRewrite.getInsertionIndex((BodyDeclaration) node, typeDeclaration.bodyDeclarations()), null); break; default: Assert.isTrue(false, String.valueOf(node.getNodeType())); } }
private static void insertToType(ASTRewrite rewrite, ASTNode node, AbstractTypeDeclaration typeDeclaration) { switch (node.getNodeType()) { case ASTNode.ANNOTATION_TYPE_DECLARATION: case ASTNode.ENUM_DECLARATION: case ASTNode.TYPE_DECLARATION: case ASTNode.METHOD_DECLARATION: case ASTNode.FIELD_DECLARATION: case ASTNode.INITIALIZER: rewrite.getListRewrite(typeDeclaration, typeDeclaration.getBodyDeclarationsProperty()).insertAt(node, ASTNodes.getInsertionIndex((BodyDeclaration) node, typeDeclaration.bodyDeclarations()), null); break; default: Assert.isTrue(false, String.valueOf(node.getNodeType())); } }
private void addFieldDeclaration(ASTRewrite rewrite) { final ChildListPropertyDescriptor descriptor= getBodyDeclarationListOfDeclaringType(); FieldDeclaration[] fields= getFieldDeclarations(getBodyDeclarationListOfDeclaringType()); final ASTNode parent= getMethodDeclaration().getParent(); int insertIndex; if (fields.length == 0) insertIndex= 0; else insertIndex= ((List) parent.getStructuralProperty(descriptor)).indexOf(fields[fields.length - 1]) + 1; final FieldDeclaration declaration= createNewFieldDeclaration(rewrite); rewrite.getListRewrite(parent, descriptor).insertAt(declaration, insertIndex, null); }
private void addNestedClass(CompilationUnitRewrite rewrite, ITypeBinding[] typeParameters) throws CoreException { final AbstractTypeDeclaration declarations= (AbstractTypeDeclaration) ASTNodes.getParent(fAnonymousInnerClassNode, AbstractTypeDeclaration.class); int index= findIndexOfFistNestedClass(declarations.bodyDeclarations()); if (index == -1) index= 0; rewrite.getASTRewrite().getListRewrite(declarations, declarations.getBodyDeclarationsProperty()).insertAt(createNewNestedClass(rewrite, typeParameters), index, null); }
private void addNestedClass(CompilationUnitRewrite rewrite, ITypeBinding[] typeParameters) throws CoreException { final AbstractTypeDeclaration declarations= ASTNodes.getParent(fAnonymousInnerClassNode, AbstractTypeDeclaration.class); int index= findIndexOfFistNestedClass(declarations.bodyDeclarations()); if (index == -1) index= 0; rewrite.getASTRewrite().getListRewrite(declarations, declarations.getBodyDeclarationsProperty()).insertAt(createNewNestedClass(rewrite, typeParameters), index, null); }
private void addNestedClass(CompilationUnitRewrite rewrite, ITypeBinding[] typeParameters) throws CoreException { final AbstractTypeDeclaration declarations= (AbstractTypeDeclaration) ASTNodes.getParent(fAnonymousInnerClassNode, AbstractTypeDeclaration.class); int index= findIndexOfFistNestedClass(declarations.bodyDeclarations()); if (index == -1) index= 0; rewrite.getASTRewrite().getListRewrite(declarations, declarations.getBodyDeclarationsProperty()).insertAt(createNewNestedClass(rewrite, typeParameters), index, null); }
@Override protected ASTRewrite getRewrite() { AST ast= fCallerNode.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); ChildListPropertyDescriptor property= getProperty(); for (int i= 0; i < fInsertIndexes.length; i++) { int idx= fInsertIndexes[i]; String key= "newarg_" + i; //$NON-NLS-1$ Expression newArg= evaluateArgumentExpressions(ast, fParamTypes[idx], key); ListRewrite listRewriter= rewrite.getListRewrite(fCallerNode, property); listRewriter.insertAt(newArg, idx, null); addLinkedPosition(rewrite.track(newArg), i == 0, key); } return rewrite; }
protected ASTRewrite getRewrite() { AST ast= fCallerNode.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); ChildListPropertyDescriptor property= getProperty(); for (int i= 0; i < fInsertIndexes.length; i++) { int idx= fInsertIndexes[i]; String key= "newarg_" + i; //$NON-NLS-1$ Expression newArg= evaluateArgumentExpressions(ast, fParamTypes[idx], key); ListRewrite listRewriter= rewrite.getListRewrite(fCallerNode, property); listRewriter.insertAt(newArg, idx, null); addLinkedPosition(rewrite.track(newArg), i == 0, key); } return rewrite; }
@Override protected ASTRewrite getRewrite() { AST ast= fCallerNode.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); ChildListPropertyDescriptor property= getProperty(); for (int i= 0; i < fInsertIndexes.length; i++) { int idx= fInsertIndexes[i]; String key= "newarg_" + i; //$NON-NLS-1$ Expression newArg= evaluateArgumentExpressions(ast, fParamTypes[idx], key); ListRewrite listRewriter= rewrite.getListRewrite(fCallerNode, property); listRewriter.insertAt(newArg, idx, null); addLinkedPosition(rewrite.track(newArg), i == 0, key); } return rewrite; }