rewrite.markAsReplaced(ifStatement.getExpression(), literal);
rewrite.markAsReplaced(ifStatement.getExpression(), literal, null);
	public void testIfStatement() 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("        }\n");		buf.append("        if (i == 0) {\n");		buf.append("            System.beep();\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 2", statements.size() == 2);		{ // replace expression body and then body, remove else body			IfStatement ifStatement= (IfStatement) statements.get(0);						BooleanLiteral literal= ast.newBooleanLiteral(true);			rewrite.markAsReplaced(ifStatement.getExpression(), literal);									MethodInvocation invocation= ast.newMethodInvocation();			invocation.setName(ast.newSimpleName("hoo"));			invocation.arguments().add(ast.newNumberLiteral("11"));			Block newBody= ast.newBlock();			newBody.statements().add(ast.newExpressionStatement(invocation));						rewrite.markAsReplaced(ifStatement.getThenStatement(), newBody);						rewrite.markAsRemoved(ifStatement.getElseStatement());		}		{ // add else body			IfStatement ifStatement= (IfStatement) statements.get(1);						MethodInvocation invocation= ast.newMethodInvocation();			invocation.setName(ast.newSimpleName("hoo"));			invocation.arguments().add(ast.newNumberLiteral("11"));			Block newBody= ast.newBlock();			newBody.statements().add(ast.newExpressionStatement(invocation));						rewrite.markAsInsert(ifStatement, IfStatement.ELSE_STATEMENT_PROPERTY, newBody, null);		}										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 (true) {\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");			assertEqualString(preview, buf.toString());	}