@NotNull
    private static ExtendableTextComponent.Extension createRightActionExtension(@NotNull AnAction action) {
      return new ExtendableTextComponent.Extension() {
        @Override
        public Icon getIcon(boolean hovered) {
          Presentation presentation = action.getTemplatePresentation();
          if (!(action instanceof TextSearchRightActionAction)) return presentation.getIcon();

          if (((TextSearchRightActionAction)action).isSelected()) {
            return presentation.getSelectedIcon();
          }
          else if (hovered) {
            return presentation.getHoveredIcon();
          }
          else {
            return presentation.getIcon();
          }
        }

        @Override
        public String getTooltip() {
          return action instanceof TextSearchRightActionAction
                 ? ((TextSearchRightActionAction)action).getTooltip()
                 : action.getTemplatePresentation().getDescription();
        }

        @Override
        public boolean isSelected() {
          return action instanceof ToggleAction toggleAction && toggleAction.isSelected(createActionEvent());
        }

        @Override
        public Dimension getButtonSize() {
          return ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE;
        }

        @Override
        public Runnable getActionOnClick() {
          return () -> {
            action.actionPerformed(createActionEvent());
          };
        }

        private AnActionEvent createActionEvent() {
          return AnActionEvent.createFromDataContext(ActionPlaces.POPUP, action.getTemplatePresentation().clone(),
                                                     DataContext.EMPTY_CONTEXT);
        }
      };
    }
@NotNull
    private static ExtendableTextComponent.Extension createRightActionExtension(@NotNull AnAction action)