void (@NotNull IntentionPopup popup, @NotNull ListPopupStep<IntentionActionWithTextCaching> step) { if (popup.myListPopup != null) { Disposer.dispose(popup.myListPopup); } if (popup.myDisposed || popup.myEditor.isDisposed()) { popup.myListPopup = null; return; } popup.myListPopup = JBPopupFactory.getInstance().createListPopup(step); if (popup.myListPopup instanceof WizardPopup wizardPopup) { Shortcut[] shortcuts = KeymapUtil.getActiveKeymapShortcuts(IdeActions.ACTION_SHOW_INTENTION_ACTIONS).getShortcuts(); for (Shortcut shortcut : shortcuts) { if (shortcut instanceof KeyboardShortcut keyboardShortcut && keyboardShortcut.getSecondKeyStroke() == null) { wizardPopup.registerAction( "activateSelectedElement", keyboardShortcut.getFirstKeyStroke(), createAction(e -> popup.myListPopup.handleSelect(true)) ); } } popup.registerIntentionShortcuts(); popup.registerShowPreviewAction(); } HighlightingContext context = new HighlightingContext(popup); ListPopupImpl list = ObjectUtils.tryCast(popup.myListPopup, ListPopupImpl.class); ListSelectionListener selectionListener = e -> { Object source = e.getSource(); if (source instanceof DataProvider dataProvider) { Object selectedItem = PlatformCoreDataKeys.SELECTED_ITEM.getData(dataProvider); if (selectedItem instanceof IntentionActionWithTextCaching actionWithCaching) { IntentionAction action = IntentionActionDelegate.unwrap(actionWithCaching.getAction()); if (list != null) { popup.updatePreviewPopup(actionWithCaching, list.getOriginalSelectedIndex()); } highlightOnHover(actionWithCaching, context, popup); return; } } context.dropHighlight(); }; ListPopup listPopup = popup.myListPopup; if (listPopup instanceof ListPopupImpl listPopupImpl) { listPopupImpl.getList().addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { if (EditorSettingsExternalizable.getInstance().isShowIntentionPreview()) { popup.showPreview(); } } @Override public void focusLost(FocusEvent e) { if (EditorSettingsExternalizable.getInstance().isShowIntentionPreview()) { popup.myPreviewPopupUpdateProcessor.hide(); } } }); } popup.myListPopup.addListSelectionListener(selectionListener); popup.myListPopup.addListener(new JBPopupListener() { @Override public void beforeShown(@NotNull LightweightWindowEvent event) { Object selectedValue = list == null ? null : list.getList().getSelectedValue(); if (selectedValue instanceof IntentionActionWithTextCaching actionWithTextCaching) { highlightOnHover(actionWithTextCaching, context, popup); } } @Override public void onClosed(@NotNull LightweightWindowEvent event) { context.dropHighlight(); popup.myPreviewPopupUpdateProcessor.hide(); popup.myPopupShown = false; } }); if (popup.myEditor.isOneLineMode()) { // hide popup on combobox popup show JComboBox<?> comboBox = findAncestorCombo(popup.myEditor); if (comboBox != null) { popup.myOuterComboboxPopupListener = new PopupMenuListenerAdapter() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { popup.myHint.hide(); } }; comboBox.addPopupMenuListener(popup.myOuterComboboxPopupListener); } } Disposer.register(popup, popup.myListPopup); Disposer.register(popup.myListPopup, ThreadingAssertions::assertEventDispatchThread); }