rewrite.markAsRemoved(secondException); rewrite.markAsRemoved(lastException);
rewrite.markAsRemoved(secondException, null); rewrite.markAsRemoved(lastException, null);
	public void testListInserts() throws Exception {		IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);		StringBuffer buf= new StringBuffer();		buf.append("package test1;\n");		buf.append("public abstract class E {\n");		buf.append("    public E(int p1, int p2, int p3) {}\n");		buf.append("    public void gee(int p1, int p2, int p3) throws IllegalArgumentException {}\n");		buf.append("    public void hee(int p1, int p2, int p3) throws IllegalArgumentException {}\n");		buf.append("    public void iee(int p1, int p2, int p3) throws IllegalArgumentException, IllegalAccessException {}\n");		buf.append("    public void jee(int p1, int p2, int p3) throws IllegalArgumentException, IllegalAccessException {}\n");		buf.append("    public abstract void kee(int p1, int p2, int p3) throws IllegalArgumentException, IllegalAccessException, SecurityException;\n");		buf.append("    public abstract void lee(int p1, int p2, int p3) throws IllegalArgumentException, IllegalAccessException, SecurityException;\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");				{ // insert before first param & insert an exception			MethodDeclaration methodDecl= findMethodDeclaration(type, "E");			List parameters= methodDecl.parameters();			assertTrue("must be 3 parameters", parameters.size() == 3);			SingleVariableDeclaration newParam= createNewParam(ast, "m");			rewrite.getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY).insertFirst(newParam, null);			List thrownExceptions= methodDecl.thrownExceptions();			assertTrue("must be 0 thrown exceptions", thrownExceptions.size() == 0);						Name newThrownException= ast.newSimpleName("InterruptedException");			rewrite.getListRewrite(methodDecl, MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY).insertFirst(newThrownException, null);		}		{ // insert before second param & insert before first exception & add synchronized			MethodDeclaration methodDecl= findMethodDeclaration(type, "gee");						// change flags			int newModifiers= Modifier.PUBLIC | Modifier.SYNCHRONIZED;			rewrite.markAsReplaced(methodDecl, MethodDeclaration.MODIFIERS_PROPERTY, new Integer(newModifiers), null);						List parameters= methodDecl.parameters();			assertTrue("must be 3 parameters", parameters.size() == 3);			ASTNode secondParam= (ASTNode) parameters.get(1);			SingleVariableDeclaration newParam= createNewParam(ast, "m");			rewrite.getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY).insertBefore(newParam, secondParam, null);			List thrownExceptions= methodDecl.thrownExceptions();			assertTrue("must be 1 thrown exceptions", thrownExceptions.size() == 1);						ASTNode firstException= (ASTNode) thrownExceptions.get(0);			Name newThrownException= ast.newSimpleName("InterruptedException");			rewrite.getListRewrite(methodDecl, MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY).insertBefore(newThrownException, firstException, null);		}				{ // insert after last param & insert after first exception & add synchronized, static			MethodDeclaration methodDecl= findMethodDeclaration(type, "hee");						// change flags			int newModifiers= Modifier.PUBLIC | Modifier.SYNCHRONIZED | Modifier.STATIC;			rewrite.markAsReplaced(methodDecl, MethodDeclaration.MODIFIERS_PROPERTY, new Integer(newModifiers), null);						List parameters= methodDecl.parameters();			assertTrue("must be 3 parameters", parameters.size() == 3);						SingleVariableDeclaration newParam= createNewParam(ast, "m");			rewrite.getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY).insertLast(newParam, null);			List thrownExceptions= methodDecl.thrownExceptions();			assertTrue("must be 1 thrown exceptions", thrownExceptions.size() == 1);						ASTNode firstException= (ASTNode) thrownExceptions.get(0);			Name newThrownException= ast.newSimpleName("InterruptedException");			rewrite.getListRewrite(methodDecl, MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY).insertAfter(newThrownException, firstException, null);		}						{ // insert 2 params before first & insert between two exception			MethodDeclaration methodDecl= findMethodDeclaration(type, "iee");			List parameters= methodDecl.parameters();			assertTrue("must be 3 parameters", parameters.size() == 3);			ASTNode firstParam= (ASTNode) parameters.get(0);						SingleVariableDeclaration newParam1= createNewParam(ast, "m1");			SingleVariableDeclaration newParam2= createNewParam(ast, "m2");						ListRewriter listRewrite = rewrite.getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY);			listRewrite.insertBefore(newParam1, firstParam, null);			listRewrite.insertBefore(newParam2, firstParam, null);			List thrownExceptions= methodDecl.thrownExceptions();			assertTrue("must be 2 thrown exceptions", thrownExceptions.size() == 2);						ASTNode firstException= (ASTNode) thrownExceptions.get(0);			Name newThrownException= ast.newSimpleName("InterruptedException");			rewrite.getListRewrite(methodDecl, MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY).insertAfter(newThrownException, firstException, null);		}					{ // insert 2 params after first & replace the second exception and insert new after			MethodDeclaration methodDecl= findMethodDeclaration(type, "jee");			List parameters= methodDecl.parameters();			assertTrue("must be 3 parameters", parameters.size() == 3);			ListRewriter listRewrite = rewrite.getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY);			ASTNode firstParam= (ASTNode) parameters.get(0);						SingleVariableDeclaration newParam1= createNewParam(ast, "m1");			SingleVariableDeclaration newParam2= createNewParam(ast, "m2");			listRewrite.insertAfter(newParam2, firstParam, null);			listRewrite.insertAfter(newParam1, firstParam, null);			List thrownExceptions= methodDecl.thrownExceptions();			assertTrue("must be 2 thrown exceptions", thrownExceptions.size() == 2);						Name newThrownException1= ast.newSimpleName("InterruptedException");			rewrite.getListRewrite(methodDecl, MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY).insertLast(newThrownException1, null);			Name newThrownException2= ast.newSimpleName("ArrayStoreException");			rewrite.markAsReplaced((ASTNode) thrownExceptions.get(1), newThrownException2);		}		{ // insert 2 params after last & remove the last exception and insert new after			MethodDeclaration methodDecl= findMethodDeclaration(type, "kee");			List parameters= methodDecl.parameters();			assertTrue("must be 3 parameters", parameters.size() == 3);			ListRewriter listRewrite= rewrite.getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY);			ASTNode lastParam= (ASTNode) parameters.get(2);						SingleVariableDeclaration newParam1= createNewParam(ast, "m1");			SingleVariableDeclaration newParam2= createNewParam(ast, "m2");			listRewrite.insertAfter(newParam2, lastParam, null);			listRewrite.insertAfter(newParam1, lastParam, null);						List thrownExceptions= methodDecl.thrownExceptions();			assertTrue("must be 3 thrown exceptions", thrownExceptions.size() == 3);						ASTNode lastException= (ASTNode) thrownExceptions.get(2);			rewrite.markAsRemoved(lastException);						Name newThrownException= ast.newSimpleName("InterruptedException");			rewrite.getListRewrite(methodDecl, MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY).insertBefore(newThrownException, lastException, null);		}			{ // insert at first and last position & remove 2nd, add after 2nd, remove 3rd			MethodDeclaration methodDecl= findMethodDeclaration(type, "lee");			List parameters= methodDecl.parameters();			assertTrue("must be 3 parameters", parameters.size() == 3);			ListRewriter listRewrite= rewrite.getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY);						SingleVariableDeclaration newParam1= createNewParam(ast, "m1");			SingleVariableDeclaration newParam2= createNewParam(ast, "m2");			listRewrite.insertFirst(newParam1, null);			listRewrite.insertLast(newParam2, null);						List thrownExceptions= methodDecl.thrownExceptions();			assertTrue("must be 3 thrown exceptions", thrownExceptions.size() == 3);						ASTNode secondException= (ASTNode) thrownExceptions.get(1);			ASTNode lastException= (ASTNode) thrownExceptions.get(2);			rewrite.markAsRemoved(secondException);			rewrite.markAsRemoved(lastException);						Name newThrownException= ast.newSimpleName("InterruptedException");			rewrite.getListRewrite(methodDecl, MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY).insertAfter(newThrownException, secondException, null);		}						String preview= evaluateRewrite(cu, rewrite);				buf= new StringBuffer();		buf.append("package test1;\n");		buf.append("public abstract class E {\n");		buf.append("    public E(float m, int p1, int p2, int p3) throws InterruptedException {}\n");		buf.append("    public synchronized void gee(int p1, float m, int p2, int p3) throws InterruptedException, IllegalArgumentException {}\n");		buf.append("    public static synchronized void hee(int p1, int p2, int p3, float m) throws IllegalArgumentException, InterruptedException {}\n");		buf.append("    public void iee(float m1, float m2, int p1, int p2, int p3) throws IllegalArgumentException, InterruptedException, IllegalAccessException {}\n");		buf.append("    public void jee(int p1, float m1, float m2, int p2, int p3) throws IllegalArgumentException, ArrayStoreException, InterruptedException {}\n");		buf.append("    public abstract void kee(int p1, int p2, int p3, float m1, float m2) throws IllegalArgumentException, IllegalAccessException, InterruptedException;\n");		buf.append("    public abstract void lee(float m1, int p1, int p2, int p3, float m2) throws IllegalArgumentException, InterruptedException;\n");		buf.append("}\n");						assertEqualString(preview, buf.toString());	}