* 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)
| 487 | * `EventData` inside the core BiDi CDDL, so a second pass is required. |
| 488 | */ |
| 489 | function collectAllMembers(defMap, rootSuffix) { |
| 490 | const members = new Set() |
| 491 | |
| 492 | // Primary traversal from the core BiDi root. |
| 493 | const rootName = rootSuffix === 'Command' ? 'CommandData' : 'EventData' |
| 494 | for (const m of collectUnionMembers(rootName, defMap)) members.add(m) |
| 495 | |
| 496 | // Secondary traversal: pick up any XxxCommand / XxxEvent unions in |
| 497 | // extension specs whose members were not already found above. |
| 498 | for (const [name, def] of defMap) { |
| 499 | if (!name.endsWith(rootSuffix) || name === rootName) continue |
| 500 | if (def.Type !== 'variable' && def.Type !== 'group') continue |
| 501 | for (const m of collectUnionMembers(name, defMap)) members.add(m) |
| 502 | } |
| 503 | |
| 504 | return members |
| 505 | } |
| 506 | |
| 507 | /** Extract all BiDi commands by traversing CommandData and extension XxxCommand unions. */ |
| 508 | function extractCommands(ast) { |
no test coverage detected