void (ChainVariable var, Project project, PsiExpression expression) { SuggestedNameInfo info = JavaCodeStyleManager.getInstance(project) .suggestVariableName(VariableKind.LOCAL_VARIABLE, null, expression, null, true); List<String> names = new ArrayList<>(Arrays.asList(info.names)); if (expression.getType() != null && !EquivalenceChecker.getCanonicalPsiEquivalence().typesAreEquivalent(var.getType(), expression.getType())) { // If variable type and expression type is different, do not suggest candidates based on expression type SuggestedNameInfo byType = JavaCodeStyleManager.getInstance(project) .suggestVariableName(VariableKind.LOCAL_VARIABLE, null, null, expression.getType(), true); names.removeAll(Arrays.asList(byType.names)); } names.forEach(var::addOtherNameCandidate); }