Emit one `name = function(…)` argument entry as a method in the current scope.
(entry: SyntaxNode, ctx: ExtractorContext)
| 82 | |
| 83 | /** Emit one `name = function(…)` argument entry as a method in the current scope. */ |
| 84 | function emitMethodArg(entry: SyntaxNode, ctx: ExtractorContext): void { |
| 85 | const entryName = getChildByField(entry, 'name'); |
| 86 | const entryValue = getChildByField(entry, 'value'); |
| 87 | if (!entryName || entryValue?.type !== 'function_definition') return; |
| 88 | const params = getChildByField(entryValue, 'parameters'); |
| 89 | const method = ctx.createNode('method', getNodeText(entryName, ctx.source), entry, { |
| 90 | signature: params ? getNodeText(params, ctx.source) : undefined, |
| 91 | }); |
| 92 | const body = getChildByField(entryValue, 'body'); |
| 93 | if (method && body) { |
| 94 | ctx.pushScope(method.id); |
| 95 | ctx.visitNode(body); // hook-aware walk — see the function-assignment note below |
| 96 | ctx.popScope(); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Extract a class call's methods. Two shapes: |
no test coverage detected