@@ -4584,6 +4584,18 @@ and get_line_sep_for_jsx_children (children : Parsetree.jsx_children) =
4584
4584
4585
4585
and print_jsx_children ~state (children : Parsetree.jsx_children ) cmt_tbl =
4586
4586
let open Parsetree in
4587
+ let get_loc (expr : Parsetree.expression ) =
4588
+ let braces =
4589
+ expr.pexp_attributes
4590
+ |> List. find_map (fun (attr , _ ) ->
4591
+ match attr with
4592
+ | {Location. txt = "res.braces" ; loc} -> Some loc
4593
+ | _ -> None )
4594
+ in
4595
+ match braces with
4596
+ | None -> expr.pexp_loc
4597
+ | Some loc -> loc
4598
+ in
4587
4599
let sep = get_line_sep_for_jsx_children children in
4588
4600
let print_expr (expr : Parsetree.expression ) =
4589
4601
let leading_line_comment_present =
@@ -4599,7 +4611,7 @@ and print_jsx_children ~state (children : Parsetree.jsx_children) cmt_tbl =
4599
4611
else Doc. concat [Doc. lbrace; inner_doc; Doc. rbrace]
4600
4612
in
4601
4613
match Parens. jsx_child_expr expr with
4602
- | Nothing -> expr_doc
4614
+ | Nothing -> print_comments expr_doc cmt_tbl (get_loc expr)
4603
4615
| Parenthesized -> add_parens_or_braces expr_doc
4604
4616
| Braced braces_loc ->
4605
4617
print_comments (add_parens_or_braces expr_doc) cmt_tbl braces_loc
@@ -4608,19 +4620,6 @@ and print_jsx_children ~state (children : Parsetree.jsx_children) cmt_tbl =
4608
4620
| JSXChildrenItems [] -> Doc. nil
4609
4621
| JSXChildrenSpreading child -> Doc. concat [Doc. dotdotdot; print_expr child]
4610
4622
| JSXChildrenItems children ->
4611
- let get_loc (expr : Parsetree.expression ) =
4612
- let braces =
4613
- expr.pexp_attributes
4614
- |> List. find_map (fun (attr , _ ) ->
4615
- match attr with
4616
- | {Location. txt = "res.braces" ; loc} -> Some loc
4617
- | _ -> None )
4618
- in
4619
- match braces with
4620
- | None -> expr.pexp_loc
4621
- | Some loc -> loc
4622
- in
4623
-
4624
4623
let rec visit acc children =
4625
4624
match children with
4626
4625
| [] -> acc
0 commit comments