private void doAddLocal(AST ast, SimpleName node, ASTRewrite rewrite) throws CoreException {
private ASTRewrite doAddLocal(CompilationUnit cu) throws CoreException { AST ast= cu.getAST(); ASTRewrite rewrite= new ASTRewrite(cu); SimpleName node= fOriginalNode;
	private void doAddLocal(AST ast, SimpleName node, ASTRewrite rewrite) throws CoreException {		BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(node);		if (decl instanceof MethodDeclaration || decl instanceof Initializer) {						VariableDeclarationFragment newDeclFrag= ast.newVariableDeclarationFragment();			VariableDeclarationStatement newDecl= ast.newVariableDeclarationStatement(newDeclFrag);						Type type= evaluateVariableType(ast);			newDecl.setType(type);			newDeclFrag.setName(ast.newSimpleName(node.getIdentifier()));			newDeclFrag.setInitializer(ASTResolving.getInitExpression(type));						ASTNode parent= node.getParent();			if (parent.getNodeType() == ASTNode.ASSIGNMENT) {				Assignment assignment= (Assignment) parent;				if (node.equals(assignment.getLeftHandSide())) {					int parentParentKind= parent.getParent().getNodeType();					if (parentParentKind == ASTNode.EXPRESSION_STATEMENT) {						Expression placeholder= (Expression) rewrite.createCopy(assignment.getRightHandSide());						newDeclFrag.setInitializer(placeholder);										rewrite.markAsReplaced(assignment.getParent(), newDecl);						return;					} else if (parentParentKind == ASTNode.FOR_STATEMENT) {						ForStatement forStatement= (ForStatement) parent.getParent();						if (forStatement.initializers().size() == 1 && assignment.equals(forStatement.initializers().get(0))) {							VariableDeclarationFragment frag= ast.newVariableDeclarationFragment();							VariableDeclarationExpression expression= ast.newVariableDeclarationExpression(frag);							frag.setName(ast.newSimpleName(node.getIdentifier()));							Expression placeholder= (Expression) rewrite.createCopy(assignment.getRightHandSide());							frag.setInitializer(placeholder);							expression.setType(evaluateVariableType(ast));														rewrite.markAsReplaced(assignment, expression);							return;						}								}							}			} else if (parent.getNodeType() == ASTNode.EXPRESSION_STATEMENT) {				rewrite.markAsReplaced(parent, newDecl);				return;			}			Statement statement= ASTResolving.findParentStatement(node);			if (statement != null && statement.getParent() instanceof Block) {				Block block= (Block) statement.getParent();				List statements= block.statements();				statements.add(0, newDecl);								rewrite.markAsInserted(newDecl);			}		}	}