void (@NotNull Editor hostEditor, int offsetBefore, @NotNull PsiFile newFile, @NotNull Editor newEditor) { ReadAction.nonBlocking(() -> { int textLength = newFile.getTextLength(); if (textLength == -1 | hostEditor.isDisposed()) { // sometimes some crazy stuff is returned (EA-248725) return null; } ProperTextRange visibleRange = ProperTextRange.from(0, textLength); IdentifierHighlighterPass pass = new IdentifierHighlighterPassFactory().createHighlightingPass(newFile, newEditor, visibleRange); DaemonProgressIndicator indicator = new DaemonProgressIndicator(); ProgressIndicatorUtils.runWithWriteActionPriority(() -> { PsiFile hostPsiFile = PsiDocumentManager.getInstance(newFile.getProject()).getPsiFile(hostEditor.getDocument()); if (hostPsiFile == null) return; HighlightingSessionImpl.runInsideHighlightingSession(hostPsiFile, hostEditor.getColorsScheme(), ProperTextRange.create(hostPsiFile.getTextRange()), false, session -> { if (pass != null) { pass.doCollectInformation(session); } }); }, indicator); return pass; }) .expireWhen(() -> !BackgroundHighlightingUtil.isValidEditor(hostEditor) || hostEditor.getCaretModel().getOffset() != offsetBefore) .coalesceBy(HighlightIdentifiersKey.class, hostEditor) .finishOnUiThread(ModalityState.stateForComponent(hostEditor.getComponent()), pass -> { if (pass != null) { pass.doAdditionalCodeBlockHighlighting(); } }) .submit(AppExecutorUtil.getAppExecutorService()); }