void () { @Language("JAVA") String text = """ class X /* */ { int foo(Object param) {//XXX return 0; }/* */ } """; configureByText(JavaFileType.INSTANCE, text); ((EditorImpl)myEditor).getScrollPane().getViewport().setSize(1000, 1000); @NotNull Editor editor = getEditor(); assertEquals(getFile().getTextRange(), editor.calculateVisibleRange()); toSleepMs.set(1_000_000); MarkupModel markupModel = DocumentMarkupModel.forDocument(getEditor().getDocument(), getProject(), true); TestTimeOut n = TestTimeOut.setTimeout(100, TimeUnit.SECONDS); AtomicInteger called = new AtomicInteger(); Runnable checkHighlighted = () -> { called.incrementAndGet(); UIUtil.dispatchAllInvocationEvents(); long highlighted = Arrays.stream(markupModel.getAllHighlighters()) .map(highlighter -> HighlightInfo.fromRangeHighlighter(highlighter)) .filter(Objects::nonNull) .filter(info -> MyFastAnnotator.SWEARING.equals(info.getDescription())) .count(); if (highlighted != 0) { toSleepMs.set(0); throw new DebugException(); // sorry for that, had to differentiate from failure } if (n.timedOut()) { toSleepMs.set(0); throw new RuntimeException(new TimeoutException(ThreadDumper.dumpThreadsToString())); } }; try { CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject()); TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(getEditor()); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); long start = System.currentTimeMillis(); myDaemonCodeAnalyzer.runPasses(getFile(), getEditor().getDocument(), textEditor, ArrayUtilRt.EMPTY_INT_ARRAY, false, checkHighlighted); List<RangeHighlighter> errors = ContainerUtil.filter(markupModel.getAllHighlighters(), highlighter -> HighlightInfo.fromRangeHighlighter(highlighter) != null && HighlightInfo.fromRangeHighlighter(highlighter).getSeverity() == HighlightSeverity.ERROR); long elapsed = System.currentTimeMillis() - start; fail("should have been interrupted. toSleepMs: " + toSleepMs + "; highlights: " + errors + "; called: " + called+"; highlighted in "+elapsed+"ms"); } catch (DebugException ignored) { } }