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