void (Project project, PsiElement callable, TemplateBuilder builder) { int offset = callable.getTextRange().getStartOffset(); final Editor targetEditor = PythonUiService.getInstance().openTextEditor(project, callable.getContainingFile().getVirtualFile(), offset); if (targetEditor != null) { builder.run(targetEditor, true); } else { builder.runNonInteractively(true); } }