Skip to content

Commit

Permalink
[ocaml] fix and simplify sequence softline/spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
nbacquey committed Oct 23, 2023
1 parent 1d5c062 commit e7aa6b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
26 changes: 2 additions & 24 deletions topiary-queries/queries/ocaml.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1506,46 +1506,24 @@
; top-level one: it is the one that is not preceded by a ";" (or ";%foo" for ppx sequences).
(
";"? @do_nothing
.
(sequence_expression
.
_
.
";"
.
"%"? @do_nothing
) @prepend_begin_scope @append_end_scope
(#scope_id! "sequence_expression")
)
(sequence_expression
";" @append_spaced_scoped_softline
(#scope_id! "sequence_expression")
)

(
";"?
.
"%"? @do_nothing
.
(attribute_id)?
.
(sequence_expression
.
_
.
";"
.
"%"
) @prepend_begin_scope @append_end_scope
(#scope_id! "ppx_sequence_expression")
(#scope_id! "sequence_expression")
)
(sequence_expression
";"
.
"%"
.
(attribute_id) @append_spaced_scoped_softline
(#scope_id! "ppx_sequence_expression")
(#scope_id! "sequence_expression")
)

; Allow softlines in or patterns in matches, such as
Expand Down
8 changes: 8 additions & 0 deletions topiary/tests/samples/expected/ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,14 @@ let _ =
| F ->
bar

(* #642: interleaving regular sequence with PPX sequence *)
let () =
foo;
bar;%lwt
baz

let () = foo; bar;%lwt baz

(* #644: softlines before module definition in a module type *)
module type F = sig
module G: sig val h : string end
Expand Down
8 changes: 8 additions & 0 deletions topiary/tests/samples/input/ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,14 @@ let _ =
| A | B | C
| D | E | F -> bar

(* #642: interleaving regular sequence with PPX sequence *)
let () =
foo;
bar;%lwt
baz

let () = foo; bar;%lwt baz

(* #644: softlines before module definition in a module type *)
module type F = sig
module G : sig val h : string end
Expand Down

0 comments on commit e7aa6b7

Please sign in to comment.