rewrite.markAsInsert(type, TypeDeclaration.SUPERCLASS_PROPERTY, newSuperclass, null);
rewrite.set(type, TypeDeclaration.SUPERCLASS_PROPERTY, newSuperclass, null);
	public void testTypeDeclInserts() 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());		assertTrue("Errors in AST", (astRoot.getFlags() & ASTNode.MALFORMED) == 0);		AST ast= astRoot.getAST();		{ // add interface & set to final			TypeDeclaration type= findTypeDeclaration(astRoot, "E");								// change flags			int newModifiers= Modifier.PUBLIC | Modifier.FINAL;			rewrite.markAsReplaced(type, TypeDeclaration.MODIFIERS_PROPERTY, new Integer(newModifiers), null);							SimpleName newSuperinterface= ast.newSimpleName("Cloneable");						rewrite.getListRewrite(type, TypeDeclaration.SUPER_INTERFACES_PROPERTY).insertFirst(newSuperinterface, null);						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);/*		bug 22161			SimpleName newSuperclass= ast.newSimpleName("Exception");			innerType.setSuperclass(newSuperclass);			rewrite.markAsInserted(newSuperclass);*/			FieldDeclaration newField= createNewField(ast, "fCount");						rewrite.getListRewrite(innerType, TypeDeclaration.BODY_DECLARATIONS_PROPERTY).insertFirst(newField, null);						MethodDeclaration newMethodDecl= createNewMethod(ast, "newMethod", false);			rewrite.getListRewrite(type, TypeDeclaration.BODY_DECLARATIONS_PROPERTY).insertAt(newMethodDecl, 4, null);		}		{ // add exception, add method			TypeDeclaration type= findTypeDeclaration(astRoot, "F");						SimpleName newSuperclass= ast.newSimpleName("Exception");			rewrite.markAsInsert(type, TypeDeclaration.SUPERCLASS_PROPERTY, newSuperclass, null);								MethodDeclaration newMethodDecl= createNewMethod(ast, "newMethod", false);			rewrite.getListRewrite(type, TypeDeclaration.BODY_DECLARATIONS_PROPERTY).insertLast(newMethodDecl, null);		}					{ // insert interface			TypeDeclaration type= findTypeDeclaration(astRoot, "G");									SimpleName newInterface= ast.newSimpleName("Runnable");			rewrite.getListRewrite(type, TypeDeclaration.SUPER_INTERFACES_PROPERTY).insertLast(newInterface, null);						MethodDeclaration newMethodDecl= createNewMethod(ast, "newMethod", true);			rewrite.getListRewrite(type, TypeDeclaration.BODY_DECLARATIONS_PROPERTY).insertLast(newMethodDecl,  null);		}					String preview= evaluateRewrite(cu, rewrite);				buf= new StringBuffer();		buf.append("package test1;\n");		buf.append("public final class E extends Exception implements Cloneable, Runnable, Serializable {\n");		buf.append("    public static class EInner {\n");		buf.append("        private double fCount;\n");		buf.append("\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("    private void newMethod(String str) {\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 extends Exception implements Runnable {\n");		buf.append("    public void foo() {\n");		buf.append("    }\n");		buf.append("\n");		buf.append("    private void newMethod(String str) {\n");		buf.append("    }\n");				buf.append("}\n");						buf.append("interface G extends Runnable {\n");		buf.append("\n");				buf.append("    private abstract void newMethod(String str);\n");				buf.append("}\n");			assertEqualString(preview, buf.toString());	}