void () { List<String> log = Collections.synchronizedList(new ArrayList<>()); myProject.getMessageBus().connect(getTestRootDisposable()) .subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListener() { @Override public void daemonFinished(@NotNull Collection<? extends FileEditor> fileEditors) { log.add("F"); } @Override public void daemonStarting(@NotNull Collection<? extends FileEditor> fileEditors) { log.add("S"); } @Override public void daemonCancelEventOccurred(@NotNull String reason) { log.add("C"); } }); @Language("JAVA") String text = """ class X { // comment1 // comment2 }"""; configureByText(JavaFileType.INSTANCE, text); assertEmpty(highlightErrors()); log.clear(); INTERRUPT.set(true); HighlightVisitor visitor = new MyInterruptingVisitor(); myProject.getExtensionArea().getExtensionPoint(HighlightVisitor.EP_HIGHLIGHT_VISITOR).registerExtension(visitor, getTestRootDisposable()); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject()); myDaemonCodeAnalyzer.restart(); myDaemonCodeAnalyzer.setUpdateByTimerEnabled(false); try { myDaemonCodeAnalyzer.runPasses(getFile(), getEditor().getDocument(), TextEditorProvider.getInstance().getTextEditor(getEditor()), ArrayUtilRt.EMPTY_INT_ARRAY, true, () -> {}); } catch (ProcessCanceledException ignored) { } List<HighlightInfo> infos = DaemonCodeAnalyzerImpl.getHighlights(getEditor().getDocument(), HighlightSeverity.WARNING, getProject()); MyInterruptingVisitor.assertHighlighted(infos); assertEquals("[S, C]", log.toString()); INTERRUPT.set(false); log.clear(); try { myDaemonCodeAnalyzer.runPasses(getFile(), getEditor().getDocument(), TextEditorProvider.getInstance().getTextEditor(getEditor()), ArrayUtilRt.EMPTY_INT_ARRAY, true, () -> { }); } catch (ProcessCanceledException ignored) { } finally { myDaemonCodeAnalyzer.setUpdateByTimerEnabled(true); } infos = DaemonCodeAnalyzerImpl.getHighlights(getEditor().getDocument(), HighlightSeverity.WARNING, getProject()); MyInterruptingVisitor.assertHighlighted(infos); assertEquals("[S, F]", log.toString()); }