Skip to content

Commit e47bc54

Browse files
authored
Dont create empty diagnostic messages (#1114)
* Don't create diagnostics with blank messages * Don't attempt to create diagnostic message for compiler log line 'cannot make progress due to previous errors' * Don't attempt to create diagnostic message for dependency cycle error * Add CHANGELOG entry * Remove extra space before CHANGELOG entry
1 parent 5b76419 commit e47bc54

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919

2020
#### :bug: Bug fix
2121

22+
- Fix: Dont create empty diagnostic messages. https://github.com/rescript-lang/rescript-vscode/pull/1114
23+
2224
- Fix: `rescript-editor-analysis.exe semanticTokens` sometimes returned invalid JSON, which affected syntax highlighting. https://github.com/rescript-lang/rescript-vscode/pull/1113
2325

24-
- Fix: hang in `rescript-editor-analysis.exe codeAction` that sometimes prevented ReScript files from being saved in VS Code. https://github.com/rescript-lang/rescript-vscode/pull/1112
26+
- Fix: hang in `rescript-editor-analysis.exe codeAction` that sometimes prevented ReScript files from being saved in VS Code. https://github.com/rescript-lang/rescript-vscode/pull/1112
2527

2628
- Fix: show existing compiler errors and warnings on file open. https://github.com/rescript-lang/rescript-vscode/pull/1103
2729

server/src/utils.ts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,11 @@ export let parseCompilerLogOutput = async (
568568
tag: undefined,
569569
content: [],
570570
});
571+
} else if (line.startsWith("FAILED: cannot make progress due to previous errors.")) {
572+
// skip
573+
} else if (line.startsWith("FAILED: dependency cycle")) {
574+
// skip as we can't extract a filepath from this error message
571575
} else if (line.startsWith("FAILED:")) {
572-
// File with a self cycle
573576
parsedDiagnostics.push({
574577
code: undefined,
575578
severity: t.DiagnosticSeverity.Error,
@@ -700,26 +703,31 @@ export let parseCompilerLogOutput = async (
700703
result[file] = [];
701704
}
702705

703-
let diagnostic: p.Diagnostic = {
704-
severity: parsedDiagnostic.severity,
705-
tags: parsedDiagnostic.tag === undefined ? [] : [parsedDiagnostic.tag],
706-
code: parsedDiagnostic.code,
707-
range,
708-
source: "ReScript",
709-
// remove start and end whitespaces/newlines
710-
message: diagnosticMessage.join("\n").trim(),
711-
};
706+
// remove start and end whitespaces/newlines
707+
let message = diagnosticMessage.join("\n").trim()
708+
709+
// vscode.Diagnostic throws an error if `message` is a blank string
710+
if (message != "") {
711+
let diagnostic: p.Diagnostic = {
712+
severity: parsedDiagnostic.severity,
713+
tags: parsedDiagnostic.tag === undefined ? [] : [parsedDiagnostic.tag],
714+
code: parsedDiagnostic.code,
715+
range,
716+
source: "ReScript",
717+
message,
718+
};
712719

713-
// Check for potential code actions
714-
await codeActions.findCodeActionsInDiagnosticsMessage({
715-
addFoundActionsHere: foundCodeActions,
716-
diagnostic,
717-
diagnosticMessage,
718-
file,
719-
range,
720-
});
720+
// Check for potential code actions
721+
await codeActions.findCodeActionsInDiagnosticsMessage({
722+
addFoundActionsHere: foundCodeActions,
723+
diagnostic,
724+
diagnosticMessage,
725+
file,
726+
range,
727+
});
721728

722-
result[file].push(diagnostic);
729+
result[file].push(diagnostic);
730+
}
723731
}
724732

725733
return {

0 commit comments

Comments
 (0)