You can do it by getting List Rewriter of first TypeDeclaration by following code:
ListRewrite lrw = astRewriter.getListRewrite(((TypeDeclaration)compilationUnit.types().get(0)), TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
lrw.insertLast(methodDeclaration, null);
There you go.