You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Diagnostic.mli
+45-38Lines changed: 45 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -3,37 +3,9 @@
3
3
(* @include *)
4
4
includemoduletype of DiagnosticData
5
5
6
-
(** {1 Constructing Messages} *)
7
-
8
-
(** [text str] converts the string [str] into a text, converting each ['\n'] into a call to {!val:Format.pp_force_newline}. *)
9
-
valtext : string -> text
10
-
11
-
(** [textf format ...] formats a text. It is an alias of {!val:Format.dprintf}. Note that there should not be any literal control characters (e.g., literal newline characters). *)
12
-
valtextf : ('a, Format.formatter, unit, text) format4 -> 'a
13
-
14
-
(** [ktextf kont format ...] is [kont (textf format ...)]. It is an alias of {!val:Format.kdprintf}. *)
15
-
valktextf : (text -> 'b) -> ('a, Format.formatter, unit, 'b) format4 -> 'a
16
-
17
-
(** [loctext str] converts the string [str] into a loctext.
18
-
19
-
@param loc The location of the loctext (usually the code) to highlight. *)
20
-
valloctext : ?loc:Range.t -> string -> loctext
21
-
22
-
(** [loctextf format ...] constructs a loctext. Note that there should not be any literal control characters (e.g., literal newline characters).
23
-
24
-
@param loc The location of the loctext (usually the code) to highlight.
25
-
*)
26
-
valloctextf : ?loc:Range.t -> ('a, Format.formatter, unit, loctext) format4 -> 'a
27
-
28
-
(** [kloctextf kont format ...] is [kont (loctextf format ...)].
29
-
30
-
@param loc The location of the loctext (usually the code) to highlight.
31
-
*)
32
-
valkloctextf : ?loc:Range.t -> (loctext -> 'b) -> ('a, Format.formatter, unit, 'b) format4 -> 'a
33
-
34
6
(** {1 Constructing Diagnostics} *)
35
7
36
-
(** [of_text severity message text] constructs a diagnostic from a {!type:text}.
8
+
(** [of_text severity message text] constructs a diagnostic from a {!type:Text.t}.
37
9
38
10
Example:
39
11
{[
@@ -45,9 +17,9 @@ val kloctextf : ?loc:Range.t -> (loctext -> 'b) -> ('a, Format.formatter, unit,
(** [makef severity message format ...] is [of_loctext severity message (loctextf format ...)]. It formats the message and constructs a diagnostic out of it.
46
+
(** [makef severity message format ...] is [of_loctext severity message (Loctext.makef format ...)]. It formats the message and constructs a diagnostic out of it.
75
47
76
48
Example:
77
49
{[
@@ -82,20 +54,55 @@ val make : ?loc:Range.t -> ?backtrace:backtrace -> ?extra_remarks:loctext list -
82
54
@param backtrace The backtrace (to overwrite the accumulative frames up to this point).
83
55
@param extra_remarks Additional remarks that are not part of the backtrace.
84
56
*)
85
-
valmakef : ?loc:Range.t -> ?backtrace:backtrace -> ?extra_remarks:loctextlist -> severity -> 'message -> ('a, Format.formatter, unit, 'messaget) format4 -> 'a
57
+
valmakef : ?loc:Range.t -> ?backtrace:backtrace -> ?extra_remarks:Loctext.tlist -> severity -> 'message -> ('a, Format.formatter, unit, 'messaget) format4 -> 'a
86
58
87
59
(** [kmakef kont severity message format ...] is [kont (makef severity message format ...)].
88
60
89
61
@param loc The location of the text (usually the code) to highlight.
90
62
@param backtrace The backtrace (to overwrite the accumulative frames up to this point).
91
63
@param extra_remarks Additional remarks that are not part of the backtrace.
(** A convenience function that converts a {!type:text} into a string by formatting it with the maximum admissible margin and then replacing newlines and indentation with a space character. *)
101
-
valstring_of_text : text -> string
72
+
(** {1 Deprecated Types and Functions} *)
73
+
74
+
(** An alias of [Text.t] for backward compatibility. *)
75
+
typetext = Text.t
76
+
[@@ocaml.alert deprecated"Use Text.t instead"]
77
+
78
+
(** An alias of [Loctext.t] for backward compatibility. *)
79
+
typeloctext = Loctext.t
80
+
[@@ocaml.alert deprecated"Use Loctext.t instead"]
81
+
82
+
(** An alias of [Text.make] for backward compatibility. *)
83
+
valtext : string -> Text.t
84
+
[@@ocaml.alert deprecated"Use Text.make instead"]
85
+
86
+
(** An alias of [Text.makef] for backward compatibility. *)
87
+
valtextf : ('a, Format.formatter, unit, Text.t) format4 -> 'a
Copy file name to clipboardExpand all lines: src/DiagnosticData.ml
+3-19Lines changed: 3 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -8,35 +8,19 @@ type severity =
8
8
| Error(** A serious error caused by the end user (the user of your proof assistant or compiler) or other external factors (e.g., internet not working). *)
9
9
| Bug(** A serious error likely caused by a bug in the proof assistant. You would want the end user to report the bug back to you. This is useful for indicating that certain branches in a pattern matching should be "impossible", while printing out debugging information in case the program logic is flawed. *)
10
10
11
-
(** The type of texts.
12
-
13
-
When we render a diagnostic, the layout engine of the diagnostic handler should be the one making layout choices. Therefore, we cannot pass already formatted strings. Instead, a text is defined to be a function that takes a formatter and uses it to render the content. A valid text must satisfy the following two conditions:
14
-
+ {b All string (and character) literals must be encoded using UTF-8.}
15
-
+ {b All string (and character) literals must not contain control characters (such as the newline character [\n]).} It is okay to have break hints (such as [@,] and [@ ]) but not literal control characters. This means you should avoid pre-formatted strings, and if you must use them, use {!val:text} to convert newline characters. Control characters include `U+0000-001F` (C0 controls), `U+007F` (backspace) and `U+0080-009F` (C1 controls). These characters are banned because they would mess up the cursor position.
16
-
17
-
{i Pro-tip:} to format a text in another text, use [%t]:
18
-
{[
19
-
let t = textf "@[<2>this is what the master said:@ @[%t@]@]" inner_text
20
-
]}
21
-
*)
22
-
typetext = Format.formatter -> unit
23
-
24
-
(** A loctext is a {!type:text} with location information. "loctext" is a portmanteau of "locate" and "text". *)
25
-
typeloctext = textRange.located
26
-
27
11
(** A backtrace is a (backward) list of loctexts. *)
28
-
typebacktrace = loctextbwd
12
+
typebacktrace = Loctext.tbwd
29
13
30
14
(** The type of diagnostics. *)
31
15
type'message t = {
32
16
severity : severity;
33
17
(** Severity of the diagnostic. *)
34
18
message : 'message;
35
19
(** The (structured) message. *)
36
-
explanation : loctext;
20
+
explanation : Loctext.t;
37
21
(** The free-form explanation. *)
38
22
backtrace : backtrace;
39
23
(** The backtrace leading to this diagnostic. *)
40
-
extra_remarks : loctextbwd;
24
+
extra_remarks : Loctext.tbwd;
41
25
(** Additional remarks that are relevant to the main message but not part of the backtrace. It is a backward list so that new remarks can be added to its end easily. *)
0 commit comments