rewrite.markAsReplaced((ASTNode) expressions.get(0), literal1); rewrite.markAsReplaced((ASTNode) expressions.get(2), literal2);
rewrite.markAsReplaced((ASTNode) expressions.get(0), literal1, null); rewrite.markAsReplaced((ASTNode) expressions.get(2), literal2, null);
	public void testArrayInitializer() 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("        goo(new int[] { 1, 2, 3 },\n");		buf.append("        new int[] { 1, 2, 3 },\n");		buf.append("        new int[] { 1, 2, 3 });\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();				assertTrue("Parse errors", (astRoot.getFlags() & ASTNode.MALFORMED) == 0);		TypeDeclaration type= findTypeDeclaration(astRoot, "E");		MethodDeclaration methodDecl= findMethodDeclaration(type, "foo");		Block block= methodDecl.getBody();		List statements= block.statements();		assertTrue("Number of statements not 1", statements.size() == 1);		ExpressionStatement statement= (ExpressionStatement) statements.get(0);		MethodInvocation invocation= (MethodInvocation) statement.getExpression();		List args= invocation.arguments();			{	// remove first and last initializer expression			ArrayCreation arrayCreation= (ArrayCreation) args.get(0);			ArrayInitializer initializer= arrayCreation.getInitializer();						List expressions= initializer.expressions();			assertTrue("Number of initializer expressions not 3", expressions.size() == 3);						rewrite.markAsRemoved((ASTNode) expressions.get(0));			rewrite.markAsRemoved((ASTNode) expressions.get(2));		}		{	// insert at second and last position			ArrayCreation arrayCreation= (ArrayCreation) args.get(1);			ArrayInitializer initializer= arrayCreation.getInitializer();						List expressions= initializer.expressions();			assertTrue("Number of initializer expressions not 3", expressions.size() == 3);			NumberLiteral literal1= ast.newNumberLiteral("10");			rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY).insertAfter(literal1, (ASTNode) expressions.get(0), null);						NumberLiteral literal2= ast.newNumberLiteral("11");			rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY).insertLast(literal2, null);		}				{	// replace first and last initializer expression			ArrayCreation arrayCreation= (ArrayCreation) args.get(2);			ArrayInitializer initializer= arrayCreation.getInitializer();						List expressions= initializer.expressions();			assertTrue("Number of initializer expressions not 3", expressions.size() == 3);			NumberLiteral literal1= ast.newNumberLiteral("10");			NumberLiteral literal2= ast.newNumberLiteral("11");						rewrite.markAsReplaced((ASTNode) expressions.get(0), literal1);			rewrite.markAsReplaced((ASTNode) expressions.get(2), literal2);		}								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("        goo(new int[] { 2 },\n");		buf.append("        new int[] { 1, 10, 2, 3, 11 },\n");		buf.append("        new int[] { 10, 2, 11 });\n");		buf.append("    }\n");		buf.append("}\n");			assertEqualString(preview, buf.toString());			}