forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiagnostics.ml
34 lines (34 loc) · 1.16 KB
/
Diagnostics.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
let document_syntax ~path =
let get_diagnostics diagnostics =
diagnostics
|> List.map (fun diagnostic ->
let _, startline, startcol =
Location.get_pos_info (Res_diagnostics.get_start_pos diagnostic)
in
let _, endline, endcol =
Location.get_pos_info (Res_diagnostics.get_end_pos diagnostic)
in
Protocol.stringifyDiagnostic
{
range =
{
start = {line = startline - 1; character = startcol};
end_ = {line = endline - 1; character = endcol};
};
message = Res_diagnostics.explain diagnostic;
severity = 1;
})
in
if FindFiles.isImplementation path then
let parseImplementation =
Res_driver.parsing_engine.parse_implementation ~for_printer:false
~filename:path
in
get_diagnostics parseImplementation.diagnostics
else if FindFiles.isInterface path then
let parseInterface =
Res_driver.parsing_engine.parse_interface ~for_printer:false
~filename:path
in
get_diagnostics parseInterface.diagnostics
else []