Skip to content

Dont create empty diagnostic messages #1114

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
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

#### :bug: Bug fix

- Fix: Dont create empty diagnostic messages. https://github.com/rescript-lang/rescript-vscode/pull/1114

- Fix: `rescript-editor-analysis.exe semanticTokens` sometimes returned invalid JSON, which affected syntax highlighting. https://github.com/rescript-lang/rescript-vscode/pull/1113

- 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
- 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

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

Expand Down
46 changes: 27 additions & 19 deletions server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,11 @@ export let parseCompilerLogOutput = async (
tag: undefined,
content: [],
});
} else if (line.startsWith("FAILED: cannot make progress due to previous errors.")) {
// skip
} else if (line.startsWith("FAILED: dependency cycle")) {
// skip as we can't extract a filepath from this error message
} else if (line.startsWith("FAILED:")) {
// File with a self cycle
parsedDiagnostics.push({
code: undefined,
severity: t.DiagnosticSeverity.Error,
Expand Down Expand Up @@ -700,26 +703,31 @@ export let parseCompilerLogOutput = async (
result[file] = [];
}

let diagnostic: p.Diagnostic = {
severity: parsedDiagnostic.severity,
tags: parsedDiagnostic.tag === undefined ? [] : [parsedDiagnostic.tag],
code: parsedDiagnostic.code,
range,
source: "ReScript",
// remove start and end whitespaces/newlines
message: diagnosticMessage.join("\n").trim(),
};
// remove start and end whitespaces/newlines
let message = diagnosticMessage.join("\n").trim()

// vscode.Diagnostic throws an error if `message` is a blank string
if (message != "") {
let diagnostic: p.Diagnostic = {
severity: parsedDiagnostic.severity,
tags: parsedDiagnostic.tag === undefined ? [] : [parsedDiagnostic.tag],
code: parsedDiagnostic.code,
range,
source: "ReScript",
message,
};

// Check for potential code actions
await codeActions.findCodeActionsInDiagnosticsMessage({
addFoundActionsHere: foundCodeActions,
diagnostic,
diagnosticMessage,
file,
range,
});
// Check for potential code actions
await codeActions.findCodeActionsInDiagnosticsMessage({
addFoundActionsHere: foundCodeActions,
diagnostic,
diagnosticMessage,
file,
range,
});

result[file].push(diagnostic);
result[file].push(diagnostic);
}
}

return {
Expand Down
Loading