1 11 package org.eclipse.jdt.internal.corext.dom; 12 13 import java.util.List ; 14 15 import org.eclipse.text.edits.TextEditGroup; 16 17 import org.eclipse.jdt.core.dom.ASTNode; 18 import org.eclipse.jdt.core.dom.BodyDeclaration; 19 import org.eclipse.jdt.core.dom.ChildListPropertyDescriptor; 20 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; 21 import org.eclipse.jdt.core.dom.rewrite.ListRewrite; 22 23 24 public class BodyDeclarationRewrite { 25 26 private ASTNode fTypeNode; 27 private ListRewrite fListRewrite; 28 29 public static BodyDeclarationRewrite create(ASTRewrite rewrite, ASTNode typeNode) { 30 return new BodyDeclarationRewrite(rewrite, typeNode); 31 } 32 33 private BodyDeclarationRewrite(ASTRewrite rewrite, ASTNode typeNode) { 34 ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(typeNode); 35 fTypeNode= typeNode; 36 fListRewrite= rewrite.getListRewrite(typeNode, property); 37 } 38 39 public void insert(BodyDeclaration decl, TextEditGroup description) { 40 List container= ASTNodes.getBodyDeclarations(fTypeNode); 41 int index= ASTNodes.getInsertionIndex(decl, container); 42 fListRewrite.insertAt(decl, index, description); 43 } 44 } 45 | Popular Tags |