void (@NotNull PsiElement expr, @NotNull Editor editor) { Project project = expr.getProject(); Document document = editor.getDocument(); PsiElement elementForRemoving = getElementToRemove(expr); document.deleteString(elementForRemoving.getTextRange().getStartOffset(), elementForRemoving.getTextRange().getEndOffset()); TemplateManager manager = TemplateManager.getInstance(project); String templateString = getTemplateString(expr); if (templateString == null) { PostfixTemplatesUtils.showErrorHint(expr.getProject(), editor); return; } Template template = createTemplate(manager, templateString); template.addVariable(EXPR, new TextExpression(expr.getText()), false); setVariables(template, expr); manager.startTemplate(editor, template); }