public static void runTemplateInSelectedEditor(@NotNull Project project, PsiElement anchor, @NotNull TemplateBuilder builder) {
    VirtualFile virtualFile = anchor.getContainingFile().getVirtualFile();
    if (virtualFile == null) return;
    final FileEditor editor = PythonUiService.getInstance().getSelectedEditor(project, virtualFile);
    if (editor instanceof TextEditor) {
      builder.run(((TextEditor)editor).getEditor(), false);
    }
    else {
      builder.runNonInteractively(false);
    }
  }
public static void runTemplateInSelectedEditor(@NotNull Project project, PsiElement anchor, @NotNull TemplateBuilder builder)