public <T extends DomElement> void runTemplate(final T t, final Editor editor, final @Nullable Template template, Map<String, String> predefinedVars) {
    if (template != null && t != null) {
      DomElement copy = t.createStableCopy();
      PsiDocumentManager.getInstance(myProject).doPostponedOperationsAndUnblockDocument(editor.getDocument());
      XmlTag tag = copy.getXmlTag();
      assert tag != null;
      editor.getCaretModel().moveToOffset(tag.getTextRange().getStartOffset());
      copy.undefine();

      PsiDocumentManager.getInstance(myProject).doPostponedOperationsAndUnblockDocument(editor.getDocument());

      template.setToReformat(true);
      TemplateManager.getInstance(myProject).startTemplate(editor, template, true, predefinedVars, null);
    }
  }
public <T extends DomElement> void runTemplate(final T t, final Editor editor, final @Nullable Template template, Map<String, String> predefinedVars)