@@ -4152,7 +4152,6 @@ and print_pexp_apply ~state expr cmt_tbl =
4152
4152
args @ [(Asttypes. Labelled " ..." , dummy)]
4153
4153
else args
4154
4154
in
4155
- let dotted = false in
4156
4155
let call_expr_doc =
4157
4156
let doc = print_expression_with_comments ~state call_expr cmt_tbl in
4158
4157
match Parens. call_expr call_expr with
@@ -4162,16 +4161,14 @@ and print_pexp_apply ~state expr cmt_tbl =
4162
4161
in
4163
4162
if ParsetreeViewer. requires_special_callback_printing_first_arg args then
4164
4163
let args_doc =
4165
- print_arguments_with_callback_in_first_position ~dotted ~state args
4166
- cmt_tbl
4164
+ print_arguments_with_callback_in_first_position ~state args cmt_tbl
4167
4165
in
4168
4166
Doc. concat
4169
4167
[print_attributes ~state attrs cmt_tbl; call_expr_doc; args_doc]
4170
4168
else if ParsetreeViewer. requires_special_callback_printing_last_arg args
4171
4169
then
4172
4170
let args_doc =
4173
- print_arguments_with_callback_in_last_position ~state ~dotted args
4174
- cmt_tbl
4171
+ print_arguments_with_callback_in_last_position ~state args cmt_tbl
4175
4172
in
4176
4173
(*
4177
4174
* Fixes the following layout (the `[` and `]` should break):
@@ -4198,7 +4195,7 @@ and print_pexp_apply ~state expr cmt_tbl =
4198
4195
args_doc;
4199
4196
]
4200
4197
else
4201
- let args_doc = print_arguments ~state ~dotted ~ partial args cmt_tbl in
4198
+ let args_doc = print_arguments ~state ~partial args cmt_tbl in
4202
4199
Doc. concat
4203
4200
[print_attributes ~state attrs cmt_tbl; call_expr_doc; args_doc]
4204
4201
| _ -> assert false
@@ -4534,8 +4531,7 @@ and print_jsx_name {txt = lident} =
4534
4531
let segments = flatten [] lident in
4535
4532
Doc. join ~sep: Doc. dot segments
4536
4533
4537
- and print_arguments_with_callback_in_first_position ~dotted ~state args cmt_tbl
4538
- =
4534
+ and print_arguments_with_callback_in_first_position ~state args cmt_tbl =
4539
4535
(* Because the same subtree gets printed twice, we need to copy the cmtTbl.
4540
4536
* consumed comments need to be marked not-consumed and reprinted…
4541
4537
* Cheng's different comment algorithm will solve this. *)
@@ -4579,7 +4575,7 @@ and print_arguments_with_callback_in_first_position ~dotted ~state args cmt_tbl
4579
4575
lazy
4580
4576
(Doc. concat
4581
4577
[
4582
- ( if dotted then Doc. text " (. " else Doc. lparen) ;
4578
+ Doc. lparen;
4583
4579
Lazy. force callback;
4584
4580
Doc. comma;
4585
4581
Doc. line;
@@ -4595,9 +4591,7 @@ and print_arguments_with_callback_in_first_position ~dotted ~state args cmt_tbl
4595
4591
* arg3,
4596
4592
* )
4597
4593
*)
4598
- let break_all_args =
4599
- lazy (print_arguments ~state ~dotted args cmt_tbl_copy)
4600
- in
4594
+ let break_all_args = lazy (print_arguments ~state args cmt_tbl_copy) in
4601
4595
4602
4596
(* Sometimes one of the non-callback arguments will break.
4603
4597
* There might be a single line comment in there, or a multiline string etc.
@@ -4620,7 +4614,7 @@ and print_arguments_with_callback_in_first_position ~dotted ~state args cmt_tbl
4620
4614
else
4621
4615
Doc. custom_layout [Lazy. force fits_on_one_line; Lazy. force break_all_args]
4622
4616
4623
- and print_arguments_with_callback_in_last_position ~state ~ dotted args cmt_tbl =
4617
+ and print_arguments_with_callback_in_last_position ~state args cmt_tbl =
4624
4618
(* Because the same subtree gets printed twice, we need to copy the cmtTbl.
4625
4619
* consumed comments need to be marked not-consumed and reprinted…
4626
4620
* Cheng's different comment algorithm will solve this. *)
@@ -4669,12 +4663,7 @@ and print_arguments_with_callback_in_last_position ~state ~dotted args cmt_tbl =
4669
4663
let fits_on_one_line =
4670
4664
lazy
4671
4665
(Doc. concat
4672
- [
4673
- (if dotted then Doc. text " (." else Doc. lparen);
4674
- Lazy. force printed_args;
4675
- Lazy. force callback;
4676
- Doc. rparen;
4677
- ])
4666
+ [Doc. lparen; Lazy. force printed_args; Lazy. force callback; Doc. rparen])
4678
4667
in
4679
4668
4680
4669
(* Thing.map(longArgumet, veryLooooongArgument, (arg1, arg2) =>
@@ -4685,7 +4674,7 @@ and print_arguments_with_callback_in_last_position ~state ~dotted args cmt_tbl =
4685
4674
lazy
4686
4675
(Doc. concat
4687
4676
[
4688
- ( if dotted then Doc. text " (. " else Doc. lparen) ;
4677
+ Doc. lparen;
4689
4678
Lazy. force printed_args;
4690
4679
Doc. breakable_group ~force_break: true (Lazy. force callback2);
4691
4680
Doc. rparen;
@@ -4699,9 +4688,7 @@ and print_arguments_with_callback_in_last_position ~state ~dotted args cmt_tbl =
4699
4688
* (param1, parm2) => doStuff(param1, parm2)
4700
4689
* )
4701
4690
*)
4702
- let break_all_args =
4703
- lazy (print_arguments ~state ~dotted args cmt_tbl_copy2)
4704
- in
4691
+ let break_all_args = lazy (print_arguments ~state args cmt_tbl_copy2) in
4705
4692
4706
4693
(* Sometimes one of the non-callback arguments will break.
4707
4694
* There might be a single line comment in there, or a multiline string etc.
@@ -4729,23 +4716,12 @@ and print_arguments_with_callback_in_last_position ~state ~dotted args cmt_tbl =
4729
4716
Lazy. force break_all_args;
4730
4717
]
4731
4718
4732
- and print_arguments ~state ~ dotted ?(partial = false )
4719
+ and print_arguments ~state ?(partial = false )
4733
4720
(args : (Asttypes.arg_label * Parsetree.expression) list ) cmt_tbl =
4734
4721
match args with
4735
- | [
4736
- ( Nolabel ,
4737
- {
4738
- pexp_desc = Pexp_construct ({txt = Longident. Lident " ()" }, _);
4739
- pexp_loc = loc;
4740
- } );
4741
- ] -> (
4742
- (* See "parseCallExpr", ghost unit expression is used the implement
4743
- * arity zero vs arity one syntax.
4744
- * Related: https://github.com/rescript-lang/syntax/issues/138 *)
4745
- match (dotted, loc.loc_ghost) with
4746
- | true , true -> Doc. text " (.)" (* arity zero *)
4747
- | true , false -> Doc. text " (. ())" (* arity one *)
4748
- | _ -> Doc. text " ()" )
4722
+ | [(Nolabel , {pexp_desc = Pexp_construct ({txt = Longident. Lident " ()" }, _)})]
4723
+ ->
4724
+ Doc. text " ()"
4749
4725
| [(Nolabel , arg)] when ParsetreeViewer. is_huggable_expression arg ->
4750
4726
let arg_doc =
4751
4727
let doc = print_expression_with_comments ~state arg cmt_tbl in
@@ -4754,17 +4730,16 @@ and print_arguments ~state ~dotted ?(partial = false)
4754
4730
| Braced braces -> print_braces doc arg braces
4755
4731
| Nothing -> doc
4756
4732
in
4757
- Doc. concat
4758
- [(if dotted then Doc. text " (. " else Doc. lparen); arg_doc; Doc. rparen]
4733
+ Doc. concat [Doc. lparen; arg_doc; Doc. rparen]
4759
4734
| args ->
4760
4735
Doc. group
4761
4736
(Doc. concat
4762
4737
[
4763
- ( if dotted then Doc. text " (. " else Doc. lparen) ;
4738
+ Doc. lparen;
4764
4739
Doc. indent
4765
4740
(Doc. concat
4766
4741
[
4767
- ( if dotted then Doc. line else Doc. soft_line) ;
4742
+ Doc. soft_line;
4768
4743
Doc. join
4769
4744
~sep: (Doc. concat [Doc. comma; Doc. line])
4770
4745
(List. map
@@ -4967,7 +4942,6 @@ and print_case ~state (case : Parsetree.case) cmt_tbl =
4967
4942
4968
4943
and print_expr_fun_parameters ~state ~in_callback ~async ~has_constraint
4969
4944
parameters cmt_tbl =
4970
- let dotted = false in
4971
4945
match parameters with
4972
4946
(* let f = _ => () *)
4973
4947
| [
@@ -4978,8 +4952,7 @@ and print_expr_fun_parameters ~state ~in_callback ~async ~has_constraint
4978
4952
default_expr = None ;
4979
4953
pat = {Parsetree. ppat_desc = Ppat_any ; ppat_loc};
4980
4954
};
4981
- ]
4982
- when not dotted ->
4955
+ ] ->
4983
4956
let any =
4984
4957
let doc = if has_constraint then Doc. text " (_)" else Doc. text " _" in
4985
4958
print_comments doc cmt_tbl ppat_loc
@@ -4998,8 +4971,7 @@ and print_expr_fun_parameters ~state ~in_callback ~async ~has_constraint
4998
4971
Parsetree. ppat_attributes = attrs;
4999
4972
};
5000
4973
};
5001
- ]
5002
- when not dotted ->
4974
+ ] ->
5003
4975
let txt_doc =
5004
4976
let var = print_ident_like string_loc.txt in
5005
4977
let var =
@@ -5022,8 +4994,7 @@ and print_expr_fun_parameters ~state ~in_callback ~async ~has_constraint
5022
4994
pat =
5023
4995
{ppat_desc = Ppat_construct ({txt = Longident. Lident " ()" ; loc}, None )};
5024
4996
};
5025
- ]
5026
- when not dotted ->
4997
+ ] ->
5027
4998
let doc =
5028
4999
let lparen_rparen = Doc. text " ()" in
5029
5000
if async then add_async lparen_rparen else lparen_rparen
@@ -5037,7 +5008,7 @@ and print_expr_fun_parameters ~state ~in_callback ~async ~has_constraint
5037
5008
| _ -> false
5038
5009
in
5039
5010
let maybe_async_lparen =
5040
- let lparen = if dotted then Doc. text " (. " else Doc. lparen in
5011
+ let lparen = Doc. lparen in
5041
5012
if async then add_async lparen else lparen
5042
5013
in
5043
5014
let should_hug = ParsetreeViewer. parameters_should_hug parameters in
@@ -5142,12 +5113,7 @@ and print_exp_fun_parameter ~state parameter cmt_tbl =
5142
5113
let doc =
5143
5114
Doc. group
5144
5115
(Doc. concat
5145
- [
5146
- attrs;
5147
- label_with_pattern;
5148
- default_expr_doc;
5149
- optional_label_suffix;
5150
- ])
5116
+ [attrs; label_with_pattern; default_expr_doc; optional_label_suffix])
5151
5117
in
5152
5118
let cmt_loc =
5153
5119
match default_expr with
0 commit comments