* Collect all leaf command/event names from every XxxCommand / XxxEvent * union that can be reached from either the core BiDi root (`CommandData` / * `EventData`) or from extension-spec roots (e.g. `PermissionsCommand`, * `SpeculationEvent`). Extension specs are not wired into `CommandData` / *
(defMap, rootSuffix)
| 510 | * `EventData` inside the core BiDi CDDL, so a second pass is required. |
| 511 | */ |
| 512 | function collectAllMembers(defMap, rootSuffix) { |
| 513 | const members = new Set() |
| 514 | |
| 515 | // Primary traversal from the core BiDi root. |
| 516 | const rootName = rootSuffix === 'Command' ? 'CommandData' : 'EventData' |
| 517 | for (const m of collectUnionMembers(rootName, defMap)) members.add(m) |
| 518 | |
| 519 | // Secondary traversal: pick up any XxxCommand / XxxEvent unions in |
| 520 | // extension specs whose members were not already found above. |
| 521 | for (const [name, def] of defMap) { |
| 522 | if (!name.endsWith(rootSuffix) || name === rootName) continue |
| 523 | if (def.Type !== 'variable' && def.Type !== 'group') continue |
| 524 | for (const m of collectUnionMembers(name, defMap)) members.add(m) |
| 525 | } |
| 526 | |
| 527 | return members |
| 528 | } |
| 529 | |
| 530 | /** Extract all BiDi commands by traversing CommandData and extension XxxCommand unions. */ |
| 531 | function extractCommands(ast) { |
no test coverage detected