public static PsiType getTypeByExpression(PsiExpression expr) {
    PsiType type = expr != null ? expr.getType() : null;
    if (type == null) {
      if (expr instanceof PsiArrayInitializerExpression) {
        PsiExpression[] initializers = ((PsiArrayInitializerExpression)expr).getInitializers();
        if (initializers.length > 0) {
          PsiType initType = getTypeByExpression(initializers[0]);
          if (initType == null) return null;
          return initType.createArrayType();
        }
      }

      if (expr instanceof PsiReferenceExpression && PsiUtil.isOnAssignmentLeftHand(expr)) {
        PsiAssignmentExpression assignmentExpression =
          (PsiAssignmentExpression)PsiTreeUtil.skipParentsOfType(expr, PsiParenthesizedExpression.class);
        return getTypeByExpression(Objects.requireNonNull(assignmentExpression).getRExpression());
      }
      return null;
    }

    return GenericsUtil.getVariableTypeByExpressionType(type);
  }
public static PsiType getTypeByExpression(PsiExpression expr)