Extract all BiDi commands by traversing CommandData and extension XxxCommand unions.
(ast)
| 506 | |
| 507 | /** Extract all BiDi commands by traversing CommandData and extension XxxCommand unions. */ |
| 508 | function extractCommands(ast) { |
| 509 | const defMap = buildDefMap(ast) |
| 510 | const emptyParamTypes = buildEmptyParamTypes(ast) |
| 511 | const commandNames = collectAllMembers(defMap, 'Command') |
| 512 | const commands = [] |
| 513 | |
| 514 | for (const name of commandNames) { |
| 515 | const def = defMap.get(name) |
| 516 | if (!def) continue |
| 517 | |
| 518 | const parsed = parseLeafDef(def) |
| 519 | if (!parsed) continue |
| 520 | |
| 521 | const { domain, methodStr, operationName: methodName, paramsCddl, vendor } = parsed |
| 522 | // emptyParamTypes holds raw CDDL group names, so compare the raw name (not the normalized one). |
| 523 | const hasParams = paramsCddl !== null && !emptyParamTypes.has(paramsCddl) |
| 524 | |
| 525 | commands.push({ |
| 526 | domain, |
| 527 | cddlName: name, |
| 528 | methodStr, |
| 529 | methodName, |
| 530 | paramsCddl, |
| 531 | hasParams, |
| 532 | vendor, |
| 533 | }) |
| 534 | } |
| 535 | |
| 536 | return commands |
| 537 | } |
| 538 | |
| 539 | /** Extract all BiDi events by traversing EventData and extension XxxEvent unions. */ |
| 540 | function extractEvents(ast) { |
no test coverage detected