boolean (@NotNull ActionContext context, ModChooseAction chooser, @Nullable Editor editor) { record ActionAndPresentation(@NotNull ModCommandAction action, @NotNull Presentation presentation) {} List<ActionAndPresentation> actions = StreamEx.of(chooser.actions()).mapToEntry(action -> action.getPresentation(context)) .nonNullValues().mapKeyValue(ActionAndPresentation::new).toList(); if (actions.isEmpty()) return true; String name = chooser.title(); if (actions.size() == 1) { ModCommandAction action = actions.get(0).action(); executeNextStep(context, name, editor, () -> { if (action.getPresentation(context) == null) return null; return action.perform(context); }); return true; } VirtualFile file = context.file().getVirtualFile(); if (file == null) return false; Editor finalEditor = editor == null ? getEditor(context.project(), file) : editor; if (editor == null) return false; List<IntentionActionWithTextCaching> actionsWithTextCaching = ContainerUtil.map( actions, (actionAndPresentation) -> { IntentionAction intention = actionAndPresentation.action().asIntention(); intention.isAvailable(context.project(), finalEditor, context.file()); // cache text and icon return new IntentionActionWithTextCaching(intention); }); IntentionContainer intentions = new IntentionContainer() { @Override public @NotNull String getTitle() { return chooser.title(); } @Override public @NotNull List<IntentionActionWithTextCaching> getAllActions() { return actionsWithTextCaching; } @Override public @NotNull IntentionGroup getGroup(@NotNull IntentionActionWithTextCaching action) { return IntentionGroup.OTHER; } @Override public @Nullable Icon getIcon(@NotNull IntentionActionWithTextCaching action) { return action.getIcon(); } }; IntentionHintComponent.showIntentionHint(context.project(), context.file(), editor, true, intentions); return true; }