rewrite.markAsReplaced(forStatement.getBody(), newBody);
rewrite.markAsReplaced(forStatement.getBody(), newBody, null);
	public void testForStatement1() 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("        for (;;) {\n");		buf.append("            foo();\n");				buf.append("        }\n");			buf.append("        for (;;)\n");		buf.append("            foo();\n");			buf.append("        for (;;) {\n");		buf.append("            foo();\n");			buf.append("        }\n");			buf.append("        for (;;)\n");		buf.append("            foo();\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();		TypeDeclaration type= findTypeDeclaration(astRoot, "E");		MethodDeclaration methodDecl= findMethodDeclaration(type, "foo");		Block block= methodDecl.getBody();		assertTrue("Parse errors", (block.getFlags() & ASTNode.MALFORMED) == 0);				List statements= block.statements();		assertTrue("Number of statements not 4", statements.size() == 4);		{ // replace body block with statement			ForStatement forStatement= (ForStatement) statements.get(0);									TryStatement newTry= ast.newTryStatement();			newTry.getBody().statements().add(ast.newReturnStatement());			CatchClause newCatchClause= ast.newCatchClause();			SingleVariableDeclaration varDecl= ast.newSingleVariableDeclaration();			varDecl.setType(ast.newSimpleType(ast.newSimpleName("Exception")));			varDecl.setName(ast.newSimpleName("e"));			newCatchClause.setException(varDecl);			newTry.catchClauses().add(newCatchClause);						rewrite.markAsReplaced(forStatement.getBody(), newTry);		}		{ // replace body statement with block			ForStatement forStatement= (ForStatement) statements.get(1);						Block newBody= ast.newBlock();						MethodInvocation invocation= ast.newMethodInvocation();			invocation.setName(ast.newSimpleName("hoo"));			invocation.arguments().add(ast.newNumberLiteral("11"));						newBody.statements().add(ast.newExpressionStatement(invocation));						rewrite.markAsReplaced(forStatement.getBody(), newBody);		}		{ // replace body block with block			ForStatement forStatement= (ForStatement) statements.get(2);						Block newBody= ast.newBlock();						MethodInvocation invocation= ast.newMethodInvocation();			invocation.setName(ast.newSimpleName("hoo"));			invocation.arguments().add(ast.newNumberLiteral("11"));						newBody.statements().add(ast.newExpressionStatement(invocation));						rewrite.markAsReplaced(forStatement.getBody(), newBody);		}				{ // replace body statement with body			ForStatement forStatement= (ForStatement) statements.get(3);									TryStatement newTry= ast.newTryStatement();			newTry.getBody().statements().add(ast.newReturnStatement());			CatchClause newCatchClause= ast.newCatchClause();			SingleVariableDeclaration varDecl= ast.newSingleVariableDeclaration();			varDecl.setType(ast.newSimpleType(ast.newSimpleName("Exception")));			varDecl.setName(ast.newSimpleName("e"));			newCatchClause.setException(varDecl);			newTry.catchClauses().add(newCatchClause);						rewrite.markAsReplaced(forStatement.getBody(), newTry);		}						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("        for (;;)\n");		buf.append("            try {\n");		buf.append("                return;\n");		buf.append("            } catch (Exception e) {\n");		buf.append("            }\n");			buf.append("        for (;;) {\n");		buf.append("            hoo(11);\n");		buf.append("        }\n");			buf.append("        for (;;) {\n");		buf.append("            hoo(11);\n");		buf.append("        }\n");			buf.append("        for (;;)\n");		buf.append("            try {\n");		buf.append("                return;\n");		buf.append("            } catch (Exception e) {\n");		buf.append("            }\n");			buf.append("    }\n");		buf.append("}\n");			assertEqualString(preview, buf.toString());	}		