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

Function emitMethodArg

src/extraction/languages/r.ts:84–98  ·  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

82
83/** Emit one `name = function(…)` argument entry as a method in the current scope. */
84function 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:

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