String (@NotNull String startName, @Nullable GrMethod method, @NotNull PsiElement call, String... otherNames) { String newName; int i = 1; PsiElement parent = call.getParent(); while (!(parent instanceof GrVariableDeclarationOwner) && parent != null) { parent = parent.getParent(); } if (parent == null || isValidName(startName, parent, call) && isValid(startName, otherNames)) { return startName; } do { newName = startName + i; i++; } while (!((method == null || isValidNameInMethod(newName, method)) && isValidName(newName, parent, call) && isValid(newName, otherNames))); return newName; }