Skip to content

Commit 9eb1d3f

Browse files
fmt
1 parent ae3192b commit 9eb1d3f

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
@@ -2740,8 +2740,8 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens
27402740
( fmt_pattern c ~pro:(if_newline "| ")
27412741
(sub_pat ~ctx pc_lhs)
27422742
$ opt pc_guard (fun g ->
2743-
space_break $ str "when "
2744-
$ fmt_expression c (sub_exp ~ctx g) )
2743+
space_break $ str "when "
2744+
$ fmt_expression c (sub_exp ~ctx g) )
27452745
$ space_break $ str "->"
27462746
$ fmt_if parens_here (str " (") ) )
27472747
$ break 1 2
@@ -3447,8 +3447,8 @@ and fmt_case c ctx ~first ~last case =
34473447
( hvbox 0
34483448
( fmt_pattern c ~pro:p.bar ~parens:paren_lhs xlhs
34493449
$ opt pc_guard (fun g ->
3450-
break 1 2 $ str "when "
3451-
$ fmt_expression c (sub_exp ~ctx g) ) )
3450+
break 1 2 $ str "when " $ fmt_expression c (sub_exp ~ctx g) )
3451+
)
34523452
$ p.break_before_arrow $ str "->" $ p.break_after_arrow
34533453
$ p.open_paren_branch )
34543454
$ p.break_after_opening_paren
@@ -3784,9 +3784,9 @@ and fmt_type_extension c ctx
37843784
$ str " +="
37853785
$ fmt_private_flag c ptyext_private
37863786
$ list_fl ptyext_constructors (fun ~first ~last:_ x ->
3787-
let bar_fits = if first then "" else "| " in
3788-
cbreak ~fits:("", 1, bar_fits) ~breaks:("", 0, "| ")
3789-
$ fmt_ctor x ) )
3787+
let bar_fits = if first then "" else "| " in
3788+
cbreak ~fits:("", 1, bar_fits) ~breaks:("", 0, "| ")
3789+
$ fmt_ctor x ) )
37903790
$ fmt_item_attributes c ~pre:(Break (1, 0)) attrs_after )
37913791

37923792
and fmt_type_exception ~pre c ctx
@@ -4126,46 +4126,46 @@ and fmt_class_types c ~pre ~sep cls =
41264126
and fmt_class_exprs c cls =
41274127
hvbox 0
41284128
@@ list_fl cls (fun ~first ~last:_ cl ->
4129-
update_config_maybe_disabled_attrs c cl.pci_loc cl.pci_attributes
4130-
@@ fun c ->
4131-
let ctx = Cd cl in
4132-
let xargs = cl.pci_args in
4133-
let ext = cl.pci_attributes.attrs_extension in
4134-
let doc_before, doc_after, attrs_before, attrs_after =
4135-
let force_before = not (Cl.is_simple cl.pci_expr) in
4136-
fmt_docstring_around_item_attrs ~force_before c cl.pci_attributes
4137-
in
4138-
let class_expr =
4139-
let pro =
4140-
box_fun_decl_args c 2
4141-
( hovbox 2
4142-
( str (if first then "class" else "and")
4143-
$ fmt_if first (fmt_extension_suffix c ext)
4144-
$ fmt_attributes c ~pre:(Break (1, 0)) attrs_before
4145-
$ fmt_virtual_flag c cl.pci_virt
4146-
$ space_break
4147-
$ fmt_class_params c ctx cl.pci_params
4148-
$ fmt_str_loc c cl.pci_name )
4149-
$ fmt_if (not (List.is_empty xargs)) space_break
4150-
$ wrap_fun_decl_args c (fmt_class_fun_args c xargs) )
4151-
in
4152-
let intro =
4153-
match cl.pci_constraint with
4154-
| Some ty ->
4155-
fmt_class_type c
4156-
~pro:(pro $ str " :" $ space_break)
4157-
(sub_cty ~ctx ty)
4158-
| None -> pro
4159-
in
4160-
hovbox 2
4161-
( hovbox 2 (intro $ space_break $ str "=")
4162-
$ space_break
4163-
$ fmt_class_expr c (sub_cl ~ctx cl.pci_expr) )
4164-
$ fmt_item_attributes c ~pre:(Break (1, 0)) attrs_after
4165-
in
4166-
fmt_if (not first) (str "\n" $ force_break)
4167-
$ hovbox 0
4168-
@@ Cmts.fmt c cl.pci_loc (doc_before $ class_expr $ doc_after) )
4129+
update_config_maybe_disabled_attrs c cl.pci_loc cl.pci_attributes
4130+
@@ fun c ->
4131+
let ctx = Cd cl in
4132+
let xargs = cl.pci_args in
4133+
let ext = cl.pci_attributes.attrs_extension in
4134+
let doc_before, doc_after, attrs_before, attrs_after =
4135+
let force_before = not (Cl.is_simple cl.pci_expr) in
4136+
fmt_docstring_around_item_attrs ~force_before c cl.pci_attributes
4137+
in
4138+
let class_expr =
4139+
let pro =
4140+
box_fun_decl_args c 2
4141+
( hovbox 2
4142+
( str (if first then "class" else "and")
4143+
$ fmt_if first (fmt_extension_suffix c ext)
4144+
$ fmt_attributes c ~pre:(Break (1, 0)) attrs_before
4145+
$ fmt_virtual_flag c cl.pci_virt
4146+
$ space_break
4147+
$ fmt_class_params c ctx cl.pci_params
4148+
$ fmt_str_loc c cl.pci_name )
4149+
$ fmt_if (not (List.is_empty xargs)) space_break
4150+
$ wrap_fun_decl_args c (fmt_class_fun_args c xargs) )
4151+
in
4152+
let intro =
4153+
match cl.pci_constraint with
4154+
| Some ty ->
4155+
fmt_class_type c
4156+
~pro:(pro $ str " :" $ space_break)
4157+
(sub_cty ~ctx ty)
4158+
| None -> pro
4159+
in
4160+
hovbox 2
4161+
( hovbox 2 (intro $ space_break $ str "=")
4162+
$ space_break
4163+
$ fmt_class_expr c (sub_cl ~ctx cl.pci_expr) )
4164+
$ fmt_item_attributes c ~pre:(Break (1, 0)) attrs_after
4165+
in
4166+
fmt_if (not first) (str "\n" $ force_break)
4167+
$ hovbox 0
4168+
@@ Cmts.fmt c cl.pci_loc (doc_before $ class_expr $ doc_after) )
41694169

41704170
and fmt_module c ctx ?rec_ ?epi ?(can_sparse = false) keyword ?(eqty = "=")
41714171
name xargs xbody xmty ~attrs ~rec_flag =
@@ -4276,13 +4276,13 @@ and fmt_module c ctx ?rec_ ?epi ?(can_sparse = false) keyword ?(eqty = "=")
42764276
$ fmt_item_attributes c ~pre:(Break (1, 0)) attrs_after
42774277
$ doc_after
42784278
$ opt epi (fun epi ->
4279-
fmt_or compact
4280-
(fmt_or
4281-
( Option.is_some blk_b.epi
4282-
&& not c.conf.fmt_opts.ocp_indent_compat.v )
4283-
(str " ") space_break )
4284-
(break 1 (-2))
4285-
$ epi ) )
4279+
fmt_or compact
4280+
(fmt_or
4281+
( Option.is_some blk_b.epi
4282+
&& not c.conf.fmt_opts.ocp_indent_compat.v )
4283+
(str " ") space_break )
4284+
(break 1 (-2))
4285+
$ epi ) )
42864286

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

0 commit comments

Comments
 (0)