The features (named heads/symbols) that must appear somewhere in any * expression the pattern can match with `useVariations: false`.
(pattern: Expression)
| 542 | } |
| 543 | |
| 544 | /** The features (named heads/symbols) that must appear somewhere in any |
| 545 | * expression the pattern can match with `useVariations: false`. */ |
| 546 | function requiredFeatures(pattern: Expression): ReadonlyArray<string> { |
| 547 | const out = new Set<string>(); |
| 548 | const walk = (p: Expression): void => { |
| 549 | const sym = (p as { symbol?: string }).symbol; |
| 550 | if (sym !== undefined) { |
| 551 | if (!sym.startsWith('_')) out.add(FEATURE_SYM_PREFIX + sym); |
| 552 | return; |
| 553 | } |
| 554 | const ops = (p as { ops?: ReadonlyArray<Expression> }).ops; |
| 555 | if (ops === undefined) return; // number/string literal: not required |
| 556 | const op = p.operator; |
| 557 | if (!op.startsWith('_') && !CROSS_HEAD_PATTERN_OPS.has(op)) |
| 558 | out.add(FEATURE_OP_PREFIX + op); |
| 559 | for (const x of ops) walk(x); |
| 560 | }; |
| 561 | walk(pattern); |
| 562 | return [...out]; |
| 563 | } |
| 564 |
no test coverage detected