@@ -4274,13 +4274,7 @@ and print_pexp_apply ~state expr cmt_tbl =
42744274 let partial, attrs = ParsetreeViewer. process_partial_app_attribute attrs in
42754275 let args =
42764276 if partial then
4277- let loc =
4278- {Asttypes. txt = " res.partial" ; Asttypes. loc = expr.pexp_loc}
4279- in
4280- let attr = (loc, Parsetree. PTyp (Ast_helper.Typ. any () )) in
4281- let dummy =
4282- Ast_helper.Exp. constant ~attrs: [attr] (Ast_helper.Const. int 0 )
4283- in
4277+ let dummy = Ast_helper.Exp. constant ~attrs (Ast_helper.Const. int 0 ) in
42844278 args @ [(Asttypes. Labelled " ..." , dummy)]
42854279 else args
42864280 in
@@ -4293,14 +4287,16 @@ and print_pexp_apply ~state expr cmt_tbl =
42934287 in
42944288 if ParsetreeViewer. requires_special_callback_printing_first_arg args then
42954289 let args_doc =
4296- print_arguments_with_callback_in_first_position ~state args cmt_tbl
4290+ print_arguments_with_callback_in_first_position ~state ~partial args
4291+ cmt_tbl
42974292 in
42984293 Doc. concat
42994294 [print_attributes ~state attrs cmt_tbl; call_expr_doc; args_doc]
43004295 else if ParsetreeViewer. requires_special_callback_printing_last_arg args
43014296 then
43024297 let args_doc =
4303- print_arguments_with_callback_in_last_position ~state args cmt_tbl
4298+ print_arguments_with_callback_in_last_position ~state ~partial args
4299+ cmt_tbl
43044300 in
43054301 (*
43064302 * Fixes the following layout (the `[` and `]` should break):
@@ -4663,7 +4659,8 @@ and print_jsx_name {txt = lident} =
46634659 let segments = flatten [] lident in
46644660 Doc. join ~sep: Doc. dot segments
46654661
4666- and print_arguments_with_callback_in_first_position ~state args cmt_tbl =
4662+ and print_arguments_with_callback_in_first_position ~state ~partial args cmt_tbl
4663+ =
46674664 (* Because the same subtree gets printed twice, we need to copy the cmt_tbl.
46684665 * consumed comments need to be marked not-consumed and reprinted…
46694666 * Cheng's different comment algorithm will solve this. *)
@@ -4723,7 +4720,9 @@ and print_arguments_with_callback_in_first_position ~state args cmt_tbl =
47234720 * arg3,
47244721 * )
47254722 *)
4726- let break_all_args = lazy (print_arguments ~state args cmt_tbl_copy) in
4723+ let break_all_args =
4724+ lazy (print_arguments ~state ~partial args cmt_tbl_copy)
4725+ in
47274726
47284727 (* Sometimes one of the non-callback arguments will break.
47294728 * There might be a single line comment in there, or a multiline string etc.
@@ -4746,7 +4745,8 @@ and print_arguments_with_callback_in_first_position ~state args cmt_tbl =
47464745 else
47474746 Doc. custom_layout [Lazy. force fits_on_one_line; Lazy. force break_all_args]
47484747
4749- and print_arguments_with_callback_in_last_position ~state args cmt_tbl =
4748+ and print_arguments_with_callback_in_last_position ~state ~partial args cmt_tbl
4749+ =
47504750 (* Because the same subtree gets printed twice, we need to copy the cmt_tbl.
47514751 * consumed comments need to be marked not-consumed and reprinted…
47524752 * Cheng's different comment algorithm will solve this. *)
@@ -4820,7 +4820,9 @@ and print_arguments_with_callback_in_last_position ~state args cmt_tbl =
48204820 * (param1, parm2) => doStuff(param1, parm2)
48214821 * )
48224822 *)
4823- let break_all_args = lazy (print_arguments ~state args cmt_tbl_copy2) in
4823+ let break_all_args =
4824+ lazy (print_arguments ~state ~partial args cmt_tbl_copy2)
4825+ in
48244826
48254827 (* Sometimes one of the non-callback arguments will break.
48264828 * There might be a single line comment in there, or a multiline string etc.
@@ -4848,7 +4850,7 @@ and print_arguments_with_callback_in_last_position ~state args cmt_tbl =
48484850 Lazy. force break_all_args;
48494851 ]
48504852
4851- and print_arguments ~state ?( partial = false )
4853+ and print_arguments ~state ~ partial
48524854 (args : (Asttypes.arg_label * Parsetree.expression) list ) cmt_tbl =
48534855 match args with
48544856 | [
@@ -4878,16 +4880,8 @@ and print_arguments ~state ?(partial = false)
48784880 Doc. concat [Doc. lparen; arg_doc; Doc. rparen]
48794881 | args ->
48804882 (* Avoid printing trailing comma when there is ... in function application *)
4881- let has_partial_attr, printed_args =
4882- List. fold_right
4883- (fun arg (flag , acc ) ->
4884- let _, expr = arg in
4885- let has_partial_attr =
4886- ParsetreeViewer. has_partial_attribute expr.Parsetree. pexp_attributes
4887- in
4888- let doc = print_argument ~state arg cmt_tbl in
4889- (flag || has_partial_attr, doc :: acc))
4890- args (false , [] )
4883+ let printed_args =
4884+ List. map (fun arg -> print_argument ~state arg cmt_tbl) args
48914885 in
48924886 Doc. group
48934887 (Doc. concat
@@ -4899,7 +4893,7 @@ and print_arguments ~state ?(partial = false)
48994893 Doc. soft_line;
49004894 Doc. join ~sep: (Doc. concat [Doc. comma; Doc. line]) printed_args;
49014895 ]);
4902- (if partial || has_partial_attr then Doc. nil else Doc. trailing_comma);
4896+ (if partial then Doc. nil else Doc. trailing_comma);
49034897 Doc. soft_line;
49044898 Doc. rparen;
49054899 ])
0 commit comments