void () { Runnable commentHighlighted = () -> { ApplicationManager.getApplication().assertIsNonDispatchThread(); ApplicationManager.getApplication().assertReadAccessAllowed(); // assert markup is updated as soon as the HighlightInfo is created List<HighlightInfo> highlightsFromMarkup = DaemonCodeAnalyzerImpl.getHighlights(getEditor().getDocument(), HighlightSeverity.WARNING, getProject()); MyHighlightCommentVisitor.assertHighlighted(highlightsFromMarkup); }; HighlightVisitor visitor = new MyHighlightCommentVisitor(commentHighlighted); 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); List<HighlightInfo> infos = doHighlighting(HighlightSeverity.WARNING); MyHighlightCommentVisitor.assertHighlighted(infos); }