Program previewProgram = previewParser.createAST(null);
previewProgram.recordModifications();
AST previewAST = previewProgram.getAST();
FunctionDeclaration function = previewAST.newFunctionDeclaration(previewAST.newIdentifier(fMethodName), computeArguments(previewAST), previewAST.newBlock(), false);
MethodDeclaration method = previewAST.newMethodDeclaration(fModifierAccessFlag, function);
previewProgram.statements().add(method);
Document myDoc = new Document();
previewProgram.rewrite(myDoc, null).apply(myDoc);