@@ -2629,6 +2629,41 @@ and printIfChain ~customLayout pexp_attributes ifs elseExpr cmtTbl =
2629
2629
Doc. concat [printAttributes ~custom Layout attrs cmtTbl; ifDocs; elseDoc]
2630
2630
2631
2631
and printExpression ~customLayout (e : Parsetree.expression ) cmtTbl =
2632
+ let makeSpreadDoc = function
2633
+ | Some expr ->
2634
+ Doc. concat
2635
+ [
2636
+ Doc. text " ," ;
2637
+ Doc. line;
2638
+ Doc. dotdotdot;
2639
+ (let doc = printExpressionWithComments ~custom Layout expr cmtTbl in
2640
+ match Parens. expr expr with
2641
+ | Parens. Parenthesized -> addParens doc
2642
+ | Braced braces -> printBraces doc expr braces
2643
+ | Nothing -> doc);
2644
+ ]
2645
+ | None -> Doc. nil
2646
+ in
2647
+ let makeSubListDoc (expressions , spread ) =
2648
+ let spreadDoc = makeSpreadDoc spread in
2649
+ Doc. concat
2650
+ [
2651
+ Doc. softLine;
2652
+ Doc. join
2653
+ ~sep: (Doc. concat [Doc. text " ," ; Doc. line])
2654
+ (List. map
2655
+ (fun expr ->
2656
+ let doc =
2657
+ printExpressionWithComments ~custom Layout expr cmtTbl
2658
+ in
2659
+ match Parens. expr expr with
2660
+ | Parens. Parenthesized -> addParens doc
2661
+ | Braced braces -> printBraces doc expr braces
2662
+ | Nothing -> doc)
2663
+ expressions);
2664
+ spreadDoc;
2665
+ ]
2666
+ in
2632
2667
let printedExpression =
2633
2668
match e.pexp_desc with
2634
2669
| Parsetree. Pexp_constant c ->
@@ -2641,47 +2676,11 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
2641
2676
[Doc. text " list{" ; printCommentsInside cmtTbl e.pexp_loc; Doc. rbrace]
2642
2677
| Pexp_construct ({txt = Longident. Lident "::" } , _ ) ->
2643
2678
let expressions, spread = ParsetreeViewer. collectListExpressions e in
2644
- let spreadDoc =
2645
- match spread with
2646
- | Some expr ->
2647
- Doc. concat
2648
- [
2649
- Doc. text " ," ;
2650
- Doc. line;
2651
- Doc. dotdotdot;
2652
- (let doc =
2653
- printExpressionWithComments ~custom Layout expr cmtTbl
2654
- in
2655
- match Parens. expr expr with
2656
- | Parens. Parenthesized -> addParens doc
2657
- | Braced braces -> printBraces doc expr braces
2658
- | Nothing -> doc);
2659
- ]
2660
- | None -> Doc. nil
2661
- in
2662
2679
Doc. group
2663
2680
(Doc. concat
2664
2681
[
2665
2682
Doc. text " list{" ;
2666
- Doc. indent
2667
- (Doc. concat
2668
- [
2669
- Doc. softLine;
2670
- Doc. join
2671
- ~sep: (Doc. concat [Doc. text " ," ; Doc. line])
2672
- (List. map
2673
- (fun expr ->
2674
- let doc =
2675
- printExpressionWithComments ~custom Layout expr
2676
- cmtTbl
2677
- in
2678
- match Parens. expr expr with
2679
- | Parens. Parenthesized -> addParens doc
2680
- | Braced braces -> printBraces doc expr braces
2681
- | Nothing -> doc)
2682
- expressions);
2683
- spreadDoc;
2684
- ]);
2683
+ Doc. indent (makeSubListDoc (expressions, spread));
2685
2684
Doc. trailingComma;
2686
2685
Doc. softLine;
2687
2686
Doc. rbrace;
@@ -2980,6 +2979,19 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
2980
2979
])
2981
2980
| extension ->
2982
2981
printExtension ~custom Layout ~at ModuleLvl:false extension cmtTbl)
2982
+ | Pexp_apply
2983
+ ( {pexp_desc = Pexp_ident {txt = Longident. Lident " @" }},
2984
+ [(Nolabel , _); (Nolabel , _)] ) ->
2985
+ let subLists = ParsetreeViewer. collectConcatListExpressions e in
2986
+ Doc. group
2987
+ (Doc. concat
2988
+ [
2989
+ Doc. text " list{" ;
2990
+ Doc. indent (Doc. concat (List. map makeSubListDoc subLists));
2991
+ Doc. trailingComma;
2992
+ Doc. softLine;
2993
+ Doc. rbrace;
2994
+ ])
2983
2995
| Pexp_apply _ ->
2984
2996
if ParsetreeViewer. isUnaryExpression e then
2985
2997
printUnaryExpression ~custom Layout e cmtTbl
0 commit comments