NamesByExprInfo (@NotNull PsiExpression expr, @Nullable VariableKind variableKind) { if (expr.getParent() instanceof PsiExpressionList list) { PsiElement listParent = list.getParent(); PsiSubstitutor subst = PsiSubstitutor.EMPTY; PsiMethod method = null; if (listParent instanceof PsiMethodCallExpression call) { final JavaResolveResult resolveResult = call.getMethodExpression().advancedResolve(false); method = (PsiMethod)resolveResult.getElement(); subst = resolveResult.getSubstitutor(); } else { if (listParent instanceof PsiAnonymousClass) { listParent = listParent.getParent(); } if (listParent instanceof PsiNewExpression newExpression) { method = newExpression.resolveConstructor(); } } if (method != null) { PsiParameter parameter = MethodCallUtils.getParameterForArgument(expr); if (parameter != null) { String name = parameter.getName(); if (TypeConversionUtil.areTypesAssignmentCompatible(subst.substitute(parameter.getType()), expr)) { name = variableNameToPropertyName(name, VariableKind.PARAMETER); if (list.getExpressionCount() == 1) { final String methodName = method.getName(); String[] words = NameUtilCore.nameToWords(methodName); if (words.length > 0) { final String firstWord = words[0]; if (SET_PREFIX.equals(firstWord)) { final String propertyName = methodName.substring(firstWord.length()); return new NamesByExprInfo(name, propertyName); } } } return new NamesByExprInfo(name); } } } } else if (expr.getParent() instanceof PsiAssignmentExpression assignmentExpression) { if (expr == assignmentExpression.getRExpression()) { final PsiExpression leftExpression = assignmentExpression.getLExpression(); if (leftExpression instanceof PsiReferenceExpression ref) { String name = getPropertyName(ref); if (name != null) { return new NamesByExprInfo(name); } } } } //skip places where name for this local variable is calculated, otherwise grab the name else if (expr.getParent() instanceof PsiLocalVariable variable && variableKind != VariableKind.LOCAL_VARIABLE) { String variableName = variable.getName(); String propertyName = variableNameToPropertyName(variableName, getVariableKind(variable)); return new NamesByExprInfo(propertyName); } return NamesByExprInfo.EMPTY; }