SuggestedNameInfo (@NotNull final VariableKind kind, @Nullable final String propertyName, @Nullable final PsiExpression expr, @Nullable PsiType type, final boolean correctKeywords) { if (expr != null && type == null) { type = expr.getType(); } Set<String> names = new LinkedHashSet<>(); if (propertyName != null) { String[] namesByName = ArrayUtilRt.toStringArray(getSuggestionsByName(propertyName, kind, correctKeywords)); sortVariableNameSuggestions(namesByName, kind, propertyName, null); ContainerUtil.addAll(names, namesByName); } final NamesByExprInfo namesByExpr; if (expr != null) { namesByExpr = suggestVariableNameByExpression(expr, kind); String[] suggestions = ArrayUtilRt.toStringArray(getSuggestionsByNames(namesByExpr.names, kind, correctKeywords)); if (namesByExpr.propertyName != null) { sortVariableNameSuggestions(suggestions, kind, namesByExpr.propertyName, null); } ContainerUtil.addAll(names, suggestions); } else { namesByExpr = null; } if (type != null) { String[] namesByType = suggestVariableNameByType(type, kind, correctKeywords); sortVariableNameSuggestions(namesByType, kind, null, type); ContainerUtil.addAll(names, namesByType); } final String _propertyName; if (propertyName != null) { _propertyName = propertyName; } else { _propertyName = namesByExpr != null ? namesByExpr.propertyName : null; } filterOutBadNames(names); addNamesFromStatistics(names, kind, _propertyName, type); String[] namesArray = ArrayUtilRt.toStringArray(names); sortVariableNameSuggestions(namesArray, kind, _propertyName, type); final String _type = type == null ? null : type.getCanonicalText(); return new SuggestedNameInfo(namesArray) { @Override public void nameChosen(String name) { if (_propertyName != null || _type != null) { JavaStatisticsManager.incVariableNameUseCount(name, kind, _propertyName, _type); } } }; }