@Override
    public void itemSelected(@NotNull final LookupEvent event) {
      FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.liveTemplates");
      final LookupElement item = event.getItem();
      final Lookup lookup = event.getLookup();
      final Project project = lookup.getProject();
      if (item instanceof LiveTemplateLookupElementImpl) {
        final TemplateImpl template = ((LiveTemplateLookupElementImpl)item).getTemplate();
        final String argument = myTemplate2Argument != null ? myTemplate2Argument.get(template) : null;
        WriteCommandAction.writeCommandAction(project).run(() -> {
          Editor editor = lookup.getEditor();
          if (!editor.isDisposed()) {
            editor.getCaretModel().runForEachCaret(caret -> {
              ((TemplateManagerImpl)TemplateManager.getInstance(project))
                .startTemplateWithPrefix(caret.getEditor(), template, null, argument);
            });
          }
        });
      }
      else if (item instanceof CustomLiveTemplateLookupElement) {
        if (myFile != null) {
          WriteCommandAction.writeCommandAction(project).run(() -> {
            Editor editor = lookup.getEditor();
            if (!editor.isDisposed()) {
              editor.getCaretModel().runForEachCaret(caret -> {
                ((CustomLiveTemplateLookupElement)item).expandTemplate(lookup.getEditor(), myFile);
              });
            }
          });
        }
      }
    }
@Override
    public void itemSelected(@NotNull final LookupEvent event)