@@ -4274,13 +4274,7 @@ and print_pexp_apply ~state expr cmt_tbl =
4274
4274
let partial, attrs = ParsetreeViewer. process_partial_app_attribute attrs in
4275
4275
let args =
4276
4276
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
4284
4278
args @ [(Asttypes. Labelled " ..." , dummy)]
4285
4279
else args
4286
4280
in
@@ -4293,14 +4287,16 @@ and print_pexp_apply ~state expr cmt_tbl =
4293
4287
in
4294
4288
if ParsetreeViewer. requires_special_callback_printing_first_arg args then
4295
4289
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
4297
4292
in
4298
4293
Doc. concat
4299
4294
[print_attributes ~state attrs cmt_tbl; call_expr_doc; args_doc]
4300
4295
else if ParsetreeViewer. requires_special_callback_printing_last_arg args
4301
4296
then
4302
4297
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
4304
4300
in
4305
4301
(*
4306
4302
* Fixes the following layout (the `[` and `]` should break):
@@ -4663,7 +4659,8 @@ and print_jsx_name {txt = lident} =
4663
4659
let segments = flatten [] lident in
4664
4660
Doc. join ~sep: Doc. dot segments
4665
4661
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
+ =
4667
4664
(* Because the same subtree gets printed twice, we need to copy the cmt_tbl.
4668
4665
* consumed comments need to be marked not-consumed and reprinted…
4669
4666
* Cheng's different comment algorithm will solve this. *)
@@ -4723,7 +4720,9 @@ and print_arguments_with_callback_in_first_position ~state args cmt_tbl =
4723
4720
* arg3,
4724
4721
* )
4725
4722
*)
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
4727
4726
4728
4727
(* Sometimes one of the non-callback arguments will break.
4729
4728
* 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 =
4746
4745
else
4747
4746
Doc. custom_layout [Lazy. force fits_on_one_line; Lazy. force break_all_args]
4748
4747
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
+ =
4750
4750
(* Because the same subtree gets printed twice, we need to copy the cmt_tbl.
4751
4751
* consumed comments need to be marked not-consumed and reprinted…
4752
4752
* Cheng's different comment algorithm will solve this. *)
@@ -4820,7 +4820,9 @@ and print_arguments_with_callback_in_last_position ~state args cmt_tbl =
4820
4820
* (param1, parm2) => doStuff(param1, parm2)
4821
4821
* )
4822
4822
*)
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
4824
4826
4825
4827
(* Sometimes one of the non-callback arguments will break.
4826
4828
* 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 =
4848
4850
Lazy. force break_all_args;
4849
4851
]
4850
4852
4851
- and print_arguments ~state ?( partial = false )
4853
+ and print_arguments ~state ~ partial
4852
4854
(args : (Asttypes.arg_label * Parsetree.expression) list ) cmt_tbl =
4853
4855
match args with
4854
4856
| [
@@ -4878,16 +4880,8 @@ and print_arguments ~state ?(partial = false)
4878
4880
Doc. concat [Doc. lparen; arg_doc; Doc. rparen]
4879
4881
| args ->
4880
4882
(* 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
4891
4885
in
4892
4886
Doc. group
4893
4887
(Doc. concat
@@ -4899,7 +4893,7 @@ and print_arguments ~state ?(partial = false)
4899
4893
Doc. soft_line;
4900
4894
Doc. join ~sep: (Doc. concat [Doc. comma; Doc. line]) printed_args;
4901
4895
]);
4902
- (if partial || has_partial_attr then Doc. nil else Doc. trailing_comma);
4896
+ (if partial then Doc. nil else Doc. trailing_comma);
4903
4897
Doc. soft_line;
4904
4898
Doc. rparen;
4905
4899
])
0 commit comments