returnStatement.setExpression(ASTResolving.getInitExpression(methodDecl.getReturnType()));
returnStatement.setExpression(ASTResolving.getInitExpression(methodDecl.getReturnType(), methodDecl.getExtraDimensions()));
	public void testAdd() throws Exception {		IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);		{	/* foo(): append a return statement */			StringBuffer buf= new StringBuffer();			buf.append("package test1;\n");			buf.append("public class C {\n");			buf.append("    public Object foo() {\n");			buf.append("        if (this.equals(new Object())) {\n");			buf.append("            toString();\n");			buf.append("        }\n");			buf.append("    }\n");			buf.append("}\n");				ICompilationUnit cu= pack1.createCompilationUnit("C.java", buf.toString(), false, null);					CompilationUnit astRoot= AST.parseCompilationUnit(cu, false);			ASTRewrite rewrite= new ASTRewrite(astRoot);			TypeDeclaration type= findTypeDeclaration(astRoot, "C");						MethodDeclaration methodDecl= findMethodDeclaration(type, "foo");			Block block= methodDecl.getBody();			assertTrue("No block" , block != null);							List statements= block.statements();			ReturnStatement returnStatement= block.getAST().newReturnStatement();			returnStatement.setExpression(ASTResolving.getInitExpression(methodDecl.getReturnType()));			statements.add(returnStatement);			rewrite.markAsInserted(returnStatement);						ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal("", cu, rewrite, 10, null);			proposal.getCompilationUnitChange().setSave(true);						proposal.apply(null);						buf= new StringBuffer();			buf.append("package test1;\n");			buf.append("public class C {\n");			buf.append("    public Object foo() {\n");			buf.append("        if (this.equals(new Object())) {\n");			buf.append("            toString();\n");			buf.append("        }\n");			buf.append("        return null;\n");			buf.append("    }\n");			buf.append("}\n");						assertEqualString(cu.getSource(), buf.toString());			clearRewrite(rewrite);		}		{	/* hoo(): return; -> return false;  */			StringBuffer buf= new StringBuffer();			buf.append("package test1;\n");			buf.append("public class D {\n");			buf.append("    public Object goo() {\n");			buf.append("        return new Integer(3);\n");			buf.append("    }\n");			buf.append("    public void hoo(int p1, Object p2) {\n");			buf.append("        return;\n");			buf.append("    }\n");					buf.append("}\n");				ICompilationUnit cu= pack1.createCompilationUnit("D.java", buf.toString(), false, null);						CompilationUnit astRoot= AST.parseCompilationUnit(cu, false);			ASTRewrite rewrite= new ASTRewrite(astRoot);			TypeDeclaration type= findTypeDeclaration(astRoot, "D");					MethodDeclaration methodDecl= findMethodDeclaration(type, "hoo");			Block block= methodDecl.getBody();			assertTrue("No block" , block != null);						List statements= block.statements();			assertTrue("No statements in block", !statements.isEmpty());			assertTrue("No ReturnStatement", statements.get(0) instanceof ReturnStatement);						ReturnStatement returnStatement= (ReturnStatement) statements.get(0);			Expression expr= block.getAST().newBooleanLiteral(false);						returnStatement.setExpression(expr);			rewrite.markAsInserted(expr);						ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal("", cu, rewrite, 10, null);			proposal.getCompilationUnitChange().setSave(true);						proposal.apply(null);						buf= new StringBuffer();			buf.append("package test1;\n");			buf.append("public class D {\n");			buf.append("    public Object goo() {\n");			buf.append("        return new Integer(3);\n");			buf.append("    }\n");			buf.append("    public void hoo(int p1, Object p2) {\n");			buf.append("        return false;\n");			buf.append("    }\n");					buf.append("}\n");							assertEqualString(cu.getSource(), buf.toString());						clearRewrite(rewrite);		}		{  // add after comment 			StringBuffer buf= new StringBuffer();			buf.append("package test1;\n");			buf.append("public class E {\n");			buf.append("    public Object goo() {\n");			buf.append("        i++; //comment\n");			buf.append("        i++; //comment\n");								buf.append("        return new Integer(3);\n");			buf.append("    }\n");			buf.append("}\n");				ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);						CompilationUnit astRoot= AST.parseCompilationUnit(cu, false);			ASTRewrite rewrite= new ASTRewrite(astRoot);			TypeDeclaration type= findTypeDeclaration(astRoot, "E");			AST ast= astRoot.getAST();					MethodDeclaration methodDecl= findMethodDeclaration(type, "goo");			Block block= methodDecl.getBody();			assertTrue("No block" , block != null);						MethodInvocation invocation1= ast.newMethodInvocation();			invocation1.setName(ast.newSimpleName("foo"));			ExpressionStatement statement1= ast.newExpressionStatement(invocation1);						rewrite.markAsInserted(statement1);						MethodInvocation invocation2= ast.newMethodInvocation();			invocation2.setName(ast.newSimpleName("foo"));			ExpressionStatement statement2= ast.newExpressionStatement(invocation2);						rewrite.markAsInserted(statement2);								List statements= methodDecl.getBody().statements();						rewrite.markAsRemoved((ASTNode) statements.get(1));						statements.add(2, statement2);			statements.add(1, statement1);						ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal("", cu, rewrite, 10, null);			proposal.getCompilationUnitChange().setSave(true);						proposal.apply(null);						buf= new StringBuffer();			buf.append("package test1;\n");			buf.append("public class E {\n");			buf.append("    public Object goo() {\n");			buf.append("        i++; //comment\n");			buf.append("        foo();\n");			buf.append("        foo();\n");							buf.append("        return new Integer(3);\n");			buf.append("    }\n");			buf.append("}\n");							assertEqualString(cu.getSource(), buf.toString());						clearRewrite(rewrite);		}					}