rewrite.markAsRemoved(outerType);
rewrite.markAsRemoved(outerType, null);
	public void testMoveDeclDifferentLevelCD() throws Exception {		IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);		StringBuffer buf= new StringBuffer();		buf.append("package test1;\n");		buf.append("public class E extends Exception implements Runnable, Serializable {\n");		buf.append("    public static class EInner {\n");		buf.append("        public void xee() {\n");		buf.append("            /* does nothing */\n");		buf.append("        }\n");		buf.append("    }\n");				buf.append("    private /* inner comment */ int i;\n");		buf.append("    private int k;\n");		buf.append("    public E() {\n");		buf.append("        super();\n");		buf.append("        i= 0;\n");		buf.append("        k= 9;\n");		buf.append("        if (System.out == null) {\n");		buf.append("            gee(); // cool\n");		buf.append("        }\n");		buf.append("    }\n");		buf.append("    public void gee() {\n");		buf.append("    }\n");		buf.append("}\n");		buf.append("interface G {\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("Code has errors", (astRoot.getFlags() & ASTNode.MALFORMED) == 0);				TypeDeclaration type= findTypeDeclaration(astRoot, "E");				{			List members= type.bodyDeclarations();			assertTrue("Has declarations", !members.isEmpty());						assertTrue("Cannot find inner class", members.get(0) instanceof TypeDeclaration);			TypeDeclaration innerType= (TypeDeclaration) members.get(0);						List innerMembers= innerType.bodyDeclarations();			assertTrue("Not expected number of inner members", innerMembers.size() == 1);						{ // move outer as inner of inner.				TypeDeclaration outerType= findTypeDeclaration(astRoot, "G");				assertTrue("G not found", outerType != null);								rewrite.markAsRemoved(outerType);								ASTNode insertNodeForCopy= rewrite.createCopyPlaceholder(outerType);								rewrite.getListRewrite(innerType, TypeDeclaration.BODY_DECLARATIONS_PROPERTY).insertLast(insertNodeForCopy, null);							}			{ // copy method of inner to main type				MethodDeclaration methodDecl= (MethodDeclaration) innerMembers.get(0);				ASTNode insertNodeForMove= rewrite.createCopyPlaceholder(methodDecl);								rewrite.getListRewrite(type, TypeDeclaration.BODY_DECLARATIONS_PROPERTY).insertLast(insertNodeForMove, null);			}			{ // nest body of constructor in a while statement				MethodDeclaration methodDecl= findMethodDeclaration(type, "E");				assertTrue("Cannot find Constructor E", methodDecl != null);				Block body= methodDecl.getBody();				WhileStatement whileStatement= ast.newWhileStatement();				whileStatement.setExpression(ast.newBooleanLiteral(true));								Statement insertNodeForCopy= (Statement) rewrite.createCopyPlaceholder(body);								whileStatement.setBody(insertNodeForCopy); // set existing body				Block newBody= ast.newBlock();				List newStatements= newBody.statements();								newStatements.add(whileStatement);								rewrite.markAsReplaced(body, newBody);			}					}								String preview= evaluateRewrite(cu, rewrite);				buf= new StringBuffer();		buf.append("package test1;\n");		buf.append("public class E extends Exception implements Runnable, Serializable {\n");		buf.append("    public static class EInner {\n");		buf.append("        public void xee() {\n");		buf.append("            /* does nothing */\n");		buf.append("        }\n");		buf.append("\n");					buf.append("        interface G {\n");		buf.append("        }\n");						buf.append("    }\n");				buf.append("    private /* inner comment */ int i;\n");		buf.append("    private int k;\n");		buf.append("    public E() {\n");		buf.append("        while (true) {\n");				buf.append("            super();\n");		buf.append("            i= 0;\n");		buf.append("            k= 9;\n");		buf.append("            if (System.out == null) {\n");		buf.append("                gee(); // cool\n");		buf.append("            }\n");		buf.append("        }\n");				buf.append("    }\n");		buf.append("    public void gee() {\n");		buf.append("    }\n");		buf.append("    public void xee() {\n");		buf.append("        /* does nothing */\n");		buf.append("    }\n");				buf.append("}\n");		assertEqualString(preview, buf.toString());	}