@Override
  public void actionPerformed(@NotNull AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    Editor editor = Objects.requireNonNull(CommonDataKeys.EDITOR.getData(dataContext));
    PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
    Project project = Objects.requireNonNull(e.getProject());
    String templateText = suggestTemplateText(editor, file, project);
    TemplateImpl template = new TemplateImpl(TemplateListPanel.ABBREVIATION, templateText, TemplateSettings.USER_GROUP_NAME);
    template.setToReformat(true);

    if (file != null) {
      OffsetKey startKey = OffsetKey.create("pivot");
      OffsetsInFile offsets = new OffsetsInFile(file);
      offsets.getOffsets().addOffset(startKey, editor.getSelectionModel().getSelectionStart());
      OffsetsInFile copy = TemplateManagerImpl.copyWithDummyIdentifier(offsets,
                                                                       editor.getSelectionModel().getSelectionStart(),
                                                                       editor.getSelectionModel().getSelectionEnd(),
                                                                       CompletionUtil.DUMMY_IDENTIFIER_TRIMMED);

      Set<TemplateContextType> applicable = TemplateManagerImpl.getApplicableContextTypes(
        TemplateActionContext.expanding(copy.getFile(), copy.getOffsets().getOffset(startKey)));

      for (TemplateContextType contextType : TemplateManagerImpl.getAllContextTypes()) {
        template.getTemplateContext().setEnabled(contextType, applicable.contains(contextType));
      }
    }

    final LiveTemplatesConfigurable configurable = new LiveTemplatesConfigurable();
    SingleConfigurableEditor dialog = new SingleConfigurableEditor(project, configurable, DialogWrapper.IdeModalityType.MODELESS);
    UiNotifyConnector.Once.installOn(dialog.getContentPane(), new Activatable() {
      @Override
      public void showNotify() {
        configurable.getTemplateListPanel().addTemplate(template);
      }
    });
    dialog.setTitle(e.getPresentation().getText());
    dialog.show();
  }
@Override
  public void actionPerformed(@NotNull AnActionEvent e)