private static PsiVariable resolveVariable(PsiExpression expression, @Nullable PsiParameter requiredQualifier) {
      if (!(expression instanceof PsiReferenceExpression referenceExpression)) {
        return null;
      }
      final PsiExpression qualifier = PsiUtil.skipParenthesizedExprDown(referenceExpression.getQualifierExpression());
      final PsiElement target = referenceExpression.resolve();
      if (requiredQualifier == null) {
        if (!(qualifier == null || qualifier instanceof PsiThisExpression)) {
          return null;
        }
      }
      else if (!ExpressionUtils.isReferenceTo(qualifier, requiredQualifier)) {
        return target == requiredQualifier ? requiredQualifier : null;
      }
      return target instanceof PsiVariable ? (PsiVariable)target : null;
    }
private static PsiVariable resolveVariable(PsiExpression expression, @Nullable PsiParameter requiredQualifier)