Skip to content

Commit c1b6d8d

Browse files
committed
fix: Quick fix are not available after a restart
Signed-off-by: azerr <azerr@redhat.com>
1 parent 54bfc7a commit c1b6d8d

3 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/main/java/com/redhat/devtools/lsp4ij/LanguageServerWrapper.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public class LanguageServerWrapper implements Disposable {
102102
protected final InitializeParams initParams = new InitializeParams();
103103
@NotNull
104104
private final LanguageServerDefinition serverDefinition;
105-
private final AtomicBoolean stopping = new AtomicBoolean(false);
106105
private final ExecutorService dispatcher;
107106
private final ExecutorService listener;
108107
private final SimpleModificationTracker modificationTracker = new SimpleModificationTracker();
@@ -1379,12 +1378,11 @@ public Alarm getTraceFlushAlarm() {
13791378
* @return true if the language server is stopping and false otherwise.
13801379
*/
13811380
public boolean isStopping() {
1382-
return this.stopping.get();
1381+
return getServerStatus() == ServerStatus.stopping;
13831382
}
13841383

13851384
public synchronized CompletableFuture<Void> stop() {
1386-
final boolean alreadyStopping = this.stopping.getAndSet(true);
1387-
return stop(alreadyStopping);
1385+
return stop(isStopping());
13881386
}
13891387

13901388
private synchronized CompletableFuture<Void> stop(boolean alreadyStopping) {
@@ -1427,7 +1425,6 @@ private synchronized CompletableFuture<Void> stop(@Nullable InitializingContext
14271425
shutdownAll(languageServer, lspStreamProvider, launcherFuture);
14281426
boolean delayedCurrent = currentInitializingContext == null || initializingContext.equals(currentInitializingContext);
14291427
if (delayedCurrent) {
1430-
this.stopping.set(false);
14311428
updateStatus(ServerStatus.stopped);
14321429
}
14331430
});

src/main/java/com/redhat/devtools/lsp4ij/features/diagnostics/LSPDiagnosticHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
*/
3232
public class LSPDiagnosticHandler implements Consumer<PublishDiagnosticsParams> {
3333

34-
private final LanguageServerWrapper languageServerWrapper;
34+
private final @NotNull LanguageServerWrapper languageServerWrapper;
3535

36-
public LSPDiagnosticHandler(LanguageServerWrapper languageServerWrapper) {
36+
public LSPDiagnosticHandler(@NotNull LanguageServerWrapper languageServerWrapper) {
3737
this.languageServerWrapper = languageServerWrapper;
3838
}
3939

4040
@Override
41-
public void accept(PublishDiagnosticsParams params) {
41+
public void accept(@NotNull PublishDiagnosticsParams params) {
4242
Project project = languageServerWrapper.getProject();
4343
if (project.isDisposed()) {
4444
return;

src/main/java/com/redhat/devtools/lsp4ij/features/diagnostics/LSPDiagnosticsForServer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,16 @@ private Map<Diagnostic, LSPLazyCodeActions> toMap(@NotNull Collection<Diagnostic
162162

163163
// Associate each diagnostic with the list of code actions to load for a given range
164164
for (DiagnosticData data : diagnosticsGroupByCoveredRange) {
165-
var action = new LSPLazyCodeActions(data.diagnostics(), file, languageServer);
165+
var newCodeActions = new LSPLazyCodeActions(data.diagnostics(), file, languageServer);
166166
data.diagnostics()
167167
.forEach(d -> {
168168
// Get the existing LSP lazy code actions for the current diagnostic
169-
LSPLazyCodeActions actions = existingDiagnostics != null ? existingDiagnostics.get(d) : null;
170-
if (actions != null) {
169+
LSPLazyCodeActions oldCodeActions = existingDiagnostics != null ? existingDiagnostics.get(d) : null;
170+
if (oldCodeActions != null) {
171171
// cancel the LSP textDocument/codeAction request if needed
172-
actions.cancel();
172+
oldCodeActions.cancel();
173173
}
174-
map.put(d, action);
174+
map.put(d, newCodeActions);
175175
});
176176

177177
}

0 commit comments

Comments
 (0)