void () { String text = "class S { ArrayList<caret>XXX x;}"; configureByText(JavaFileType.INSTANCE, text); ((EditorImpl)myEditor).getScrollPane().getViewport().setSize(1000, 1000); DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true); UIUtil.markAsFocused(getEditor().getContentComponent(), true); // to make ShowIntentionPass call its collectInformation() Set<LightweightHint> shown = new ReferenceOpenHashSet<>(); getProject().getMessageBus().connect().subscribe(EditorHintListener.TOPIC, new EditorHintListener() { @Override public void hintShown(@NotNull Editor editor, @NotNull LightweightHint hint, int flags, @NotNull HintHint hintInfo) { shown.add(hint); hint.addHintListener(event -> shown.remove(hint)); } }); assertNotEmpty(highlightErrors()); IntentionHintComponent hintComponent = myDaemonCodeAnalyzer.getLastIntentionHint(); assertNotNull(hintComponent); assertFalse(hintComponent.isDisposed()); assertNotNull(hintComponent.getComponentHint()); assertTrue(shown.contains(hintComponent.getComponentHint())); assertTrue(hintComponent.hasVisibleLightBulbOrPopup()); CommandProcessor.getInstance().executeCommand(getProject(), () -> EditorTestUtil.executeAction(getEditor(), IdeActions.ACTION_EDITOR_ESCAPE, true), "", null, getEditor().getDocument()); assertNotEmpty(highlightErrors()); hintComponent = myDaemonCodeAnalyzer.getLastIntentionHint(); assertNull(hintComponent); // the bulb must reappear when the caret moved caretLeft(); assertNotEmpty(highlightErrors()); IntentionHintComponent hintComponentAfter = myDaemonCodeAnalyzer.getLastIntentionHint(); assertNotNull(hintComponentAfter); assertFalse(hintComponentAfter.isDisposed()); assertNotNull(hintComponentAfter.getComponentHint()); assertTrue(shown.contains(hintComponentAfter.getComponentHint())); assertTrue(hintComponentAfter.hasVisibleLightBulbOrPopup()); }