( expr: CELExpr, negative: boolean = false )
| 219 | }; |
| 220 | |
| 221 | const resolveCollectionExpr = ( |
| 222 | expr: CELExpr, |
| 223 | negative: boolean = false |
| 224 | ): CollectionExpr => { |
| 225 | const callExpr = |
| 226 | expr.exprKind?.case === "callExpr" ? expr.exprKind.value : null; |
| 227 | if (!callExpr) |
| 228 | throw new Error(`Expected callExpr but got ${expr.exprKind?.case}`); |
| 229 | let operator = callExpr.function as CollectionOperator; |
| 230 | if (negative && operator === "@in") { |
| 231 | operator = "@not_in"; |
| 232 | } |
| 233 | const [factorExpr, valuesExpr] = callExpr.args; |
| 234 | const factor = getFactorName(factorExpr); |
| 235 | |
| 236 | if (isNumberFactor(factor)) { |
| 237 | return { |
| 238 | type: ExprType.Condition, |
| 239 | operator, |
| 240 | args: [ |
| 241 | factor, |
| 242 | valuesExpr.exprKind?.case === "listExpr" |
| 243 | ? (valuesExpr.exprKind.value.elements?.map(getConstantInt64Value) ?? |
| 244 | []) |
| 245 | : [], |
| 246 | ], |
| 247 | }; |
| 248 | } |
| 249 | if (isStringFactor(factor)) { |
| 250 | return { |
| 251 | type: ExprType.Condition, |
| 252 | operator, |
| 253 | args: [ |
| 254 | factor, |
| 255 | valuesExpr.exprKind?.case === "listExpr" |
| 256 | ? (valuesExpr.exprKind.value.elements?.map(getConstantStringValue) ?? |
| 257 | []) |
| 258 | : [], |
| 259 | ], |
| 260 | }; |
| 261 | } |
| 262 | throw new Error(`cannot resolve expr ${JSON.stringify(expr)}`); |
| 263 | }; |
| 264 | |
| 265 | const resolveRawStringExpr = (expr: CELExpr): RawStringExpr => { |
| 266 | return { |
no test coverage detected