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

Method scanFnRefSubtree

src/extraction/tree-sitter.ts:1198–1218  ·  view source on GitHub ↗

* Candidates-only scan of a subtree the main walkers won't traverse * (top-level variable initializers). No extraction side effects. Halts at * nested function definitions: their bodies are walked — and their * candidates attributed — by extractFunction's own body walk.

(node: SyntaxNode, depth: number, walked?: ReadonlySet<number>)

Source from the content-addressed store, hash-verified

1196 * candidates attributed — by extractFunction's own body walk.
1197 */
1198 private scanFnRefSubtree(node: SyntaxNode, depth: number, walked?: ReadonlySet<number>): void {
1199 if (!this.fnRefSpec || depth > 12) return;
1200 // Subtrees the body walker has already been through.
1201 if (walked?.has(node.id)) return;
1202 const nodeType = node.type;
1203 if (depth > 0 && (
1204 this.extractor?.functionTypes.includes(nodeType) ||
1205 ((this.language === 'lua' || this.language === 'luau') && nodeType === 'function_definition') ||
1206 nodeType === 'arrow_function' ||
1207 nodeType === 'function_expression' ||
1208 nodeType === 'lambda_literal' ||
1209 nodeType === 'lambda_expression'
1210 )) {
1211 return;
1212 }
1213 this.maybeCaptureFnRefs(node, nodeType);
1214 for (let i = 0; i < node.namedChildCount; i++) {
1215 const child = node.namedChild(i);
1216 if (child) this.scanFnRefSubtree(child, depth + 1, walked);
1217 }
1218 }
1219
1220 /**
1221 * Gate captured function-as-value candidates and push survivors as

Callers 1

dispatchNodeMethod · 0.95

Calls 2

maybeCaptureFnRefsMethod · 0.95
hasMethod · 0.80

Tested by

no test coverage detected