String (Project project, PsiVariable variable) { // new name should not conflict with another variable at the variable declaration level and usage level String name = variable.getName(); // trim last digit to suggest variable names like i1,i2, i3... if (name.length() > 1 && Character.isDigit(name.charAt(name.length()-1))) { name = name.substring(0,name.length()-1); } name = "final" + StringUtil.capitalize(StringUtil.trimStart(name, "final")); return JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName(name, variable, true); }