void (@Nullable Project project, @NotNull UpdateRunnable updateRunnable) { ThreadingAssertions.assertEventDispatchThread(); DaemonCodeAnalyzerImpl dca; if (project == null || project.isDefault() || !project.isInitialized() || project.isDisposed() || LightEdit.owns(project) || (dca = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project)).myDisposed) { return; } if (PowerSaveMode.isEnabled()) { // to show the correct "power save" traffic light icon dca.myListeners.repaintTrafficLightIconForAllEditors(); return; } synchronized (dca) { long actualDelay = dca.myScheduledUpdateTimestamp - System.nanoTime(); if (actualDelay > 0) { // started too soon (there must've been some typings after we'd scheduled this; need to re-schedule) dca.scheduleUpdateRunnable(actualDelay); return; } } Collection<? extends FileEditor> activeEditors = dca.getSelectedEditors(); boolean updateByTimerEnabled = dca.isUpdateByTimerEnabled(); if (PassExecutorService.LOG.isDebugEnabled()) { PassExecutorService.log(null, null, "Update Runnable. myUpdateByTimerEnabled:", updateByTimerEnabled, " activeEditors:", activeEditors, (dca.getPsiDocumentManager().hasEventSystemEnabledUncommittedDocuments() ? " hasEventSystemEnabledUncommittedDocuments(" + Arrays.toString(dca.getPsiDocumentManager().getUncommittedDocuments()) + ")" : "()") + (ApplicationManager.getApplication().isWriteAccessAllowed() ? " inside write action" : "r")); } if (!updateByTimerEnabled || activeEditors.isEmpty()) { return; } if (ApplicationManager.getApplication().isWriteAccessAllowed()) { // makes no sense to start from within write action - will cancel anyway // we'll restart when the write action finish return; } if (dca.getPsiDocumentManager().hasEventSystemEnabledUncommittedDocuments()) { // restart when everything committed dca.getPsiDocumentManager().performLaterWhenAllCommitted(updateRunnable); return; } try { boolean submitted = false; for (FileEditor fileEditor : activeEditors) { if (fileEditor instanceof TextEditor textEditor && !AsyncEditorLoader.Companion.isEditorLoaded(textEditor.getEditor())) { // make sure the highlighting is restarted when the editor is finally loaded, because otherwise some crazy things happen, // for instance `FileEditor.getBackgroundHighlighter()` returning null, essentially stopping highlighting silently AsyncEditorLoader.Companion.performWhenLoaded(((TextEditor)fileEditor).getEditor(), updateRunnable); } VirtualFile virtualFile = getVirtualFile(fileEditor); PsiFile psiFile = virtualFile == null ? null : findFileToHighlight(dca.myProject, virtualFile); submitted |= psiFile != null && dca.queuePassesCreation(fileEditor, virtualFile, psiFile, ArrayUtil.EMPTY_INT_ARRAY) != null; if (PassExecutorService.LOG.isDebugEnabled()) { PassExecutorService.log(null, null, "submitting psiFile:", psiFile+"; submitted=", submitted); } } 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); } } catch (ProcessCanceledException ignored) { } }