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

Method dispatchNode

src/extraction/tree-sitter.ts:1631–2116  ·  view source on GitHub ↗
(node: SyntaxNode)

Source from the content-addressed store, hash-verified

1629 }
1630
1631 private dispatchNode(node: SyntaxNode): void {
1632 if (!this.extractor) return;
1633
1634 const nodeType = node.type;
1635 let skipChildren = false;
1636
1637 // Language-specific custom visitor hook
1638 if (this.extractor.visitNode) {
1639 const ctx = this.makeExtractorContext();
1640 const handled = this.extractor.visitNode(node, ctx);
1641 if (handled) {
1642 // The hook consumed this subtree, so the walkers below never descend
1643 // into it — scan it for function-as-value candidates (#756). Scala's
1644 // hook handles val/var definitions (`val table = Seq(targetCb)`), for
1645 // example. The scan is capture-only and halts at nested functions;
1646 // an initializer the hook walked has captured its own.
1647 this.scanFnRefSubtree(node, 0, ctx.walked ?? undefined);
1648 return;
1649 }
1650 }
1651
1652 // Pascal-specific AST handling
1653 if (this.language === 'pascal') {
1654 skipChildren = this.visitPascalNode(node);
1655 if (skipChildren) return;
1656 }
1657
1658 if (this.language === 'cpp' && isCppConstructorDeclaration(node)) {
1659 this.extractMethod(node);
1660 return;
1661 }
1662
1663 // C/C++ function-like macros (`#define TRACE(x) ...`) become `constant`
1664 // nodes carrying the directive as their signature. A macro is a value,
1665 // never an executable callee: the resolver reads these to recognize a
1666 // call whose name is a macro visible in the translation unit and refuses
1667 // to bind it to a same-named function elsewhere (#1838). Mirrored in the
1668 // kernel (ccpp/mod.rs visit_node).
1669 if ((this.language === 'c' || this.language === 'cpp') && nodeType === 'preproc_function_def') {
1670 const name = getChildByField(node, 'name');
1671 if (name) {
1672 this.createNode('constant', getNodeText(name, this.source), node, {
1673 signature: getNodeText(node, this.source).trim(),
1674 });
1675 }
1676 return;
1677 }
1678
1679 // C++ namespace blocks: carry the namespace name as a qualifiedName prefix
1680 // while walking the body, so `namespace flash { void compute_attn(); }`
1681 // indexes compute_attn with qualifiedName `flash::compute_attn` and a
1682 // namespace-qualified call (`flash::compute_attn(...)`) resolves by exact
1683 // qualified match instead of never resolving — C++ namespaces previously
1684 // left no trace in qualifiedNames at all, so every `ns::fn()` call site
1685 // was a permanently dead edge (surfaced by #387 flow validation on
1686 // flash-attention/cutlass, whose kernel dispatch is namespace-qualified).
1687 // C++17 nested forms (`namespace a::b {`) prefix as written. An anonymous
1688 // namespace falls through to the generic walk — its contents stay bare,

Callers 2

visitNodeMethod · 0.95
visitInCppBraceScopeMethod · 0.95

Calls 15

makeExtractorContextMethod · 0.95
scanFnRefSubtreeMethod · 0.95
visitPascalNodeMethod · 0.95
extractMethodMethod · 0.95
createNodeMethod · 0.95
visitNodeMethod · 0.95
maybeCaptureFnRefsMethod · 0.95
isInsideClassLikeNodeMethod · 0.95
extractFunctionMethod · 0.95
isClassTypeNodeMethod · 0.95
extractStructMethod · 0.95

Tested by

no test coverage detected