code: public static boolean mayBeExpression(Node n) {
      switch (n.getToken()) {
        case FUNCTION:
        case CLASS:
          // FUNCTION and CLASS are used both in expression and statement
          // contexts.
          return true;
  
        case ADD:
        case AND:
        case ARRAYLIT:
        case ASSIGN:
        case ASSIGN_BITOR:
        case ASSIGN_BITXOR:
        case ASSIGN_BITAND:
        case ASSIGN_LSH:
        case ASSIGN_RSH:
        case ASSIGN_URSH:
        case ASSIGN_ADD:
        case ASSIGN_SUB:
        case ASSIGN_MUL:
        case ASSIGN_EXPONENT:
        case ASSIGN_DIV:
        case ASSIGN_MOD:
        case AWAIT:
        case BITAND:
        case BITOR:
        case BITNOT:
        case BITXOR:
        case CALL:
        case CAST:
        case COMMA:
        case DEC:
        case DELPROP:
        case DIV:
        case EQ:
        case EXPONENT:
        case FALSE:
        case GE:
        case GETPROP:
        case GETELEM:
        case GT:
        case HOOK:
        case IN:
        case INC:
        case INSTANCEOF:
        case LE:
        case LSH:
        case LT:
        case MOD:
        case MUL:
        case NAME:
        case NE:
        case NEG:
        case NEW:
        case NEW_TARGET:
        case NOT:
        case NUMBER:
        case NULL:
        case OBJECTLIT:
        case OR:
        case POS:
        case REGEXP:
        case RSH:
        case SHEQ:
        case SHNE:
        case STRING:
        case SUB:
        case SUPER:
        case TEMPLATELIT:
        case TAGGED_TEMPLATELIT:
        case THIS:
        case TYPEOF:
        case TRUE:
        case URSH:
        case VOID:
        case YIELD:
          return true;
  
        default:
          return false;
      }
    }
docs: It isn't possible to always determine if a detached node is a expression,
  so make a best guess.