Skip to content

Commit 0133f91

Browse files
committed
Formats
1 parent 2b9b5ce commit 0133f91

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

compiler/syntax/src/res_comments_table.ml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,16 +1473,24 @@ and walk_expression expr t comments =
14731473
let xs = exprs |> List.map (fun e -> Expression e) in
14741474
walk_list xs t rest
14751475
| Pexp_jsx_unary_element {jsx_unary_element_props = props} ->
1476-
let _ = List.map (fun prop ->
1477-
match prop with
1478-
| Parsetree.JSXPropPunning (_, _) -> ()
1479-
| Parsetree.JSXPropValue (_, _, expr) ->
1480-
let (_leading, inside, trailing) = partition_by_loc comments expr.pexp_loc in
1481-
let after_expr, _ = partition_adjacent_trailing expr.pexp_loc trailing in
1482-
attach t.trailing expr.pexp_loc after_expr;
1483-
walk_expression expr t inside;
1484-
| Parsetree.JSXPropSpreading (_loc, _expr) -> ()
1485-
) props in ()
1476+
let _ =
1477+
List.map
1478+
(fun prop ->
1479+
match prop with
1480+
| Parsetree.JSXPropPunning (_, _) -> ()
1481+
| Parsetree.JSXPropValue (_, _, expr) ->
1482+
let _leading, inside, trailing =
1483+
partition_by_loc comments expr.pexp_loc
1484+
in
1485+
let after_expr, _ =
1486+
partition_adjacent_trailing expr.pexp_loc trailing
1487+
in
1488+
attach t.trailing expr.pexp_loc after_expr;
1489+
walk_expression expr t inside
1490+
| Parsetree.JSXPropSpreading (_loc, _expr) -> ())
1491+
props
1492+
in
1493+
()
14861494
| Pexp_jsx_container_element
14871495
{
14881496
jsx_container_element_opening_tag_end = opening_greater_than;

compiler/syntax/src/res_printer.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,14 +4314,15 @@ and print_jsx_unary_tag ~state tag_name props cmt_tbl =
43144314
let formatted_props = print_jsx_props ~state props cmt_tbl in
43154315
let formatted_props = formatted_props @ [Doc.text "/>"] in
43164316
Doc.group
4317-
(Doc.concat
4318-
[
4319-
print_comments
4320-
(Doc.concat [Doc.less_than; name])
4321-
cmt_tbl tag_name.Asttypes.loc;
4322-
Doc.space;
4323-
Doc.indent (Doc.group (Doc.join formatted_props ~sep:Doc.line));
4324-
]);
4317+
(Doc.concat
4318+
[
4319+
print_comments
4320+
(Doc.concat [Doc.less_than; name])
4321+
cmt_tbl tag_name.Asttypes.loc;
4322+
Doc.indent
4323+
(Doc.concat
4324+
[Doc.line; Doc.group (Doc.join formatted_props ~sep:Doc.line)]);
4325+
])
43254326

43264327
and print_jsx_container_tag ~state tag_name props
43274328
(children : Parsetree.jsx_children) cmt_tbl =
@@ -4513,7 +4514,6 @@ and print_jsx_prop ~state prop cmt_tbl =
45134514
and print_jsx_props ~state props cmt_tbl : Doc.t list =
45144515
props |> List.map (fun prop -> print_jsx_prop ~state prop cmt_tbl)
45154516

4516-
45174517
(* div -> div.
45184518
* Navabar.createElement -> Navbar
45194519
* Staff.Users.createElement -> Staff.Users *)

0 commit comments

Comments
 (0)