rewrite.markAsReplaced((ASTNode) members.get(0), newFieldDecl);
rewrite.markAsReplaced((ASTNode) members.get(0), newFieldDecl, null);
	public void testTypeDeclChanges() 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("        }\n");				buf.append("    }\n");				buf.append("    private int i;\n");			buf.append("    private int k;\n");			buf.append("    public E() {\n");		buf.append("    }\n");		buf.append("    public void gee() {\n");		buf.append("    }\n");		buf.append("    public void hee() {\n");		buf.append("    }\n");		buf.append("}\n");		buf.append("class F implements Runnable {\n");		buf.append("    public void foo() {\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();				{  // rename type, rename supertype, rename first interface, replace inner class with field			TypeDeclaration type= findTypeDeclaration(astRoot, "E");			SimpleName name= type.getName();			SimpleName newName= ast.newSimpleName("X");						rewrite.markAsReplaced(name, newName);						Name superClass= type.getSuperclass();			assertTrue("Has super type", superClass != null);						SimpleName newSuperclass= ast.newSimpleName("Object");			rewrite.markAsReplaced(superClass, newSuperclass);			List superInterfaces= type.superInterfaces();			assertTrue("Has super interfaces", !superInterfaces.isEmpty());						SimpleName newSuperinterface= ast.newSimpleName("Cloneable");			rewrite.markAsReplaced((ASTNode) superInterfaces.get(0), newSuperinterface);						List members= type.bodyDeclarations();			assertTrue("Has declarations", !members.isEmpty());						FieldDeclaration newFieldDecl= createNewField(ast, "fCount");						rewrite.markAsReplaced((ASTNode) members.get(0), newFieldDecl);		}		{ // replace method in F, change to interface			TypeDeclaration type= findTypeDeclaration(astRoot, "F");						// change flags			int newModifiers= 0;			rewrite.markAsReplaced(type, TypeDeclaration.MODIFIERS_PROPERTY, new Integer(newModifiers), null);			// change to interface			rewrite.markAsReplaced(type, TypeDeclaration.INTERFACE_PROPERTY, Boolean.TRUE, null);						List members= type.bodyDeclarations();			assertTrue("Has declarations", members.size() == 1);			MethodDeclaration methodDecl= createNewMethod(ast, "newFoo", true);			rewrite.markAsReplaced((ASTNode) members.get(0), methodDecl);		}				{ // change to class, add supertype			TypeDeclaration type= findTypeDeclaration(astRoot, "G");						// change flags			int newModifiers= 0;			rewrite.markAsReplaced(type, TypeDeclaration.MODIFIERS_PROPERTY, new Integer(newModifiers), null);			// change to class			rewrite.markAsReplaced(type, TypeDeclaration.INTERFACE_PROPERTY, Boolean.FALSE, null);									SimpleName newSuperclass= ast.newSimpleName("Object");			rewrite.markAsInsert(type, TypeDeclaration.SUPERCLASS_PROPERTY, newSuperclass, null);		}										String preview= evaluateRewrite(cu, rewrite);				buf= new StringBuffer();		buf.append("package test1;\n");		buf.append("public class X extends Object implements Cloneable, Serializable {\n");		buf.append("    private double fCount;\n");		buf.append("    private int i;\n");			buf.append("    private int k;\n");		buf.append("    public E() {\n");		buf.append("    }\n");		buf.append("    public void gee() {\n");		buf.append("    }\n");		buf.append("    public void hee() {\n");		buf.append("    }\n");		buf.append("}\n");		buf.append("interface F extends Runnable {\n");		buf.append("    private abstract void newFoo(String str);\n");		buf.append("}\n");						buf.append("class G extends Object {\n");		buf.append("}\n");					assertEqualString(preview, buf.toString());	}