void () { @Language("JAVA") String text = """ class LQF { int f; public void me() { // } void foo//<caret> (){}}"""; configureByText(JavaFileType.INSTANCE, text); makeWholeEditorWindowVisible((EditorImpl)myEditor); // get "visible area first" optimization out of the way UIUtil.markAsFocused(getEditor().getContentComponent(), true); // to make ShowIntentionPass call its collectInformation() SeverityRegistrar.getSeverityRegistrar(getProject()); //preload inspection profile AtomicReference<String> diagnosticText = new AtomicReference<>("1st run"); AtomicInteger stallMs = new AtomicInteger(); LocalInspectionTool tool = new MyFegnaInspection() { @NotNull @Override public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitField(@NotNull PsiField field) { holder.registerProblem(field.getNameIdentifier(), diagnosticText.get()); super.visitField(field); } @Override public void visitElement(@NotNull PsiElement element) { // stall every other element to exacerbate latency problems if the order is wrong TimeoutUtil.sleep(stallMs.get()); } }; } }; disposeOnTearDown(() -> disableInspectionTool(tool.getShortName())); for (Tools tools : ProjectInspectionProfileManager.getInstance(getProject()).getCurrentProfile().getAllEnabledInspectionTools(getProject())) { disableInspectionTool(tools.getTool().getShortName()); } enableInspectionTool(tool); List<HighlightInfo> infos = doHighlighting(HighlightSeverity.WARNING); HighlightInfo i = assertOneElement(infos); assertEquals(diagnosticText.get(), i.getDescription()); diagnosticText.set("Aha, field, finally!"); stallMs.set(10000); backspace(); backspace(); type("blah"); makeWholeEditorWindowVisible((EditorImpl)myEditor); // get "visible area first" optimization out of the way // now when the LIP restarted, we should get back our inspection result very fast, despite very slow processing of every other element long deadline = System.currentTimeMillis() + 10_000; while (!daemonIsWorkingOrPending()) { PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue(); if (System.currentTimeMillis() > deadline) { fail("Too long waiting for daemon to start"); } } PsiField field = ((PsiJavaFile)getFile()).getClasses()[0].getFields()[0]; TextRange range = field.getNameIdentifier().getTextRange(); MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(getEditor().getDocument(), getProject(), true); while (daemonIsWorkingOrPending()) { if (System.currentTimeMillis() > deadline) { DaemonRespondToChangesPerformanceTest.dumpThreadsToConsole(); fail("Too long waiting for daemon to finish"); } PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue(); boolean found = !DaemonCodeAnalyzerEx.processHighlights(model, getProject(), HighlightSeverity.WARNING, range.getStartOffset(), range.getEndOffset(), info -> !diagnosticText.get().equals(info.getDescription())); if (found) { break; } } }