Skip to content

Just make the diagnostics parser accept all the lines, including non-indented ones... #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ export let parseCompilerLogOutput = (
tag: undefined,
content: [],
});
} else if (line.startsWith("#Start(")) {
// do nothing for now
} else if (line.startsWith("#Done(")) {
done = true;
} else if (/^ +([0-9]+| +|\.) (│|┆)/.test(line)) {
Expand All @@ -326,6 +328,17 @@ export let parseCompilerLogOutput = (
// │
// 10 ┆
} else if (line.startsWith(" ")) {
// part of the actual diagnostics message
parsedDiagnostics[parsedDiagnostics.length - 1].content.push(
line.slice(2)
);
} else if (line.trim() != "") {
// We'll assume that everything else is also part of the diagnostics too.
// Most of these should have been indented 2 spaces; sadly, some of them
// aren't (e.g. outcome printer printing badly, and certain old ocaml type
// messages not printing with indent). We used to get bug reports and fix
// the messages, but that strategy turned out too slow. One day we should
// revert to not having this branch...
parsedDiagnostics[parsedDiagnostics.length - 1].content.push(line);
}
}
Expand All @@ -338,22 +351,14 @@ export let parseCompilerLogOutput = (
if (result[file] == null) {
result[file] = [];
}
let cleanedUpDiagnostic =
diagnosticMessage
.map((line) => {
// remove the spaces in front
return line.slice(2);
})
.join("\n")
// remove start and end whitespaces/newlines
.trim() + "\n";
result[file].push({
severity: parsedDiagnostic.severity,
tags: parsedDiagnostic.tag === undefined ? [] : [parsedDiagnostic.tag],
code: parsedDiagnostic.code,
range,
source: "ReScript",
message: cleanedUpDiagnostic,
// remove start and end whitespaces/newlines
message: diagnosticMessage.join("\n").trim() + "\n",
});
});

Expand Down