String (JavaCodeStyleManager codeStyleManager, PsiExpression expression, PsiType exprType, Set<? super String> existingNames) { SuggestedNameInfo nameInfo = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, expression, exprType); @NonNls String[] names = nameInfo.names; if (expression instanceof PsiReferenceExpression) { final PsiElement resolve = ((PsiReferenceExpression)expression).resolve(); if (resolve instanceof PsiVariable) { final VariableKind variableKind = codeStyleManager.getVariableKind((PsiVariable)resolve); final String propertyName = codeStyleManager.variableNameToPropertyName(((PsiVariable)resolve).getName(), variableKind); final String parameterName = codeStyleManager.propertyNameToVariableName(propertyName, VariableKind.PARAMETER); names = ArrayUtil.mergeArrays(new String[]{parameterName}, names); } } if (names.length == 0) names = new String[]{"param"}; int suffix = 0; while (true) { for (String name : names) { String suggested = name + (suffix == 0 ? "" : String.valueOf(suffix)); if (existingNames.add(suggested)) { return suggested; } } suffix++; } }