1
1
open TopTypes ;
2
2
open Infix ;
3
+ module J = JsonShort ;
3
4
4
5
let makeDiagnostic = (documentText, ((line, c1, c2), message)) => {
5
- open JsonShort ;
6
6
let text = String . concat("\n " , message);
7
7
let (l2 , c22 ) =
8
8
{
@@ -14,10 +14,10 @@ let makeDiagnostic = (documentText, ((line, c1, c2), message)) => {
14
14
switch (ErrorParser . parseDependencyError(text)) {
15
15
| None =>
16
16
Some (
17
- o([
17
+ J . o([
18
18
("range" , Protocol . rangeOfInts(line, c1, l2, c22)),
19
- ("message" , s(text)),
20
- ("severity" , i(Utils . startsWith(text, "Warning" ) ? 2 : 1 )),
19
+ ("message" , J . s(text)),
20
+ ("severity" , J . i(Utils . startsWith(text, "Warning" ) ? 2 : 1 )),
21
21
] ),
22
22
)
23
23
| Some (_ ) =>
@@ -42,66 +42,62 @@ let runDiagnostics = (uri, state, ~package) => {
42
42
Log . log("Running diagnostics for " ++ uri);
43
43
let %try_consume documentText = getText(state, uri);
44
44
let %try_consume result = State.getCompilationResult(uri, state, ~package);
45
- JsonShort . (
46
- Rpc . sendNotification (
47
- stdout ,
48
- "textDocument/publishDiagnostics" ,
49
- o ([
50
- ("uri" , s (uri )),
51
- (
52
- "diagnostics" ,
53
- switch (result ) {
54
- | AsYouType . SyntaxError (text, otherText, _) =>
55
- let errors =
56
- ErrorParser.parseErrors(
57
- Utils.splitLines(Utils.stripAnsii(otherText)),
58
- );
59
- let errors =
60
- errors
61
- |> List.filter(((_loc, message)) =>
62
- message
63
- != [
64
- "Error: Uninterpreted extension 'merlin.syntax-error'.",
65
- ]
66
- );
67
- let errors =
68
- ErrorParser.parseErrors(
69
- Utils.splitLines(Utils.stripAnsii(text)),
70
- )
71
- @ errors;
72
- l(errors |> Utils.filterMap(makeDiagnostic(documentText)));
73
- | Success(text, _ ) =>
74
- if (String.trim(text) == "") {
75
- l([]);
76
- } else {
77
- let errors =
78
- ErrorParser.parseErrors(
79
- Utils.splitLines(Utils.stripAnsii(text)),
80
- );
81
- l(errors |> Utils.filterMap(makeDiagnostic(documentText)));
82
- }
83
- | TypeError (text , _ ) =>
84
- Log . log ("type error here " ++ text );
45
+ Rpc . sendNotification (
46
+ stdout ,
47
+ "textDocument/publishDiagnostics" ,
48
+ J . o ([
49
+ ("uri" , J . s (uri )),
50
+ (
51
+ "diagnostics" ,
52
+ switch (result ) {
53
+ | AsYouType . SyntaxError (text, otherText, _) =>
54
+ let errors =
55
+ ErrorParser.parseErrors(
56
+ Utils.splitLines(Utils.stripAnsii(otherText)),
57
+ );
58
+ let errors =
59
+ errors
60
+ |> List.filter(((_loc, message)) =>
61
+ message
62
+ != ["Error: Uninterpreted extension 'merlin.syntax-error'."]
63
+ );
64
+ let errors =
65
+ ErrorParser.parseErrors(
66
+ Utils.splitLines(Utils.stripAnsii(text)),
67
+ )
68
+ @ errors;
69
+ J.l(errors |> Utils.filterMap(makeDiagnostic(documentText)));
70
+ | Success(text, _ ) =>
71
+ if (String.trim(text) == "") {
72
+ J.l([]);
73
+ } else {
85
74
let errors =
86
75
ErrorParser.parseErrors(
87
76
Utils.splitLines(Utils.stripAnsii(text)),
88
- )
89
- |> List . filter (((_loc , message )) => {
90
- !
91
- Str . string_match(
92
- Str.regexp(
93
- {|.*Missing dependency [a-zA-Z]+ in search path|},
94
- ),
95
- String . concat (" " , message ),
96
- 0 ,
97
- )
98
- });
77
+ );
78
+ J . l(errors |> Utils.filterMap(makeDiagnostic(documentText)));
79
+ }
80
+ | TypeError (text , _ ) =>
81
+ Log . log ("type error here " ++ text );
82
+ let errors =
83
+ ErrorParser . parseErrors (
84
+ Utils . splitLines (Utils . stripAnsii (text )),
85
+ )
86
+ |> List . filter (((_loc , message )) => {
87
+ !
88
+ Str . string_match(
89
+ Str.regexp(
90
+ {|.*Missing dependency [a-zA-Z]+ in search path|},
91
+ ),
92
+ String . concat (" " , message ),
93
+ 0 ,
94
+ )
95
+ });
99
96
100
- l (errors |> Utils . filterMap (makeDiagnostic (documentText )));
101
- },
102
- ),
103
- ] ),
104
- )
97
+ J . l (errors |> Utils . filterMap (makeDiagnostic (documentText )));
98
+ },
99
+ ),
100
+ ] ),
105
101
);
106
102
};
107
103
0 commit comments