PsiExpression (PsiElement element) { PsiClassType classType = getQualifierExpressionType(element); if (classType == null) { return null; } if (InheritanceUtil.isInheritor(classType, CommonClassNames.JAVA_UTIL_STREAM_BASE_STREAM)) { // Disable for stream API return null; } boolean first = true; while (true) { final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)element; final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); final PsiExpression qualifierExpression = PsiUtil.skipParenthesizedExprDown(methodExpression.getQualifierExpression()); PsiClassType expressionType = getQualifierExpressionType(qualifierExpression); if (!first) { if (expressionType == null) { if (qualifierExpression instanceof PsiMethodCallExpression call) { if (call.getMethodExpression().getQualifierExpression() == null) { PsiMethod method = call.resolveMethod(); if (method == null || !method.hasModifierProperty(PsiModifier.STATIC)) { return null; } } } return qualifierExpression; } } else { first = false; } if (!classType.equals(expressionType)) { return null; } element = qualifierExpression; } }