Template (PsiMethod method, int caretOffset, PsiExpressionList argList, TextRange argRange) { Template template = TemplateManager.getInstance(method.getProject()).createTemplate("", ""); PsiParameter[] parameters = method.getParameterList().getParameters(); for (int i = 0; i < parameters.length; i++) { if (i > 0) { template.addTextSegment(", "); } String name = parameters[i].getName(); Expression expression = Registry.is("java.completion.argument.live.template.completion") ? new AutoPopupCompletion() : new ConstantNode(name); template.addVariable(name, expression, new ConstantNode(name), true); } boolean finishInsideParens = method.isVarArgs(); if (finishInsideParens) { template.addEndVariable(); } template.addTextSegment(argList.getText().substring(caretOffset - argRange.getStartOffset(), argList.getTextLength())); if (!finishInsideParens) { template.addEndVariable(); } return template; }