Skip to content

Commit 35e1b76

Browse files
fmt
1 parent 5abe691 commit 35e1b76

File tree

1 file changed

+64
-64
lines changed

1 file changed

+64
-64
lines changed

lib/Fmt_ast.ml

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ let fmt_item_list c ctx0 update_config ast fmt_item items =
222222
let loc = Ast.location ctx in
223223
maybe_disabled c loc [] (fun c -> fmt_item c ctx ~prev ~next itm)
224224
$ opt next (fun (i_n, c_n) ->
225-
fmt_or
226-
(break_between c (ctx, c.conf) (ast i_n, c_n.conf))
227-
(str "\n" $ force_break)
228-
(fmt_or break_struct force_break space_break) )
225+
fmt_or
226+
(break_between c (ctx, c.conf) (ast i_n, c_n.conf))
227+
(str "\n" $ force_break)
228+
(fmt_or break_struct force_break space_break) )
229229

230230
let fmt_recmodule c ctx items fmt_item ast sub =
231231
let update_config c i = update_config c (Ast.attributes (ast i)) in
@@ -473,7 +473,7 @@ let fmt_docstring_around_item' ?(is_val = false) ?(force_before = false)
473473
let floating_doc, doc =
474474
doc
475475
|> List.map ~f:(fun (({txt; loc}, _) as doc) ->
476-
(Docstring.parse ~loc txt, doc) )
476+
(Docstring.parse ~loc txt, doc) )
477477
|> List.partition_tf ~f:(fun (_, (_, floating)) -> floating)
478478
in
479479
let placement =
@@ -860,8 +860,8 @@ and fmt_core_type c ?(box = true) ?pro ?(pro_space = true) ?constraint_ctx
860860
update_config_maybe_disabled c ptyp_loc ptyp_attributes
861861
@@ fun c ->
862862
( match pro with
863-
| Some pro -> fmt_constraint_sep ~pro_space c pro
864-
| None -> noop )
863+
| Some pro -> fmt_constraint_sep ~pro_space c pro
864+
| None -> noop )
865865
$
866866
let doc, atrs = doc_atrs ptyp_attributes in
867867
Cmts.fmt c ptyp_loc
@@ -1131,8 +1131,8 @@ and fmt_pattern ?ext c ?pro ?parens ?(box = false)
11311131
let parens = match parens with Some b -> b | None -> parenze_pat xpat in
11321132
(match ctx0 with Pat {ppat_desc= Ppat_tuple _; _} -> hvbox 0 | _ -> Fn.id)
11331133
@@ ( match ppat_desc with
1134-
| Ppat_or _ -> fun k -> Cmts.fmt c ppat_loc @@ k
1135-
| _ -> fun k -> Cmts.fmt c ppat_loc @@ (fmt_opt pro $ k) )
1134+
| Ppat_or _ -> fun k -> Cmts.fmt c ppat_loc @@ k
1135+
| _ -> fun k -> Cmts.fmt c ppat_loc @@ (fmt_opt pro $ k) )
11361136
@@ hovbox_if box 0
11371137
@@ fmt_pattern_attributes c xpat
11381138
@@
@@ -1533,7 +1533,7 @@ and fmt_indexop_access c ctx ~fmt_atrs ~has_attr ~parens x =
15331533
(str ";" $ space_break)
15341534
(sub_exp ~ctx >> fmt_expression c) ) )
15351535
$ opt pia_rhs (fun e ->
1536-
fmt_assign_arrow c $ fmt_expression c (sub_exp ~ctx e) ) )
1536+
fmt_assign_arrow c $ fmt_expression c (sub_exp ~ctx e) ) )
15371537
$ fmt_atrs ) )
15381538

15391539
(** Format a [Pexp_function]. [wrap_intro] wraps up to after the [->] and is
@@ -2738,8 +2738,8 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens
27382738
( fmt_pattern c ~pro:(if_newline "| ")
27392739
(sub_pat ~ctx pc_lhs)
27402740
$ opt pc_guard (fun g ->
2741-
space_break $ str "when "
2742-
$ fmt_expression c (sub_exp ~ctx g) )
2741+
space_break $ str "when "
2742+
$ fmt_expression c (sub_exp ~ctx g) )
27432743
$ space_break $ str "->"
27442744
$ fmt_if parens_here (str " (") ) )
27452745
$ break 1 2
@@ -3445,8 +3445,8 @@ and fmt_case c ctx ~first ~last case =
34453445
( hvbox 0
34463446
( fmt_pattern c ~pro:p.bar ~parens:paren_lhs xlhs
34473447
$ opt pc_guard (fun g ->
3448-
break 1 2 $ str "when "
3449-
$ fmt_expression c (sub_exp ~ctx g) ) )
3448+
break 1 2 $ str "when " $ fmt_expression c (sub_exp ~ctx g) )
3449+
)
34503450
$ p.break_before_arrow $ str "->" $ p.break_after_arrow
34513451
$ p.open_paren_branch )
34523452
$ p.break_after_opening_paren
@@ -3782,9 +3782,9 @@ and fmt_type_extension c ctx
37823782
$ str " +="
37833783
$ fmt_private_flag c ptyext_private
37843784
$ list_fl ptyext_constructors (fun ~first ~last:_ x ->
3785-
let bar_fits = if first then "" else "| " in
3786-
cbreak ~fits:("", 1, bar_fits) ~breaks:("", 0, "| ")
3787-
$ fmt_ctor x ) )
3785+
let bar_fits = if first then "" else "| " in
3786+
cbreak ~fits:("", 1, bar_fits) ~breaks:("", 0, "| ")
3787+
$ fmt_ctor x ) )
37883788
$ fmt_item_attributes c ~pre:(Break (1, 0)) attrs_after )
37893789

