void (PsiElement context, PsiNameIdentifierOwner element, PsiReference... references) { context = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement( context); final Project project = context.getProject(); final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); final Editor editor = fileEditorManager.getSelectedTextEditor(); if (editor == null) { return; } final TemplateBuilderImpl builder = new TemplateBuilderImpl(context); final Expression macroCallNode = new MacroCallNode( new SuggestVariableNameMacro()); final PsiElement identifier = element.getNameIdentifier(); builder.replaceElement(identifier, "PATTERN", macroCallNode, true); for (PsiReference reference : references) { builder.replaceElement(reference, "PATTERN", "PATTERN", false); } final Template template = builder.buildInlineTemplate(); final TextRange textRange = context.getTextRange(); final int startOffset = textRange.getStartOffset(); editor.getCaretModel().moveToOffset(startOffset); final TemplateManager templateManager = TemplateManager.getInstance(project); templateManager.startTemplate(editor, template); }