SuggestedNameInfo (@NotNull final SuggestedNameInfo baseNameInfo, PsiElement place, boolean ignorePlaceName, boolean lookForward) { final String[] names = baseNameInfo.names; final LinkedHashSet<String> uniqueNames = new LinkedHashSet<>(names.length); for (String name : names) { if (ignorePlaceName && place instanceof PsiNamedElement) { final String placeName = ((PsiNamedElement)place).getName(); if (Comparing.strEqual(placeName, name)) { uniqueNames.add(name); continue; } } String unique = suggestUniqueVariableName(name, place, lookForward); if (!unique.equals(name)) { String withShadowing = suggestUniqueVariableName(name, place, lookForward, place instanceof PsiParameter, v -> false); if (withShadowing.equals(name)) { uniqueNames.add(name); } } uniqueNames.add(unique); } return new SuggestedNameInfo(ArrayUtilRt.toStringArray(uniqueNames)) { @Override public void nameChosen(String name) { baseNameInfo.nameChosen(name); } }; }