37903790
and fmt_type_exception ~pre c ctx
@@ -4105,46 +4105,46 @@ and fmt_class_types c ~pre ~sep cls =
41054105
and fmt_class_exprs c cls =
41064106
hvbox 0
41074107
@@ list_fl cls (fun ~first ~last:_ cl ->
4108-
update_config_maybe_disabled_attrs c cl.pci_loc cl.pci_attributes
4109-
@@ fun c ->
4110-
let ctx = Cd cl in
4111-
let xargs = cl.pci_args in
4112-
let ext = cl.pci_attributes.attrs_extension in
4113-
let doc_before, doc_after, attrs_before, attrs_after =
4114-
let force_before = not (Cl.is_simple cl.pci_expr) in
4115-
fmt_docstring_around_item_attrs ~force_before c cl.pci_attributes
4116-
in
4117-
let class_expr =
4118-
let pro =
4119-
box_fun_decl_args c 2
4120-
( hovbox 2
4121-
( str (if first then "class" else "and")
4122-
$ fmt_if first (fmt_extension_suffix c ext)
4123-
$ fmt_attributes c ~pre:(Break (1, 0)) attrs_before
4124-
$ fmt_virtual_flag c cl.pci_virt
4125-
$ space_break
4126-
$ fmt_class_params c ctx cl.pci_params
4127-
$ fmt_str_loc c cl.pci_name )
4128-
$ fmt_if (not (List.is_empty xargs)) space_break
4129-
$ wrap_fun_decl_args c (fmt_class_fun_args c xargs) )
4130-
in
4131-
let intro =
4132-
match cl.pci_constraint with
4133-
| Some ty ->
4134-
fmt_class_type c
4135-
~pro:(pro $ str " :" $ space_break)
4136-
(sub_cty ~ctx ty)
4137-
| None -> pro
4138-
in
4139-
hovbox 2
4140-
( hovbox 2 (intro $ space_break $ str "=")
4141-
$ space_break
4142-
$ fmt_class_expr c (sub_cl ~ctx cl.pci_expr) )
4143-
$ fmt_item_attributes c ~pre:(Break (1, 0)) attrs_after
4144-
in
4145-
fmt_if (not first) (str "\n" $ force_break)
4146-
$ hovbox 0
4147-
@@ Cmts.fmt c cl.pci_loc (doc_before $ class_expr $ doc_after) )
4108+
update_config_maybe_disabled_attrs c cl.pci_loc cl.pci_attributes
4109+
@@ fun c ->
4110+
let ctx = Cd cl in
4111+
let xargs = cl.pci_args in
4112+
let ext = cl.pci_attributes.attrs_extension in
4113+
let doc_before, doc_after, attrs_before, attrs_after =
4114+
let force_before = not (Cl.is_simple cl.pci_expr) in
4115+
fmt_docstring_around_item_attrs ~force_before c cl.pci_attributes
4116+
in
4117+
let class_expr =
4118+
let pro =
4119+
box_fun_decl_args c 2
4120+
( hovbox 2
4121+
( str (if first then "class" else "and")
4122+
$ fmt_if first (fmt_extension_suffix c ext)
4123+
$ fmt_attributes c ~pre:(Break (1, 0)) attrs_before
4124+
$ fmt_virtual_flag c cl.pci_virt
4125+
$ space_break
4126+
$ fmt_class_params c ctx cl.pci_params
4127+
$ fmt_str_loc c cl.pci_name )
4128+
$ fmt_if (not (List.is_empty xargs)) space_break
4129+
$ wrap_fun_decl_args c (fmt_class_fun_args c xargs) )
4130+
in
4131+
let intro =
4132+
match cl.pci_constraint with
4133+
| Some ty ->
4134+
fmt_class_type c
4135+
~pro:(pro $ str " :" $ space_break)
4136+
(sub_cty ~ctx ty)
4137+
| None -> pro
4138+
in
4139+
hovbox 2
4140+
( hovbox 2 (intro $ space_break $ str "=")
4141+
$ space_break
4142+
$ fmt_class_expr c (sub_cl ~ctx cl.pci_expr) )
4143+
$ fmt_item_attributes c ~pre:(Break (1, 0)) attrs_after
4144+
in
4145+
fmt_if (not first) (str "\n" $ force_break)
4146+
$ hovbox 0
4147+
@@ Cmts.fmt c cl.pci_loc (doc_before $ class_expr $ doc_after) )
41484148

41494149
and fmt_module c ctx ?rec_ ?epi ?(can_sparse = false) keyword ?(eqty = "=")
41504150
name xargs xbody xmty ~attrs ~rec_flag =
@@ -4242,13 +4242,13 @@ and fmt_module c ctx ?rec_ ?epi ?(can_sparse = false) keyword ?(eqty = "=")
42424242
$ fmt_item_attributes c ~pre:(Break (1, 0)) attrs_after
42434243
$ doc_after
42444244
$ opt epi (fun epi ->
4245-
fmt_or compact
4246-
(fmt_or
4247-
( Option.is_some blk_b.epi
4248-
&& not c.conf.fmt_opts.ocp_indent_compat.v )
4249-
(str " ") space_break )
4250-
(break 1 (-2))
4251-
$ epi ) )
4245+
fmt_or compact
4246+
(fmt_or
4247+
( Option.is_some blk_b.epi
4248+
&& not c.conf.fmt_opts.ocp_indent_compat.v )
4249+
(str " ") space_break )
4250+
(break 1 (-2))
4251+
$ epi ) )
42524252

42534253
and fmt_module_declaration c ~rec_flag ~first {ast= pmd; _} =
42544254
protect c (Md pmd)

0 commit comments

Comments
 (0)