void () { AtomicBoolean xxxMustBeVisible = new AtomicBoolean(); HighlightVisitor visitor = new MyHighlightCommentsSubstringVisitor(xxxMustBeVisible); myProject.getExtensionArea().getExtensionPoint(HighlightVisitor.EP_HIGHLIGHT_VISITOR).registerExtension(visitor, getTestRootDisposable()); @Language("JAVA") String text = """ class X { void f(boolean b) { if (b) { // xxx } } } """; configureByText(JavaFileType.INSTANCE, text); TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(getEditor()); Runnable callbackWhileWaiting = () -> { if (xxxMustBeVisible.get()) { List<String> myInfos = ContainerUtil.map(filterMy(DaemonCodeAnalyzerImpl.getHighlights(getEditor().getDocument(), HighlightSeverity.WARNING, getProject())), h->h.getDescription()); assertTrue(myInfos.toString(), myInfos.contains("MY: XXX")); } }; myDaemonCodeAnalyzer.runPasses(getFile(), getEditor().getDocument(), textEditor, ArrayUtilRt.EMPTY_INT_ARRAY, false, callbackWhileWaiting); List<HighlightInfo> myWarns = filterMy(doHighlighting()); assertEquals(myWarns.toString(), 2, myWarns.size()); }