VariableDeclarationFragment placeholder= (VariableDeclarationFragment) rewrite.createMoveTarget(declNode); FieldDeclaration newField= ast.newFieldDeclaration(placeholder); newField.setType((Type) ASTNode.copySubtree(ast, fieldDecl.getType())); newField.modifiers().addAll(ast.newModifiers((fieldDecl.getModifiers() & ~fExcludedModifiers) | fIncludedModifiers));  AbstractTypeDeclaration typeDecl= (AbstractTypeDeclaration) fieldDecl.getParent(); ListRewrite listRewrite= rewrite.getListRewrite(typeDecl, typeDecl.getBodyDeclarationsProperty()); if (fieldDecl.fragments().indexOf(declNode) == 0) { listRewrite.insertBefore(newField, parent, null); } else { listRewrite.insertAfter(newField, parent, null); } declNode= newField;
VariableDeclarationRewrite.rewriteModifiers(fieldDecl, new VariableDeclarationFragment[] {fragment}, fIncludedModifiers, fExcludedModifiers, rewrite, selectionDescription);
	protected ASTRewrite getRewrite() {		CompilationUnit astRoot= ASTResolving.findParentCompilationUnit(fNode);		ASTNode boundNode= astRoot.findDeclaringNode(fBinding);		ASTNode declNode= null;		TextEditGroup selectionDescription= null;		if (boundNode != null) {			declNode= boundNode; // is same CU		} else {			selectionDescription= new TextEditGroup("selection"); // in different CU, needs selection //$NON-NLS-1$			//setSelectionDescription(selectionDescription);			CompilationUnit newRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null);			declNode= newRoot.findDeclaringNode(fBinding.getKey());		}		if (declNode != null) {			AST ast= declNode.getAST();			ASTRewrite rewrite= ASTRewrite.create(ast);			if (declNode.getNodeType() == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {				ASTNode parent= declNode.getParent();				if (parent instanceof FieldDeclaration) {					FieldDeclaration fieldDecl= (FieldDeclaration) parent;					if (fieldDecl.fragments().size() > 1 && (fieldDecl.getParent() instanceof AbstractTypeDeclaration)) { // split						VariableDeclarationFragment placeholder= (VariableDeclarationFragment) rewrite.createMoveTarget(declNode);						FieldDeclaration newField= ast.newFieldDeclaration(placeholder);						newField.setType((Type) ASTNode.copySubtree(ast, fieldDecl.getType()));						newField.modifiers().addAll(ast.newModifiers((fieldDecl.getModifiers() & ~fExcludedModifiers) | fIncludedModifiers));						AbstractTypeDeclaration typeDecl= (AbstractTypeDeclaration) fieldDecl.getParent();						ListRewrite listRewrite= rewrite.getListRewrite(typeDecl, typeDecl.getBodyDeclarationsProperty());						if (fieldDecl.fragments().indexOf(declNode) == 0) { // if it as the first in the list-> insert before							listRewrite.insertBefore(newField, parent, null);						} else {							listRewrite.insertAfter(newField, parent, null);						}						declNode= newField;						return rewrite;					}				} else if (parent instanceof VariableDeclarationStatement) {					VariableDeclarationStatement varDecl= (VariableDeclarationStatement) parent;					if (varDecl.fragments().size() > 1 && (varDecl.getParent() instanceof Block)) { // split						VariableDeclarationFragment placeholder= (VariableDeclarationFragment) rewrite.createMoveTarget(declNode);						VariableDeclarationStatement newStat= ast.newVariableDeclarationStatement(placeholder);						newStat.setType((Type) ASTNode.copySubtree(ast, varDecl.getType()));						newStat.modifiers().addAll(ast.newModifiers((newStat.getModifiers() & ~fExcludedModifiers) | fIncludedModifiers));						ListRewrite listRewrite= rewrite.getListRewrite(varDecl.getParent(), Block.STATEMENTS_PROPERTY);						if (varDecl.fragments().indexOf(declNode) == 0) { // if it as the first in the list-> insert before							listRewrite.insertBefore(newStat, parent, null);						} else {							listRewrite.insertAfter(newStat, parent, null);						}						return rewrite;					}				} else if (parent instanceof VariableDeclarationExpression) {					// can't separate				}				declNode= parent;			}			ModifierRewrite listRewrite= ModifierRewrite.create(rewrite, declNode);			listRewrite.setModifiers(fIncludedModifiers, fExcludedModifiers, selectionDescription);			return rewrite;		}		return null;	}