rewrite.markAsReplaced(expression, newExpression);
rewrite.markAsReplaced(expression, newExpression, null);
	public void testSwitchStatement() 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(int i) {\n");		buf.append("        switch (i) {\n");		buf.append("        }\n");		buf.append("        switch (i) {\n");		buf.append("            case 1:\n");		buf.append("                i= 1;\n");		buf.append("                break;\n");			buf.append("            case 2:\n");		buf.append("                i= 2;\n");		buf.append("                break;\n");					buf.append("            default:\n");		buf.append("                i= 3;\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 blockStatements= block.statements();		assertTrue("Number of statements not 2", blockStatements.size() == 2);		{ // insert statements, replace expression			SwitchStatement switchStatement= (SwitchStatement) blockStatements.get(0);						ASTNode expression= switchStatement.getExpression();			SimpleName newExpression= ast.newSimpleName("x");				rewrite.markAsReplaced(expression, newExpression);						List statements= switchStatement.statements();			assertTrue("Number of statements not 0", statements.size() == 0);						SwitchCase caseStatement1= ast.newSwitchCase();			caseStatement1.setExpression(ast.newNumberLiteral("1"));						Statement statement1= ast.newReturnStatement();						SwitchCase caseStatement2= ast.newSwitchCase(); // default			caseStatement2.setExpression(null);						ListRewriter listRewrite= rewrite.getListRewrite(switchStatement, SwitchStatement.STATEMENTS_PROPERTY);			listRewrite.insertLast(caseStatement1, null);			listRewrite.insertLast(statement1, null);			listRewrite.insertLast(caseStatement2, null);		}				{ // insert, remove, replace statements, change case statements			SwitchStatement switchStatement= (SwitchStatement) blockStatements.get(1);						List statements= switchStatement.statements();			assertTrue("Number of statements not 8", statements.size() == 8);						// remove statements						rewrite.markAsRemoved((ASTNode) statements.get(0));			rewrite.markAsRemoved((ASTNode) statements.get(1));			rewrite.markAsRemoved((ASTNode) statements.get(2));						// change case statement			SwitchCase caseStatement= (SwitchCase) statements.get(3);			Expression newCaseExpression= ast.newNumberLiteral("10");			rewrite.markAsReplaced(caseStatement.getExpression(), newCaseExpression);						ListRewriter listRewrite= rewrite.getListRewrite(switchStatement, SwitchStatement.STATEMENTS_PROPERTY);						{				// insert case statement				SwitchCase caseStatement2= ast.newSwitchCase();				caseStatement2.setExpression(ast.newNumberLiteral("11"));				listRewrite.insertFirst(caseStatement2, null);					// insert statement				Statement statement1= ast.newReturnStatement();				listRewrite.insertAfter(statement1, caseStatement2, null);			}						{				// insert case statement				SwitchCase caseStatement2= ast.newSwitchCase();				caseStatement2.setExpression(ast.newNumberLiteral("12"));				listRewrite.insertLast(caseStatement2, null);					// insert statement				Statement statement1= ast.newReturnStatement();				listRewrite.insertAfter(statement1, caseStatement2, 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(int i) {\n");		buf.append("        switch (x) {\n");		buf.append("            case 1 :\n");		buf.append("                return;\n");		buf.append("            default :\n");					buf.append("        }\n");		buf.append("        switch (i) {\n");		buf.append("            case 11 :\n");		buf.append("                return;\n");		buf.append("            case 10:\n");				buf.append("                i= 2;\n");		buf.append("                break;\n");					buf.append("            default:\n");		buf.append("                i= 3;\n");		buf.append("            case 12 :\n");		buf.append("                return;\n");					buf.append("        }\n");		buf.append("    }\n");		buf.append("}\n");		assertEqualString(preview, buf.toString());	}