From 3caa4aaa2485091ec32e779c4f3e10af5831842c Mon Sep 17 00:00:00 2001 From: Kate Botsman Date: Wed, 27 Mar 2024 10:51:12 +0100 Subject: [PATCH] Postpone (`invokeLater`) `stopProcess` to allow `myUpdateRunnableFuture` to finish `stopProcess` checks whether the future is finished before scheduling a new task to avoid many re-schedules. However, in this case, the future will never be in finished state, because `stopProcess` is called from the inside of it. So, the analyzer will never schedule a new task here. To allow the future to finish before `stopProcess` is called, we can postpone its execution by using `invokeLater`. By the time `stopProcess` is executed, this future is going to finish, so the check can succeed. Fixes rare issue in RDCT-933 when analyzer doesn't finish editor analysing. GitOrigin-RevId: 5ecb914ce2b3c792988853955fcb9a03d6fc9129 --- .../codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java index 43bf1d391017..ba5bb32c51c4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java @@ -1100,7 +1100,9 @@ public final class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx } if (!submitted) { // happens e.g., when we are trying to open a directory and there's a FileEditor supporting this - dca.stopProcess(true, "Couldn't create session for "+activeEditors); + ApplicationManager.getApplication().invokeLater(() -> { + dca.stopProcess(true, "Couldn't create session for " + activeEditors); + }); } } catch (ProcessCanceledException ignored) {