diff --git a/src/MarkedSource.ml b/src/MarkedSource.ml
index 044e5f4..962513d 100644
--- a/src/MarkedSource.ml
+++ b/src/MarkedSource.ml
@@ -1,6 +1,6 @@
include MarkedSourceData
-let dump_marker dump_tag fmt =
+let dump_mark dump_tag fmt =
function
| RangeBegin tag -> Format.fprintf fmt {|@[<2>RangeBegin@ @[%a@]@]|} dump_tag tag
| RangeEnd tag -> Format.fprintf fmt {|@[<2>RangeEnd@ @[%a@]@]|} dump_tag tag
@@ -8,19 +8,19 @@ let dump_marker dump_tag fmt =
let dump_special_position fmt =
function
- | End_of_line -> Format.fprintf fmt {|End_of_line|}
- | End_of_file -> Format.fprintf fmt {|End_of_file|}
+ | `End_of_line -> Format.fprintf fmt {|`End_of_line|}
+ | `End_of_file -> Format.fprintf fmt {|`End_of_file|}
let dump_token dump_tag fmt =
function
| String str -> Format.fprintf fmt {|@[<2>String@ "%s"@]|} (String.escaped str)
- | Marker (p, m) ->
+ | Mark (p, m) ->
Format.fprintf fmt {|@[<2>Marker@ @[<1>(@[%a@],@ @[%a@])@]@]|}
- (Utils.dump_option dump_special_position) p (dump_marker dump_tag) m
+ (Utils.dump_option dump_special_position) p (dump_mark dump_tag) m
-let dump_line dump_tag fmt {markers; tokens} =
- Format.fprintf fmt {|@[<1>{@[<2>markers=@,@[%a@]@];@ @[<2>tokens=@ @[%a@]@]}@]|}
- (Utils.dump_list dump_tag) markers
+let dump_line dump_tag fmt {marks; tokens} =
+ Format.fprintf fmt {|@[<1>{@[<2>marks=@,@[%a@]@];@ @[<2>tokens=@ @[%a@]@]}@]|}
+ (Utils.dump_list dump_tag) marks
(Utils.dump_list (dump_token dump_tag)) tokens
let dump_block dump_tag fmt {begin_line_num; end_line_num; lines} =
diff --git a/src/MarkedSource.mli b/src/MarkedSource.mli
index 9ed63a6..c5b8285 100644
--- a/src/MarkedSource.mli
+++ b/src/MarkedSource.mli
@@ -5,8 +5,8 @@ include module type of MarkedSourceData
(** {1 Debugging} *)
-(** Ugly printer for {!type:marker} *)
-val dump_marker : (Format.formatter -> 'tag -> unit) -> Format.formatter -> 'tag marker -> unit
+(** Ugly printer for {!type:mark} *)
+val dump_mark : (Format.formatter -> 'tag -> unit) -> Format.formatter -> 'tag mark -> unit
(** Ugly printer for {!type:t} *)
val dump : (Format.formatter -> 'tag -> unit) -> Format.formatter -> 'tag t -> unit
diff --git a/src/MarkedSourceData.ml b/src/MarkedSourceData.ml
index a807f66..d36d815 100644
--- a/src/MarkedSourceData.ml
+++ b/src/MarkedSourceData.ml
@@ -1,22 +1,17 @@
-(** Special positions. *)
-type special_position =
- | End_of_line
- | End_of_file
-
-(** A marker is a delimiter of a range or a specific point. *)
-type 'tag marker =
+(** A mark is a delimiter of a range or a specific point. *)
+type 'tag mark =
| RangeBegin of 'tag
| RangeEnd of 'tag
| Point of 'tag
-(** A token is either a string or a marker. *)
+(** A token is either a string or a mark. *)
type 'tag token =
| String of string
- | Marker of special_position option * 'tag marker
+ | Mark of [`End_of_line | `End_of_file] option * 'tag mark
(** A line is a list of {!type:segment}s along with tags. *)
type 'tag line =
- { markers : 'tag list (** All tags in this line *)
+ { marks : 'tag list (** All tags in this line *)
; tokens : 'tag token list
}
diff --git a/src/RangeFlattener.ml b/src/RangeFlattener.ml
index e58933f..570a723 100644
--- a/src/RangeFlattener.ml
+++ b/src/RangeFlattener.ml
@@ -7,24 +7,24 @@ open SourceMarkerSigs
type 'tag block =
{ begin_line_num : int
; end_line_num : int
- ; markers : (Range.position * 'tag marker) list
- ; line_markers : (int * 'tag) list}
+ ; marks : (Range.position * 'tag mark) list
+ ; line_marks : (int * 'tag) list}
type 'tag t = (Range.source * 'tag block list) list
-let dump_block dump_tag fmt {begin_line_num; end_line_num; markers; line_markers} : unit =
+let dump_block dump_tag fmt {begin_line_num; end_line_num; marks; line_marks} : unit =
Format.fprintf fmt
begin
"@[<1>{" ^^
"begin_line_num=%d;@ " ^^
"end_line_num=%d;@ " ^^
- "@[<2>markers=@ @[%a@]@];@ " ^^
+ "@[<2>marks=@ @[%a@]@];@ " ^^
"@[<2>marked_lines=@,@[%a@]@]" ^^
"}@]"
end
begin_line_num end_line_num
- (Utils.dump_list (Utils.dump_pair Range.dump_position (dump_marker dump_tag))) markers
- (Utils.dump_list (Utils.dump_pair Format.pp_print_int dump_tag)) line_markers
+ (Utils.dump_list (Utils.dump_pair Range.dump_position (dump_mark dump_tag))) marks
+ (Utils.dump_list (Utils.dump_pair Format.pp_print_int dump_tag)) line_marks
let dump dump_tag =
Utils.dump_list @@ Utils.dump_pair Range.dump_source (Utils.dump_list (dump_block dump_tag))
@@ -90,17 +90,17 @@ struct
partition_sorted ~block_splitting_threshold @@ Bwd.of_list @@ sort_tagged l
end
- (* Stage 2: for each block, flatten out ranges into markers *)
+ (* Stage 2: for each block, flatten out ranges into marks *)
module BlockFlattener :
sig
- val flatten : (Range.t * Tag.t) list -> (Range.position * Tag.t marker) list
+ val flatten : (Range.t * Tag.t) list -> (Range.position * Tag.t mark) list
end
=
struct
type t =
- { begins : (Range.position * Tag.t marker) bwd
- ; points : (Range.position * Tag.t marker) bwd
- ; ends : (Range.position * Tag.t marker) list
+ { begins : (Range.position * Tag.t mark) bwd
+ ; points : (Range.position * Tag.t mark) bwd
+ ; ends : (Range.position * Tag.t mark) list
}
let add (range, tag) {begins; points; ends} =
@@ -110,21 +110,21 @@ struct
else
{begins = begins <: (b, RangeBegin tag); points; ends = (e, RangeEnd tag) :: ends}
- let sort_marker =
- let marker_order =
+ let sort_marks =
+ let mark_order =
function
| RangeEnd _ -> -1
| Point _ -> 0
| RangeBegin _ -> 1
in
- let compare_marker m1 m2 = Int.compare (marker_order m1) (marker_order m2) in
- List.stable_sort (Utils.compare_pair compare_position compare_marker)
+ let compare_mark m1 m2 = Int.compare (mark_order m1) (mark_order m2) in
+ List.stable_sort (Utils.compare_pair compare_position compare_mark)
- let merge_marker {begins; points; ends} =
+ let merge_marks {begins; points; ends} =
begins @> points @> ends
let flatten l =
- sort_marker @@ merge_marker @@
+ sort_marks @@ merge_marks @@
Bwd.fold_right add (Bwd.of_list l) {begins = Emp; points = Emp; ends = []}
end
@@ -135,15 +135,15 @@ struct
=
struct
let flatten_block ({begin_line_num; end_line_num; ranges} : unflattened_block) =
- let markers = BlockFlattener.flatten ranges in
- let line_markers =
+ let marks = BlockFlattener.flatten ranges in
+ let line_marks =
List.filter_map
(function
| (_, RangeBegin _) -> None
| (p, RangeEnd tag) | (p, Point tag) -> Some (p.Range.line_num, tag))
- markers
+ marks
in
- { begin_line_num; end_line_num; markers; line_markers }
+ { begin_line_num; end_line_num; marks; line_marks }
let flatten ~block_splitting_threshold rs =
List.map flatten_block @@ RangePartitioner.partition ~block_splitting_threshold rs
diff --git a/src/RangeFlattener.mli b/src/RangeFlattener.mli
index 3502f7d..b2676e4 100644
--- a/src/RangeFlattener.mli
+++ b/src/RangeFlattener.mli
@@ -3,8 +3,8 @@ open MarkedSource
type 'tag block =
{ begin_line_num : int
; end_line_num : int
- ; markers : (Range.position * 'tag marker) list
- ; line_markers : (int * 'tag) list (* should be sorted by line numbers *)
+ ; marks : (Range.position * 'tag mark) list
+ ; line_marks : (int * 'tag) list (* should be sorted by line numbers *)
}
type 'tag t = (Range.source * 'tag block list) list
@@ -16,17 +16,17 @@ module Make (Tag : SourceMarkerSigs.Tag) : sig
val flatten : block_splitting_threshold:int -> (Range.t * Tag.t) list -> Tag.t t
(**
The code needs to handle several subtle cases, expressing in an XML-like notation:
- - The ordering of range markers and point markers at the same location should be ordered like this:
+ - The ordering of range marks and point marks at the same location should be ordered like this:
[......]
[RangeEnd] goes first, and then [Point], and then [RangeBegin].
- If the set of ranges is "well-scoped" (that is, a range is always completely included in,
completely including, or being disjoint from another range), then matching beginning and
- ending markers will have the expected nested structures, like this:
+ ending marks will have the expected nested structures, like this:
[......]
- For two ranges marking the same text with different priorities, the prioritized one goes inside.
This is to reduce interruption of the prioritized highlighting.
[...]
- - For two ranges with the same text and priority, the order of ending markers will follow
+ - For two ranges with the same text and priority, the order of ending marks will follow
the order of the original input list. This will help the TTY backend display the messages in order.
[...]
*)
diff --git a/src/SourceMarker.ml b/src/SourceMarker.ml
index beaf4a5..4aca269 100644
--- a/src/SourceMarker.ml
+++ b/src/SourceMarker.ml
@@ -62,7 +62,7 @@ module Make (Tag : Tag) = struct
type marker_state =
{ lines : Tag.t line bwd
; tokens : Tag.t token bwd
- ; remaining_line_markers : (int * Tag.t) list
+ ; remaining_line_marks : (int * Tag.t) list
; cursor : Range.position
; eol : int
; eol_shift : int option
@@ -72,53 +72,53 @@ module Make (Tag : Tag) = struct
module F = RangeFlattener.Make(Tag)
let mark_block ~line_breaks source (b : Tag.t RangeFlattener.block) : Tag.t block =
- match b.markers with
+ match b.marks with
| [] -> invalid_arg "mark_block: empty block; should be impossible"
- | ((first_loc, _) :: _) as markers ->
+ | ((first_loc, _) :: _) as marks ->
let source = SourceReader.load source in
let eof = SourceReader.length source in
let find_eol i = StringUtils.find_eol ~line_breaks (SourceReader.unsafe_get source) (i, eof) in
- let rec go state : (Range.position * Tag.t marker) list -> _ =
+ let rec go state : (Range.position * Tag.t mark) list -> _ =
function
- | (loc, marker) :: markers when state.cursor.line_num = loc.line_num (* on the same line *) ->
+ | (loc, mark) :: marks when state.cursor.line_num = loc.line_num (* on the same line *) ->
if loc.offset > eof then invalid_arg "Asai.SourceMarker.mark: position beyond EOF; use the debug mode";
if loc.offset > state.eol then invalid_arg "Asai.SourceMarker.mark: unexpected newline; use the debug mode";
let special_position =
if loc.offset = state.eol then
if loc.offset = eof then
- Some End_of_file
+ Some `End_of_file
else
- Some End_of_line
+ Some `End_of_line
else
None
in
let tokens =
if loc.offset = state.cursor.offset then
- state.tokens <: Marker (special_position, marker)
+ state.tokens <: Mark (special_position, mark)
else
- state.tokens <: String (read_between ~source state.cursor.offset loc.offset) <: Marker (special_position, marker)
+ state.tokens <: String (read_between ~source state.cursor.offset loc.offset) <: Mark (special_position, mark)
in
- go { state with tokens; cursor = loc } markers
- | markers ->
+ go { state with tokens; cursor = loc } marks
+ | marks ->
(* Shifting to the next line *)
- let lines, remaining_line_markers =
+ let lines, remaining_line_marks =
let tokens =
if state.cursor.offset < state.eol then
state.tokens <: String (read_between ~source state.cursor.offset state.eol)
else
state.tokens
in
- let line_markers, remaining_line_markers =
- Utils.span (fun (line_num, _) -> line_num = state.line_num) state.remaining_line_markers
+ let line_marks, remaining_line_marks =
+ Utils.span (fun (line_num, _) -> line_num = state.line_num) state.remaining_line_marks
in
(state.lines <:
{ tokens = Bwd.to_list tokens
- ; markers = List.map snd line_markers
+ ; marks = List.map snd line_marks
}),
- remaining_line_markers
+ remaining_line_marks
in
- (* Continue the process if [markers] is not empty. *)
- match markers, state.eol_shift with
+ (* Continue the process if [marks] is not empty. *)
+ match marks, state.eol_shift with
| [], _ ->
assert (state.line_num = b.end_line_num);
lines
@@ -133,13 +133,13 @@ module Make (Tag : Tag) = struct
go
{ lines
; tokens = Emp
- ; remaining_line_markers
+ ; remaining_line_marks
; cursor
; eol
; eol_shift
; line_num = state.line_num + 1
}
- markers
+ marks
in
let lines =
let begin_pos = to_start_of_line first_loc in
@@ -147,13 +147,13 @@ module Make (Tag : Tag) = struct
go
{ lines = Emp
; tokens = Emp
- ; remaining_line_markers = b.line_markers
+ ; remaining_line_marks = b.line_marks
; cursor = begin_pos
; eol
; eol_shift
; line_num = b.begin_line_num
}
- markers
+ marks
in
{ begin_line_num = b.begin_line_num
; end_line_num = b.end_line_num
diff --git a/src/tty/Tty.ml b/src/tty/Tty.ml
index a388020..b38c6ba 100644
--- a/src/tty/Tty.ml
+++ b/src/tty/Tty.ml
@@ -8,6 +8,17 @@ let string_of_severity : Diagnostic.severity -> string =
| Error -> "error"
| Bug -> "bug"
+type tag = TtyTag.t
+
+type marker = use_ansi:bool -> use_color:bool -> [`End_of_line | `End_of_file] option -> tag MarkedSource.mark -> string
+
+let default_marker ~use_ansi:_ ~use_color:_ s m =
+ match s, m with
+ | _, (MarkedSource.RangeBegin _ | RangeEnd _) -> ""
+ | Some `End_of_line, Point _ -> "‹EOL›"
+ | Some `End_of_file, Point _ -> "‹EOF›"
+ | None, Point _ -> "‹POS›"
+
module SM = SourceMarker.Make(TtyTag)
(* calculating the width of line numbers *)
@@ -61,6 +72,7 @@ sig
severity : Diagnostic.severity;
line_number_width : int;
ansi : Ansi.param;
+ marker : marker;
}
val render : param:param -> Format.formatter -> TtyTag.t MarkedSource.t -> unit
@@ -75,6 +87,7 @@ struct
severity : Diagnostic.severity;
line_number_width : int;
ansi : Ansi.param;
+ marker : marker;
}
(* [ ■ examples/stlc/source.lambda] *)
@@ -83,7 +96,7 @@ struct
| None -> ()
| Some title -> Format.fprintf fmt " @<1>%s %s@." "■" title
- let render_line_marker ~param fmt ((_, text) as tag) =
+ let render_line_mark ~param fmt ((_, text) as tag) =
let style = TtyStyle.message ~param:param.ansi param.severity tag in
Format.fprintf fmt (" %*s " ^^ highlight "^" ^^ " " ^^ highlight "@[%t@]" ^^ "@.")
param.line_number_width ""
@@ -94,33 +107,28 @@ struct
(Ansi.reset_string ~param:param.ansi style)
let render_styled_segment ~param fmt tag segment =
- let style = TtyStyle.highlight ~param:param.ansi param.severity tag in
- Format.fprintf fmt (highlight "%s")
- (Ansi.style_string ~param:param.ansi style)
- (StringUtils.replace_control ~tab_size:param.tab_size segment)
- (Ansi.reset_string ~param:param.ansi style)
-
- (* Current design:
-
- ‹let x◂POS₀▸ = 1› in let ‹x› = «1 + ‹x›»◂POS₁▸
- ‹let x◂POS₀▸ = 1›₀ in let ‹x›₁ = «1 + ‹x›₂»◂POS₁▸
- *)
-
- let render_line ~line_num ~param fmt init_tag_set MarkedSource.{tokens; markers} =
+ if segment <> "" then
+ let style = TtyStyle.highlight ~param:param.ansi param.severity tag in
+ Format.fprintf fmt (highlight "%s")
+ (Ansi.style_string ~param:param.ansi style)
+ (StringUtils.replace_control ~tab_size:param.tab_size segment)
+ (Ansi.reset_string ~param:param.ansi style)
+
+ let render_line ~line_num ~param fmt init_tag_set MarkedSource.{tokens; marks} =
let go set =
function
| MarkedSource.String s ->
render_styled_segment ~param fmt (TtyTagSet.prioritized set) s; set
- | MarkedSource.Marker (_, RangeEnd t) ->
- TtyTagSet.remove t set
- | MarkedSource.Marker (Some End_of_file, Point t) ->
- render_styled_segment ~param fmt (Some t) "‹EOF›"; set
- | MarkedSource.Marker (Some End_of_line, Point t) ->
- render_styled_segment ~param fmt (Some t) "‹EOL›"; set
- | MarkedSource.Marker (None, Point t) ->
- render_styled_segment ~param fmt (Some t) "‹POS›"; set
- | MarkedSource.Marker (_, RangeBegin t) ->
- TtyTagSet.add t set
+ | MarkedSource.Mark (sp, m) ->
+ let t, next =
+ match m with
+ | RangeEnd t -> t, TtyTagSet.remove t set
+ | RangeBegin t -> t, TtyTagSet.add t set
+ | Point t -> t, set
+ and mark =
+ param.marker ~use_ansi:param.ansi.enabled ~use_color:param.ansi.color sp m
+ in
+ render_styled_segment ~param fmt (Some t) mark; next
in
Format.fprintf fmt (" " ^^ highlight "%*d |" ^^ " ")
(Ansi.style_string ~param:param.ansi TtyStyle.fringe)
@@ -128,7 +136,7 @@ struct
(Ansi.reset_string ~param:param.ansi TtyStyle.fringe);
let end_tag_set = List.fold_left go init_tag_set tokens in
Format.fprintf fmt "@.";
- List.iter (render_line_marker ~param fmt) markers;
+ List.iter (render_line_mark ~param fmt) marks;
end_tag_set
let render_lines ~param ~begin_line_num fmt lines =
@@ -167,6 +175,7 @@ sig
block_splitting_threshold : int;
tab_size : int;
ansi : Ansi.param;
+ marker : marker;
}
val render_diagnostic : param:param -> Format.formatter -> string Diagnostic.t -> unit
@@ -180,6 +189,7 @@ struct
block_splitting_threshold : int;
tab_size : int;
ansi : Ansi.param;
+ marker : marker;
}
let line_number_width marked_source : int =
@@ -206,7 +216,13 @@ struct
SM.mark ~block_splitting_threshold:param.block_splitting_threshold ~debug:param.debug located_tags
in
let line_number_width = line_number_width marked_source in
- let param = {MarkedSourceRenderer.severity = severity; tab_size = param.tab_size; line_number_width; ansi = param.ansi} in
+ let param = {
+ MarkedSourceRenderer.severity = severity;
+ tab_size = param.tab_size;
+ line_number_width;
+ ansi = param.ansi;
+ marker = param.marker
+ } in
MarkedSourceRenderer.render ~param fmt marked_source;
List.iter (render_unlocated_tag ~severity:param.severity ~ansi:param.ansi fmt) unlocated_tags
@@ -222,12 +238,12 @@ end
module Make (Message : MinimumSigs.Message) =
struct
- let display ?(output=Stdlib.stdout) ?use_ansi ?use_color ?(show_backtrace=true)
+ let display ?(output=Stdlib.stdout) ?use_ansi ?use_color ?(show_backtrace=true) ?(marker=default_marker)
?(line_breaks=`Traditional) ?(block_splitting_threshold=5) ?(tab_size=8) ?(debug=false) d =
let d = if show_backtrace then d else {d with Diagnostic.backtrace = Emp} in
let d = Diagnostic.map Message.short_code d in
let ansi = Ansi.Test.guess ?use_ansi ?use_color output in
- let param = {DiagnosticRenderer.debug; line_breaks; block_splitting_threshold; tab_size; ansi} in
+ let param = {DiagnosticRenderer.debug; line_breaks; block_splitting_threshold; tab_size; ansi; marker} in
let fmt = Format.formatter_of_out_channel output in
SourceReader.run @@ fun () ->
DiagnosticRenderer.render_diagnostic ~param fmt d;
diff --git a/src/tty/Tty.mli b/src/tty/Tty.mli
index 171be2d..846f216 100644
--- a/src/tty/Tty.mli
+++ b/src/tty/Tty.mli
@@ -4,6 +4,22 @@
(** {1 Display} *)
+(** The type of tags for custom markers *)
+type tag = TtyTag.t
+
+(** The type of custom marker functions. A function of this type takes four arguments:
+
+ 1. [use_ansi]: whether ANSI control sequences will be used.
+ 2. [use_color]: whether colors should be used. If [use_ansi] is false, [use_color] must be false.
+ 3. Whether the mark is at the end of a line of a file.
+ 4. The mark to visualize.
+
+*)
+type marker = use_ansi:bool -> use_color:bool -> [`End_of_line | `End_of_file] option -> tag MarkedSource.mark -> string
+
+(** The default markers *)
+val default_marker : marker
+
(** This module provides functions to display or interact with diagnostics in UNIX terminals. *)
module Make (Message : MinimumSigs.Message) : sig
@@ -25,6 +41,7 @@ module Make (Message : MinimumSigs.Message) : sig
@param use_ansi Whether ANSI escape sequences should be used, overwriting the auto-detection. By default, the auto-detection checks whether the [output] is a TTY and whether the environment variable [TERM] is set to a non-empty value other than [dumb]. Note that this handler is currently using {i exclusively} ANSI escape sequences for highlighting, which means turning them off will lose the precise location. (This may change in the future.)
@param use_color Whether colors should be use when ANSI escape sequences are used, overwriting the auto-detection. By default, the auto-detection will turn off the colors if ANSI escape sequences should not be used or if a non-empty value was assigned to the environment variable [NO_COLOR]. Note that even when the colors are turned off, the handler may still use the bold style, the faint style, and underlines for highlighting if ANSI escape sequences are used. It is an error to pass [true] as this parameter and [false] as [use_ansi].
@param show_backtrace Whether the backtrace should be shown. The default is [true].
+ @param marker A function that that displays markers as strings. It takes the final values of [use_ansi] and [use_color], an indication whether it is at the end of a line or a file, and the marker to visualize. See {!type:marker}. The default value is {!val:default_marker}.
@param line_breaks The set of character sequences that are recognized as (hard) line breaks. The [`Unicode] set contains all Unicode character sequences in {{:https://www.unicode.org/versions/Unicode15.0.0/ch05.pdf#G41643}Unicode 15.0.0 Table 5-1.} The [`Traditional] set only contains [U+000A (LF)], [U+000D (CR)], and [U+000D U+000A (CRLF)] as line breaks. The default is the [`Traditional] set.
@param block_splitting_threshold The maximum number of consecutive, non-highlighted lines allowed in a block. The function will try to minimize the number of blocks, as long as no block has too many consecutive, non-highlighted lines. A higher threshold will lead to fewer blocks. When the threshold is zero, it means no block can contain any non-highlighted line. The default value is [5].
@param tab_size The number of spaces that should be used to replace a horizontal tab. Note that a horizontal tab is always expanded to the same number of spaces. The result should still be visually appealing as long as horizontal tabs are only used at the beginning of lines. The default value is [8].
@@ -35,5 +52,5 @@ module Make (Message : MinimumSigs.Message) : sig
@see for the [NO_COLOR] specification
*)
- val display : ?output:out_channel -> ?use_ansi:bool -> ?use_color:bool -> ?show_backtrace:bool -> ?line_breaks:[`Unicode | `Traditional] -> ?block_splitting_threshold:int -> ?tab_size:int -> ?debug:bool -> Message.t Diagnostic.t -> unit
+ val display : ?output:out_channel -> ?use_ansi:bool -> ?use_color:bool -> ?show_backtrace:bool -> ?marker:marker -> ?line_breaks:[`Unicode | `Traditional] -> ?block_splitting_threshold:int -> ?tab_size:int -> ?debug:bool -> Message.t Diagnostic.t -> unit
end
diff --git a/test/TestRangeFlattener.ml b/test/TestRangeFlattener.ml
index d72e64d..fb1fc38 100644
--- a/test/TestRangeFlattener.ml
+++ b/test/TestRangeFlattener.ml
@@ -24,7 +24,7 @@ let single_line_flatten () =
[(source,
[{begin_line_num=1;
end_line_num=1;
- markers=
+ marks=
[ pt1, RangeBegin (1, "3")
; pt1, RangeBegin (1, "1")
; pt1, RangeBegin (2, "2")
@@ -34,7 +34,7 @@ let single_line_flatten () =
; pt3, RangeEnd (1, "3")
; pt4, RangeEnd (3, "4")
];
- line_markers=[(1, (2, "2")); (1, (1, "1")); (1, (1, "3")); (1, (3, "4"))]}])]
+ line_marks=[(1, (2, "2")); (1, (1, "1")); (1, (1, "3")); (1, (3, "4"))]}])]
in
let actual = F.flatten ~block_splitting_threshold:5 ranges in
Alcotest.(check test_flattened) "RangeFlattener is correct" expected actual
@@ -83,7 +83,7 @@ ggggghh
[(source,
[{begin_line_num=2;
end_line_num=9;
- markers=
+ marks=
[(pt3, RangeBegin (1, "2"));
(pt18, RangeBegin (2, "1"));
(pt21, RangeEnd (2, "1"));
@@ -93,7 +93,7 @@ ggggghh
(pt40, RangeEnd (8, "4"));
(pt40, RangeEnd (4, "3"));
];
- line_markers=
+ line_marks=
[ 4, (2, "1")
; 4, (1, "2")
; 9, (8, "4")
@@ -101,10 +101,10 @@ ggggghh
]};
{begin_line_num=15;
end_line_num=15;
- markers=
+ marks=
[(begin_of_line15, RangeBegin (16, "5"));
(pt56, RangeEnd (16, "5"))];
- line_markers=
+ line_marks=
[(15, (16, "5"))]}])]
in
let actual = F.flatten ~block_splitting_threshold:5 ranges in
diff --git a/test/TestSourceMarker.ml b/test/TestSourceMarker.ml
index 056b772..e0fa684 100644
--- a/test/TestSourceMarker.ml
+++ b/test/TestSourceMarker.ml
@@ -15,16 +15,16 @@ let single_line mode eol () =
[{begin_line_num = 1;
end_line_num = 1;
lines =
- [{markers = [(1, "1"); (2, "2")];
+ [{marks = [(1, "1"); (2, "2")];
tokens =
[String "aaa";
- Marker (None, RangeBegin (1, "1"));
+ Mark (None, RangeBegin (1, "1"));
String "bbb";
- Marker (None, RangeBegin (2, "2"));
+ Mark (None, RangeBegin (2, "2"));
String "ccc";
- Marker (None, RangeEnd (1, "1"));
+ Mark (None, RangeEnd (1, "1"));
String "ddd";
- Marker (None, RangeEnd (2, "2"));
+ Mark (None, RangeEnd (2, "2"));
String "eee";
]}]}
]}
@@ -43,16 +43,16 @@ let multi_lines_with_ls () =
[{begin_line_num = 1;
end_line_num = 2;
lines =
- [{markers=[];
+ [{marks=[];
tokens=
[String "aa";
- Marker (None, RangeBegin (1, "1"));
+ Mark (None, RangeBegin (1, "1"));
String "bbbbb";
]};
- {markers=[(1, "1")];
+ {marks=[(1, "1")];
tokens=
[String "bbbb";
- Marker (None, RangeEnd (1, "1"));
+ Mark (None, RangeEnd (1, "1"));
String "ccc";
]}]}
]}
@@ -102,51 +102,51 @@ ggggghh
[{begin_line_num=2;
end_line_num=9;
lines=
- [{markers=[];
+ [{marks=[];
tokens=
[String "aa";
- Marker (None, RangeBegin (1, "2"));
+ Mark (None, RangeBegin (1, "2"));
String "bbbbb"]};
- {markers=[];
+ {marks=[];
tokens=
[String "bbbbbbb"]};
- {markers=[(2, "1"); (1, "2")];
+ {marks=[(2, "1"); (1, "2")];
tokens=
[String "b";
- Marker (None, RangeBegin (2, "1"));
+ Mark (None, RangeBegin (2, "1"));
String "*cc";
- Marker (None, RangeEnd (2, "1"));
- Marker (None, RangeEnd (1, "2"));
+ Mark (None, RangeEnd (2, "1"));
+ Mark (None, RangeEnd (1, "2"));
String "ddd"]};
- {markers=[];
+ {marks=[];
tokens=
[String "1"]};
- {markers=[];
+ {marks=[];
tokens=
[String "2"]};
- {markers=[];
+ {marks=[];
tokens=
[String "3"]};
- {markers=[];
+ {marks=[];
tokens=
[String "4"]};
- {markers=[(8, "4"); (4, "3")];
+ {marks=[(8, "4"); (4, "3")];
tokens=
[String "ee";
- Marker (None, RangeBegin (4, "3"));
+ Mark (None, RangeBegin (4, "3"));
String "++";
- Marker (None, RangeBegin (8, "4"));
+ Mark (None, RangeBegin (8, "4"));
String "fff";
- Marker (Some End_of_line, RangeEnd (8, "4"));
- Marker (Some End_of_line, RangeEnd (4, "3"))]}]};
+ Mark (Some `End_of_line, RangeEnd (8, "4"));
+ Mark (Some `End_of_line, RangeEnd (4, "3"))]}]};
{begin_line_num=15;
end_line_num=15;
lines=
- [{markers=[(16, "5")];
+ [{marks=[(16, "5")];
tokens=
- [Marker (None, RangeBegin (16, "5"));
+ [Mark (None, RangeBegin (16, "5"));
String "ggggg";
- Marker (None, RangeEnd (16, "5"));
+ Mark (None, RangeEnd (16, "5"));
String "hh"]}]}]}]
in
let actual = SM.mark ~line_breaks:`Traditional ~block_splitting_threshold:5 ranges in