HighlightingSession (@NotNull FileEditor fileEditor, @NotNull VirtualFile virtualFile, @NotNull PsiFile psiFile, int @NotNull [] passesToIgnore) { ThreadingAssertions.assertEventDispatchThread(); BackgroundEditorHighlighter highlighter; try (AccessToken ignored = ClientId.withClientId(ClientFileEditorManager.getClientId(fileEditor))) { highlighter = fileEditor.getBackgroundHighlighter(); } Editor editor = fileEditor instanceof TextEditor textEditor ? textEditor.getEditor() : null; if (highlighter == null) { if (PassExecutorService.LOG.isDebugEnabled()) { PassExecutorService.log(null, null, "couldn't highlight", virtualFile, "because getBackgroundHighlighter() returned null. fileEditor=", fileEditor,fileEditor.getClass(),(editor == null ? "editor is null" : "editor loaded:"+ AsyncEditorLoader.Companion.isEditorLoaded(editor))); } return null; } DaemonProgressIndicator progress = createUpdateProgress(fileEditor); // pre-create HighlightingSession in EDT to make visible range available in a background thread if (editor != null && editor.getDocument().isInBulkUpdate()) { // avoid restarts until the bulk mode is finished and daemon restarted in DaemonListeners stopProcess(false, editor.getDocument() +" is in bulk state"); throw new ProcessCanceledException(); } Document document = editor == null ? FileDocumentManager.getInstance().getCachedDocument(virtualFile) : editor.getDocument(); if (document == null) { if (PassExecutorService.LOG.isDebugEnabled()) { PassExecutorService.log(progress, null, "couldn't submit", virtualFile, "because document is null: fileEditor=",fileEditor,fileEditor.getClass()); } return null; } EditorColorsScheme scheme = editor == null ? null : editor.getColorsScheme(); HighlightingSessionImpl session; try (AccessToken ignored = ClientId.withClientId(ClientFileEditorManager.getClientId(fileEditor))) { session = HighlightingSessionImpl.createHighlightingSession(psiFile, editor, scheme, progress, daemonCancelEventCount); } JobLauncher.getInstance().submitToJobThread(Context.current().wrap(() -> submitInBackground(fileEditor, document, virtualFile, psiFile, highlighter, passesToIgnore, progress, session)), // manifest exceptions in EDT to avoid storing them in the Future and abandoning task -> ApplicationManager.getApplication().invokeLater(() -> ConcurrencyUtil.manifestExceptionsIn(task))); return session; }