private void applyInformationToEditorsLater(
     @NotNull final FileEditor fileEditor,
     @NotNull final TextEditorHighlightingPass pass,
     @NotNull final DaemonProgressIndicator updateProgress,
     @NotNull final AtomicInteger threadsToStartCountdown) {
   ApplicationManager.getApplication()
       .invokeLater(
           (DumbAwareRunnable)
               () -> {
                 if (isDisposed() || myProject.isDisposed()) {
                   updateProgress.cancel();
                 }
                 if (updateProgress.isCanceled()) {
                   log(updateProgress, pass, " is canceled during apply, sorry");
                   return;
                 }
                 Document document = pass.getDocument();
                 try {
                   if (fileEditor.getComponent().isDisplayable()
                       || ApplicationManager.getApplication().isUnitTestMode()) {
                     pass.applyInformationToEditor();
                     FileStatusMap fileStatusMap =
                         DaemonCodeAnalyzerEx.getInstanceEx(myProject).getFileStatusMap();
                     if (document != null) {
                       fileStatusMap.markFileUpToDate(document, pass.getId());
                     }
                     log(updateProgress, pass, " Applied");
                   }
                 } catch (ProcessCanceledException e) {
                   log(updateProgress, pass, "Error " + e);
                   throw e;
                 } catch (RuntimeException e) {
                   VirtualFile file =
                       document == null
                           ? null
                           : FileDocumentManager.getInstance().getFile(document);
                   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) {
                   log(updateProgress, pass, "Stopping ");
                   updateProgress.stopIfRunning();
                 } else {
                   log(
                       updateProgress,
                       pass,
                       "Finished but there are passes in the queue: "
                           + threadsToStartCountdown.get());
                 }
               },
           Registry.is("ide.perProjectModality")
               ? ModalityState.defaultModalityState()
               : ModalityState.stateForComponent(fileEditor.getComponent()));
 }