MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / emitMethodArg

Function emitMethodArg

src/extraction/languages/r.ts:82–96  ·  view source on GitHub ↗

Emit one `name = function(…)` argument entry as a method in the current scope.

(entry: SyntaxNode, ctx: ExtractorContext)

Source from the content-addressed store, hash-verified

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

Callers 1

extractClassMembersFunction · 0.85

Calls 6

getChildByFieldFunction · 0.90
getNodeTextFunction · 0.90
pushScopeMethod · 0.80
popScopeMethod · 0.80
createNodeMethod · 0.65
visitNodeMethod · 0.65

Tested by

no test coverage detected