Skip to content
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

Check if the marker still exists before calculating a marker resolution #995

Merged
merged 1 commit into from
May 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,30 @@ private void checkMarkerResolution(IMarker marker) throws IOException, CoreExcep
params.setContext(context);
params.setTextDocument(LSPEclipseUtils.toTextDocumentIdentifier(res));
params.setRange(diagnostic.getRange());
marker.setAttribute(LSP_REMEDIATION, COMPUTING);
try {
executor.computeFirst(ls -> ls.getTextDocumentService().codeAction(params)).thenAccept(optional -> {
try {
marker.setAttribute(LSP_REMEDIATION, optional.orElse(Collections.emptyList()));
} catch (CoreException e) {
LanguageServerPlugin.logError(e);
}
}).thenRun(() -> {
Display display = UI.getDisplay();
display.asyncExec(() -> {
ITextViewer textViewer = UI.getActiveTextViewer();
if (textViewer != null) {
// Do not re-invoke hover right away as hover may not be showing at all yet
display.timerExec(500, () -> reinvokeQuickfixProposalsIfNecessary(textViewer));
if (marker.exists()) { // otherwise the marker has been removed by now
marker.setAttribute(LSP_REMEDIATION, COMPUTING);
try {
executor.computeFirst(ls -> ls.getTextDocumentService().codeAction(params)).thenAccept(optional -> {
try {
marker.setAttribute(LSP_REMEDIATION, optional.orElse(Collections.emptyList()));
} catch (CoreException e) {
LanguageServerPlugin.logError(e);
}
});
}).get(300, TimeUnit.MILLISECONDS);
// wait a bit to avoid showing too much "Computing" without looking like a freeze
} catch (TimeoutException e) {
LanguageServerPlugin.logWarning(
"Could get code actions due to timeout after 300 milliseconds in `textDocument/codeAction`", e); //$NON-NLS-1$
}).thenRun(() -> {
Display display = UI.getDisplay();
display.asyncExec(() -> {
ITextViewer textViewer = UI.getActiveTextViewer();
if (textViewer != null) {
// Do not re-invoke hover right away as hover may not be showing at all yet
display.timerExec(500, () -> reinvokeQuickfixProposalsIfNecessary(textViewer));
}
});
}).get(300, TimeUnit.MILLISECONDS);
// wait a bit to avoid showing too much "Computing" without looking like a freeze
} catch (TimeoutException e) {
LanguageServerPlugin.logWarning(
"Could get code actions due to timeout after 300 milliseconds in `textDocument/codeAction`", e); //$NON-NLS-1$
}
}
}
}
Expand Down