Extract all BiDi commands by traversing CommandData and extension XxxCommand unions.
(ast)
| 561 | |
| 562 | /** Extract all BiDi commands by traversing CommandData and extension XxxCommand unions. */ |
| 563 | function extractCommands(ast) { |
| 564 | const defMap = buildDefMap(ast) |
| 565 | const emptyParamTypes = buildEmptyParamTypes(ast) |
| 566 | const commandNames = collectAllMembers(defMap, 'Command') |
| 567 | const commands = [] |
| 568 | |
| 569 | for (const name of commandNames) { |
| 570 | const def = defMap.get(name) |
| 571 | if (!def) continue |
| 572 | |
| 573 | const parsed = parseLeafDef(def) |
| 574 | if (!parsed) continue |
| 575 | |
| 576 | const { domain, methodStr, operationName: methodName, paramsCddl } = parsed |
| 577 | // emptyParamTypes holds raw CDDL group names, so compare the raw name (not the normalized one). |
| 578 | const hasParams = paramsCddl !== null && !emptyParamTypes.has(paramsCddl) |
| 579 | |
| 580 | commands.push({ |
| 581 | domain, |
| 582 | cddlName: name, |
| 583 | methodStr, |
| 584 | methodName, |
| 585 | paramsCddl, |
| 586 | hasParams, |
| 587 | }) |
| 588 | } |
| 589 | |
| 590 | return commands |
| 591 | } |
| 592 | |
| 593 | /** Extract all BiDi events by traversing EventData and extension XxxEvent unions. */ |
| 594 | function extractEvents(ast) { |
no test coverage detected