@@ -3135,8 +3135,8 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
3135
3135
cmtTbl
3136
3136
| Pexp_fun _ | Pexp_newtype _ ->
3137
3137
let attrsOnArrow, parameters, returnExpr = ParsetreeViewer. funExpr e in
3138
- let uncurried, attrs =
3139
- ParsetreeViewer. processUncurriedAttribute attrsOnArrow
3138
+ let async, uncurried, attrs =
3139
+ ParsetreeViewer. processFunctionAttributes attrsOnArrow
3140
3140
in
3141
3141
let returnExpr, typConstraint =
3142
3142
match returnExpr.pexp_desc with
@@ -3156,7 +3156,7 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
3156
3156
in
3157
3157
let parametersDoc =
3158
3158
printExprFunParameters ~custom Layout ~in Callback:NoCallback ~uncurried
3159
- ~has Constraint parameters cmtTbl
3159
+ ~async ~ has Constraint parameters cmtTbl
3160
3160
in
3161
3161
let returnExprDoc =
3162
3162
let optBraces, _ = ParsetreeViewer. processBracesAttr returnExpr in
@@ -3298,8 +3298,8 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
3298
3298
3299
3299
and printPexpFun ~customLayout ~inCallback e cmtTbl =
3300
3300
let attrsOnArrow, parameters, returnExpr = ParsetreeViewer. funExpr e in
3301
- let uncurried, attrs =
3302
- ParsetreeViewer. processUncurriedAttribute attrsOnArrow
3301
+ let async, uncurried, attrs =
3302
+ ParsetreeViewer. processFunctionAttributes attrsOnArrow
3303
3303
in
3304
3304
let returnExpr, typConstraint =
3305
3305
match returnExpr.pexp_desc with
@@ -3313,7 +3313,7 @@ and printPexpFun ~customLayout ~inCallback e cmtTbl =
3313
3313
| _ -> (returnExpr, None )
3314
3314
in
3315
3315
let parametersDoc =
3316
- printExprFunParameters ~custom Layout ~in Callback ~uncurried
3316
+ printExprFunParameters ~custom Layout ~in Callback ~async ~ uncurried
3317
3317
~has Constraint:
3318
3318
(match typConstraint with
3319
3319
| Some _ -> true
@@ -4575,8 +4575,8 @@ and printCase ~customLayout (case : Parsetree.case) cmtTbl =
4575
4575
in
4576
4576
Doc. group (Doc. concat [Doc. text " | " ; content])
4577
4577
4578
- and printExprFunParameters ~customLayout ~inCallback ~uncurried ~ hasConstraint
4579
- parameters cmtTbl =
4578
+ and printExprFunParameters ~customLayout ~inCallback ~async ~ uncurried
4579
+ ~ hasConstraint parameters cmtTbl =
4580
4580
match parameters with
4581
4581
(* let f = _ => () *)
4582
4582
| [
@@ -4589,7 +4589,8 @@ and printExprFunParameters ~customLayout ~inCallback ~uncurried ~hasConstraint
4589
4589
};
4590
4590
]
4591
4591
when not uncurried ->
4592
- if hasConstraint then Doc. text " (_)" else Doc. text " _"
4592
+ let any = if hasConstraint then Doc. text " (_)" else Doc. text " _" in
4593
+ if async then Doc. concat [Doc. text " async " ; any] else any
4593
4594
(* let f = a => () *)
4594
4595
| [
4595
4596
ParsetreeViewer. Parameter
@@ -4603,7 +4604,8 @@ and printExprFunParameters ~customLayout ~inCallback ~uncurried ~hasConstraint
4603
4604
when not uncurried ->
4604
4605
let txtDoc =
4605
4606
let var = printIdentLike stringLoc.txt in
4606
- if hasConstraint then addParens var else var
4607
+ let var = if hasConstraint then addParens var else var in
4608
+ if async then Doc. concat [Doc. text " async (" ; var; Doc. rparen] else var
4607
4609
in
4608
4610
printComments txtDoc cmtTbl stringLoc.loc
4609
4611
(* let f = () => () *)
@@ -4617,15 +4619,21 @@ and printExprFunParameters ~customLayout ~inCallback ~uncurried ~hasConstraint
4617
4619
};
4618
4620
]
4619
4621
when not uncurried ->
4620
- Doc. text " ()"
4622
+ if async then Doc. text " async () " else Doc. text " ()"
4621
4623
(* let f = (~greeting, ~from as hometown, ~x=?) => () *)
4622
4624
| parameters ->
4623
4625
let inCallback =
4624
4626
match inCallback with
4625
4627
| FitsOnOneLine -> true
4626
4628
| _ -> false
4627
4629
in
4628
- let lparen = if uncurried then Doc. text " (. " else Doc. lparen in
4630
+ let maybeAsyncLparen =
4631
+ match (async, uncurried) with
4632
+ | true , true -> Doc. text " async (. "
4633
+ | true , false -> Doc. text " async ("
4634
+ | false , true -> Doc. text " (. "
4635
+ | false , false -> Doc. lparen
4636
+ in
4629
4637
let shouldHug = ParsetreeViewer. parametersShouldHug parameters in
4630
4638
let printedParamaters =
4631
4639
Doc. concat
@@ -4641,7 +4649,7 @@ and printExprFunParameters ~customLayout ~inCallback ~uncurried ~hasConstraint
4641
4649
Doc. group
4642
4650
(Doc. concat
4643
4651
[
4644
- lparen ;
4652
+ maybeAsyncLparen ;
4645
4653
(if shouldHug || inCallback then printedParamaters
4646
4654
else
4647
4655
Doc. concat
0 commit comments