LinkedHashSet<String> (List<ExpressionToConstantComparison> comparisons) { PsiExpression stringExpression = comparisons.get(0).myExpression; Project project = stringExpression.getProject(); JavaCodeStyleManager manager = JavaCodeStyleManager.getInstance(project); SuggestedNameInfo info = manager.suggestVariableName(VariableKind.STATIC_FINAL_FIELD, null, stringExpression, comparisons.get(0).myType, false); // Suggestions like OBJECT and AN_OBJECT appear because Object.equals argument type is an Object, // such names are rarely appropriate LinkedHashSet<String> suggestions = StreamEx.of(info.names).without("OBJECT", "AN_OBJECT").map(StringUtil::pluralize).nonNull().toCollection(LinkedHashSet::new); Pair<String, String> prefixSuffix = comparisons.stream().map(cmp -> cmp.myConstantRepresentation).collect( MoreCollectors.pairing(MoreCollectors.commonPrefix(), MoreCollectors.commonSuffix(), Pair::create)); StreamEx.of(prefixSuffix.first, prefixSuffix.second).flatMap(str -> StreamEx.split(str, "\\W+").limit(3)) .map(str -> str.replaceFirst("^_+", "").replaceFirst("_+$", "")) .filter(str -> str.length() >= 3 && StringUtil.isJavaIdentifier(str)) .flatMap(str -> StreamEx.of(manager.suggestVariableName(VariableKind.STATIC_FINAL_FIELD, str, null, null).names)) .limit(5) .map(StringUtil::pluralize) .forEach(suggestions::add); if(comparisons.get(0).myType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) { suggestions.add("STRINGS"); } return suggestions; }