void (@NotNull FileEditor fileEditor, @NotNull HighlightingPass pass, @NotNull DaemonProgressIndicator updateProgress, @NotNull AtomicInteger threadsToStartCountdown, @NotNull CoroutineContext context, @NotNull Runnable callbackOnApplied) { ApplicationManager.getApplication().invokeLater(() -> { if (isDisposed() || !fileEditor.isValid()) { updateProgress.cancel(); } if (updateProgress.isCanceled()) { log(updateProgress, pass, " is canceled during apply, sorry"); return; } try (AccessToken ignored = ClientId.withClientId(ClientFileEditorManager.getClientId(fileEditor))) { try (AccessToken ignored2 = ThreadContext.installThreadContext(context, true)) { if (UIUtil.isShowing(fileEditor.getComponent())) { pass.applyInformationToEditor(); repaintErrorStripeAndIcon(fileEditor); if (pass instanceof TextEditorHighlightingPass text) { FileStatusMap fileStatusMap = DaemonCodeAnalyzerEx.getInstanceEx(myProject).getFileStatusMap(); Document document = text.getDocument(); int passId = text.getId(); fileStatusMap.markFileUpToDate(document, passId); } log(updateProgress, pass, " Applied"); } } } catch (ProcessCanceledException e) { log(updateProgress, pass, "Error " + e); throw e; } catch (RuntimeException e) { VirtualFile file = fileEditor.getFile(); FileType fileType = file == null ? null : file.getFileType(); String message = "Exception while applying information to " + fileEditor + "("+fileType+")"; log(updateProgress, pass, message + e); throw new RuntimeException(message, e); } if (threadsToStartCountdown.decrementAndGet() == 0) { HighlightingSessionImpl.waitForAllSessionsHighlightInfosApplied(updateProgress); log(updateProgress, pass, "Stopping "); updateProgress.stopIfRunning(); clearStaleEntries(); } else { log(updateProgress, pass, "Finished but there are passes in the queue: " + threadsToStartCountdown.get()); } callbackOnApplied.run(); }, updateProgress.getModalityState(), pass.getExpiredCondition()); }