11let document_syntax ~path =
2- let parse =
3- Res_driver. parsingEngine.parseImplementation ~for Printer:false
4- ~filename: path
2+ let get_diagnostics diagnostics =
3+ match diagnostics with
4+ | [] -> []
5+ | diagnostics ->
6+ diagnostics
7+ |> List. rev_map (fun diagnostic ->
8+ let _, startline, startcol =
9+ Location. get_pos_info (Res_diagnostics. getStartPos diagnostic)
10+ in
11+ let _, endline, endcol =
12+ Location. get_pos_info (Res_diagnostics. getEndPos diagnostic)
13+ in
14+ Protocol. stringifyDiagnostic
15+ {
16+ range =
17+ {
18+ start = {line = startline - 1 ; character = startcol};
19+ end_ = {line = endline - 1 ; character = endcol};
20+ };
21+ message = Res_diagnostics. explain diagnostic;
22+ severity = Error ;
23+ })
524 in
6- match parse.diagnostics with
7- | [] -> []
8- | diagnostics ->
9- diagnostics
10- |> List. rev_map (fun diagnostic ->
11- let _, startline, startcol =
12- Location. get_pos_info (Res_diagnostics. getStartPos diagnostic)
13- in
14- let _, endline, endcol =
15- Location. get_pos_info (Res_diagnostics. getEndPos diagnostic)
16- in
17- Protocol. stringifyDiagnostic
18- {
19- range =
20- {
21- start = {line = startline - 1 ; character = startcol};
22- end_ = {line = endline - 1 ; character = endcol};
23- };
24- message = Res_diagnostics. explain diagnostic;
25- severity = Error ;
26- })
25+ if FindFiles. isImplementation path then
26+ let parseImplementation =
27+ Res_driver. parsingEngine.parseImplementation ~for Printer:false
28+ ~filename: path
29+ in
30+ get_diagnostics parseImplementation.diagnostics
31+ else if FindFiles. isInterface path then
32+ let parseInterface =
33+ Res_driver. parsingEngine.parseInterface ~for Printer:false ~filename: path
34+ in
35+ get_diagnostics parseInterface.diagnostics
36+ else []
0 commit comments