blob: 7f697f86bd81058caec73f1da2f7e56d50fa50ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
module Types = Linol_lsp.Types
(** Generate a diagnostic from the report *)
let position : Lexing.position -> Types.Position.t =
fun pos ->
{
character = pos.Lexing.pos_cnum - pos.Lexing.pos_bol;
line = pos.Lexing.pos_lnum - 1;
}
let build : Qsp_syntax.Report.t -> Types.Diagnostic.t =
fun { level; loc; message } ->
let severity =
match level with
| Error -> Types.DiagnosticSeverity.Error
| Warn -> Types.DiagnosticSeverity.Warning
| Debug -> Types.DiagnosticSeverity.Hint
in
let start = position (fst loc) and end_ = position (snd loc) in
let range = Types.Range.{ start; end_ } in
let message = `String message in
Types.Diagnostic.create ~range ~message ~severity ()
|