private BodyDeclarationRewrite(ASTRewrite rewrite, ASTNode typeNode) { ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(typeNode); fTypeNode= typeNode; fListRewrite= rewrite.getListRewrite(typeNode, property); }
private BodyDeclarationRewrite(ASTRewrite rewrite, ASTNode typeNode) { ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(typeNode); fTypeNode= typeNode; fListRewrite= rewrite.getListRewrite(typeNode, property); }
private BodyDeclarationRewrite(ASTRewrite rewrite, ASTNode typeNode) { ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(typeNode); fTypeNode= typeNode; fListRewrite= rewrite.getListRewrite(typeNode, property); }
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); }
protected ASTRewrite getRewrite() throws CoreException { CompilationUnit astRoot= ASTResolving.findParentCompilationUnit(fInvocationNode); ASTNode typeDecl= astRoot.findDeclaringNode(fSenderBinding); ASTNode newTypeDecl= null; if (typeDecl != null) { newTypeDecl= typeDecl; } else { astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } createImportRewrite(astRoot); if (newTypeDecl instanceof AnnotationTypeDeclaration) { ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); AnnotationTypeMemberDeclaration newStub= getStub(rewrite, (AnnotationTypeDeclaration) newTypeDecl); ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List members= (List) newTypeDecl.getStructuralProperty(property); int insertIndex= members.size(); ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, property); listRewriter.insertAt(newStub, insertIndex, null); return rewrite; } return null; }
private VariableDeclarationFragment addFieldDeclaration(ASTRewrite rewrite, ASTNode newTypeDecl, int modifiers, Expression expression) throws CoreException { if (fExistingFragment != null) { return fExistingFragment; } ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List decls= (List) newTypeDecl.getStructuralProperty(property); AST ast= newTypeDecl.getAST(); String[] varNames= suggestFieldNames(fTypeBinding, expression, modifiers); for (int i= 0; i < varNames.length; i++) { addLinkedPositionProposal(KEY_NAME, varNames[i], null); } String varName= varNames[0]; VariableDeclarationFragment newDeclFrag= ast.newVariableDeclarationFragment(); newDeclFrag.setName(ast.newSimpleName(varName)); FieldDeclaration newDecl= ast.newFieldDeclaration(newDeclFrag); Type type= evaluateType(ast); newDecl.setType(type); newDecl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, modifiers)); ModifierCorrectionSubProcessor.installLinkedVisibilityProposals(getLinkedProposalModel(), rewrite, newDecl.modifiers(), false); int insertIndex= findFieldInsertIndex(decls, fNodeToAssign.getStartPosition()); rewrite.getListRewrite(newTypeDecl, property).insertAt(newDecl, insertIndex, null); return newDeclFrag; }
ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List members= (List) newTypeDecl.getStructuralProperty(property);
ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List<BodyDeclaration> members= ASTNodes.getBodyDeclarations(newTypeDecl);
private VariableDeclarationFragment addFieldDeclaration(ASTRewrite rewrite, ASTNode newTypeDecl, int modifiers, Expression expression, ASTNode nodeToAssign, ITypeBinding typeBinding, int index) { if (fExistingFragment != null) { return fExistingFragment; } ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List<BodyDeclaration> decls= ASTNodes.getBodyDeclarations(newTypeDecl); AST ast= newTypeDecl.getAST(); String[] varNames= suggestFieldNames(typeBinding, expression, modifiers, nodeToAssign); for (int i= 0; i < varNames.length; i++) { addLinkedPositionProposal(KEY_NAME + index, varNames[i], null); } String varName= varNames[0]; VariableDeclarationFragment newDeclFrag= ast.newVariableDeclarationFragment(); newDeclFrag.setName(ast.newSimpleName(varName)); FieldDeclaration newDecl= ast.newFieldDeclaration(newDeclFrag); Type type= evaluateType(ast, nodeToAssign, typeBinding, KEY_TYPE + index, TypeLocation.FIELD); newDecl.setType(type); newDecl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, modifiers)); ModifierCorrectionSubProcessor.installLinkedVisibilityProposals(getLinkedProposalModel(), rewrite, newDecl.modifiers(), false, ModifierCorrectionSubProcessor.KEY_MODIFIER + index); int insertIndex= findFieldInsertIndex(decls, nodeToAssign.getStartPosition()) + index; rewrite.getListRewrite(newTypeDecl, property).insertAt(newDecl, insertIndex, null); return newDeclFrag; }
private VariableDeclarationFragment addFieldDeclaration(ASTRewrite rewrite, ASTNode newTypeDecl, int modifiers, Expression expression, ASTNode nodeToAssign, ITypeBinding typeBinding, int index) { if (fExistingFragment != null) { return fExistingFragment; } ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List<BodyDeclaration> decls= ASTNodes.getBodyDeclarations(newTypeDecl); AST ast= newTypeDecl.getAST(); String[] varNames= suggestFieldNames(typeBinding, expression, modifiers, nodeToAssign); for (int i= 0; i < varNames.length; i++) { addLinkedPositionProposal(KEY_NAME + index, varNames[i], null); } String varName= varNames[0]; VariableDeclarationFragment newDeclFrag= ast.newVariableDeclarationFragment(); newDeclFrag.setName(ast.newSimpleName(varName)); FieldDeclaration newDecl= ast.newFieldDeclaration(newDeclFrag); Type type= evaluateType(ast, nodeToAssign, typeBinding, KEY_TYPE + index); newDecl.setType(type); newDecl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, modifiers)); ModifierCorrectionSubProcessor.installLinkedVisibilityProposals(getLinkedProposalModel(), rewrite, newDecl.modifiers(), false, ModifierCorrectionSubProcessor.KEY_MODIFIER + index); int insertIndex= findFieldInsertIndex(decls, nodeToAssign.getStartPosition()) + index; rewrite.getListRewrite(newTypeDecl, property).insertAt(newDecl, insertIndex, null); return newDeclFrag; }
ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List<BodyDeclaration> members= ASTNodes.getBodyDeclarations(newTypeDecl);
ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List<BodyDeclaration> members= ASTNodes.getBodyDeclarations(newTypeDecl);
ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List<BodyDeclaration> decls= ASTNodes.<BodyDeclaration>getChildListProperty(newTypeDecl, property);
ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List decls= (List) newTypeDecl.getStructuralProperty(property);
ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List<BodyDeclaration> decls= ASTNodes.<BodyDeclaration>getChildListProperty(newTypeDecl, property);
ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl); List<BodyDeclaration> decls= ASTNodes.<BodyDeclaration>getChildListProperty(newTypeDecl, property);
List container= ASTNodes.getBodyDeclarations(declaration); int index= ASTNodes.getInsertionIndex((BodyDeclaration)newNode, container); ListRewrite lw= rewriter.getListRewrite(declaration, ASTNodes.getBodyDeclarationsProperty(declaration)); lw.insertAt(newNode, index, null); } else if (declaration instanceof EnumDeclaration) {
List<BodyDeclaration> container= ASTNodes.getBodyDeclarations(declaration); int index= BodyDeclarationRewrite.getInsertionIndex((BodyDeclaration)newNode, container); ListRewrite lw= rewriter.getListRewrite(declaration, ASTNodes.getBodyDeclarationsProperty(declaration)); lw.insertAt(newNode, index, null); } else if (declaration instanceof EnumDeclaration) {
List<BodyDeclaration> container= ASTNodes.getBodyDeclarations(declaration); int index= ASTNodes.getInsertionIndex((BodyDeclaration)newNode, container); ListRewrite lw= rewriter.getListRewrite(declaration, ASTNodes.getBodyDeclarationsProperty(declaration)); lw.insertAt(newNode, index, null); } else if (declaration instanceof EnumDeclaration) {