rewrite.markAsReplaced(statement, newBody);
rewrite.markAsReplaced(statement, newBody, null);
	public void testIfStatementReplaceElse3() throws Exception {		IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);		StringBuffer buf= new StringBuffer();		buf.append("package test1;\n");		buf.append("public class E {\n");		buf.append("    public void foo() {\n");		buf.append("        if (i == 0)\n");		buf.append("            System.beep();\n");		buf.append("        else\n");		buf.append("            hoo(11);\n");					buf.append("        if (i == 0) {\n");		buf.append("            System.beep();\n");		buf.append("        } else\n");		buf.append("            hoo(11);\n");			buf.append("        if (i == 0)\n");		buf.append("            System.beep();\n");		buf.append("        else {\n");		buf.append("            hoo(11);\n");		buf.append("        }\n");				buf.append("        if (i == 0) {\n");		buf.append("            System.beep();\n");		buf.append("        } else {\n");		buf.append("            hoo(11);\n");		buf.append("        }\n");				buf.append("    }\n");		buf.append("}\n");			ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);				CompilationUnit astRoot= createAST(cu);		NewASTRewrite rewrite= new NewASTRewrite(astRoot.getAST());		AST ast= astRoot.getAST();						assertTrue("Parse errors", (astRoot.getFlags() & ASTNode.MALFORMED) == 0);		TypeDeclaration type= findTypeDeclaration(astRoot, "E");		MethodDeclaration methodDecl= findMethodDeclaration(type, "foo");		Block block= methodDecl.getBody();		List statements= block.statements();		assertTrue("Number of statements not 4", statements.size() == 4);		{ // replace then statement by block , replace else with if statement (no block)			IfStatement ifStatement= (IfStatement) statements.get(0);						ASTNode statement= ifStatement.getThenStatement();						Block newBody= ast.newBlock();			ASTNode newStatement= rewrite.createMovePlaceholder(statement);			newBody.statements().add(newStatement);						rewrite.markAsReplaced(statement, newBody);						IfStatement newElseBlock= ast.newIfStatement();			newElseBlock.setExpression(ast.newBooleanLiteral(true));						Statement newBody2= (Statement) rewrite.createMovePlaceholder(ifStatement.getElseStatement());			newElseBlock.setThenStatement(newBody2);			rewrite.markAsReplaced(ifStatement.getElseStatement(), newElseBlock);		}		{ // replace then statement by block, replace else with if statement (no block)			IfStatement ifStatement= (IfStatement) statements.get(1);						Block body= (Block) ifStatement.getThenStatement();			ASTNode statement= (ASTNode) body.statements().get(0);						ASTNode newBody= rewrite.createMovePlaceholder(statement);						rewrite.markAsReplaced(body, newBody);							IfStatement newElseBlock= ast.newIfStatement();			newElseBlock.setExpression(ast.newBooleanLiteral(true));						Statement newBody2= (Statement) rewrite.createMovePlaceholder(ifStatement.getElseStatement());			newElseBlock.setThenStatement(newBody2);			rewrite.markAsReplaced(ifStatement.getElseStatement(), newElseBlock);		}		{ // replace then block by statement, replace else with if statement (block)			IfStatement ifStatement= (IfStatement) statements.get(2);						ASTNode statement= ifStatement.getThenStatement();						Block newBody= ast.newBlock();			ASTNode newStatement= rewrite.createMovePlaceholder(statement);			newBody.statements().add(newStatement);						rewrite.markAsReplaced(statement, newBody);										IfStatement newElseBlock= ast.newIfStatement();			newElseBlock.setExpression(ast.newBooleanLiteral(true));						Statement newBody2= (Statement) rewrite.createMovePlaceholder(ifStatement.getElseStatement());			newElseBlock.setThenStatement(newBody2);			rewrite.markAsReplaced(ifStatement.getElseStatement(), newElseBlock);					}		{ // replace then block by statement, replace else with if statement (block)			IfStatement ifStatement= (IfStatement) statements.get(3);						Block body= (Block) ifStatement.getThenStatement();			ASTNode statement= (ASTNode) body.statements().get(0);						ASTNode newBody= rewrite.createMovePlaceholder(statement);						rewrite.markAsReplaced(body, newBody);							IfStatement newElseBlock= ast.newIfStatement();			newElseBlock.setExpression(ast.newBooleanLiteral(true));						Statement newBody2= (Statement) rewrite.createMovePlaceholder(ifStatement.getElseStatement());			newElseBlock.setThenStatement(newBody2);			rewrite.markAsReplaced(ifStatement.getElseStatement(), newElseBlock);		}						String preview= evaluateRewrite(cu, rewrite);				buf= new StringBuffer();		buf.append("package test1;\n");		buf.append("public class E {\n");		buf.append("    public void foo() {\n");		buf.append("        if (i == 0) {\n");		buf.append("            System.beep();\n");		buf.append("        } else if (true)\n");		buf.append("            hoo(11);\n");					buf.append("        if (i == 0)\n");		buf.append("            System.beep();\n");		buf.append("        else if (true)\n");		buf.append("            hoo(11);\n");			buf.append("        if (i == 0) {\n");		buf.append("            System.beep();\n");		buf.append("        } else if (true) {\n");		buf.append("            hoo(11);\n");		buf.append("        }\n");				buf.append("        if (i == 0)\n");		buf.append("            System.beep();\n");		buf.append("        else if (true) {\n");		buf.append("            hoo(11);\n");		buf.append("        }\n");				buf.append("    }\n");		buf.append("}\n");			assertEqualString(preview, buf.toString());	}