void (Set<LookupElement> set, PrefixMatcher matcher, @NotNull PsiVariable var, boolean includeOverlapped) { FeatureUsageTracker.getInstance().triggerFeatureUsed("editing.completion.variable.name"); Project project = var.getProject(); JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project); VariableKind variableKind = codeStyleManager.getVariableKind(var); String propertyName = null; if (variableKind == VariableKind.PARAMETER) { PsiMethod method = PsiTreeUtil.getParentOfType(var, PsiMethod.class); if (method != null) { propertyName = PropertyUtilBase.getPropertyName(method); } if (method != null && method.getName().startsWith("with")) { propertyName = StringUtil.decapitalize(method.getName().substring(4)); } } PsiType type = var.getType(); if (type instanceof PsiClassType && ((PsiClassType)type).resolve() == null && seemsMistypedKeyword(((PsiClassType)type).getClassName())) { return; } SuggestedNameInfo suggestedNameInfo = codeStyleManager.suggestVariableName(variableKind, propertyName, null, type, StringUtil.isEmpty(matcher.getPrefix())); suggestedNameInfo = codeStyleManager.suggestUniqueVariableName(suggestedNameInfo, var, false); String[] suggestedNames = suggestedNameInfo.names; addLookupItems(set, suggestedNameInfo, matcher, project, suggestedNames); if (!hasStartMatches(set, matcher)) { if (type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) && matcher.prefixMatches("object")) { set.add(withInsertHandler(suggestedNameInfo, LookupElementBuilder.create("object"))); } if (type.equalsToText(CommonClassNames.JAVA_LANG_STRING) && matcher.prefixMatches("string")) { set.add(withInsertHandler(suggestedNameInfo, LookupElementBuilder.create("string"))); } } if (!hasStartMatches(set, matcher) && includeOverlapped) { addLookupItems(set, null, matcher, project, getOverlappedNameVersions(matcher.getPrefix(), suggestedNames, "")); } PsiElement parent = PsiTreeUtil.getParentOfType(var, PsiCodeBlock.class); if(parent == null) parent = PsiTreeUtil.getParentOfType(var, PsiMethod.class, PsiLambdaExpression.class); addLookupItems(set, suggestedNameInfo, matcher, project, getUnresolvedReferences(parent, false, matcher)); if (var instanceof PsiParameter && parent instanceof PsiMethod) { addSuggestionsInspiredByFieldNames(set, matcher, var, project, codeStyleManager); PsiDocComment docComment = ((PsiMethod)parent).getDocComment(); if (docComment != null) { addLookupItems(set, null, matcher, project, ArrayUtil.toStringArray(getUnresolvedMethodParamNamesFromJavadoc(docComment))); } } PsiExpression initializer = var.getInitializer(); if (initializer != null) { SuggestedNameInfo initializerSuggestions = CommonJavaRefactoringUtil.getSuggestedName(type, initializer); addLookupItems(set, initializerSuggestions, matcher, project, initializerSuggestions.names); } }