(node: SyntaxNode)
| 1590 | } |
| 1591 | |
| 1592 | private dispatchNode(node: SyntaxNode): void { |
| 1593 | if (!this.extractor) return; |
| 1594 | |
| 1595 | const nodeType = node.type; |
| 1596 | let skipChildren = false; |
| 1597 | |
| 1598 | // Language-specific custom visitor hook |
| 1599 | if (this.extractor.visitNode) { |
| 1600 | const ctx = this.makeExtractorContext(); |
| 1601 | const handled = this.extractor.visitNode(node, ctx); |
| 1602 | if (handled) { |
| 1603 | // The hook consumed this subtree, so the walkers below never descend |
| 1604 | // into it — scan it for function-as-value candidates (#756). Scala's |
| 1605 | // hook handles val/var definitions (`val table = Seq(targetCb)`), for |
| 1606 | // example. The scan is capture-only and halts at nested functions; |
| 1607 | // an initializer the hook walked has captured its own. |
| 1608 | this.scanFnRefSubtree(node, 0, ctx.walked ?? undefined); |
| 1609 | return; |
| 1610 | } |
| 1611 | } |
| 1612 | |
| 1613 | // Pascal-specific AST handling |
| 1614 | if (this.language === 'pascal') { |
| 1615 | skipChildren = this.visitPascalNode(node); |
| 1616 | if (skipChildren) return; |
| 1617 | } |
| 1618 | |
| 1619 | if (this.language === 'cpp' && isCppConstructorDeclaration(node)) { |
| 1620 | this.extractMethod(node); |
| 1621 | return; |
| 1622 | } |
| 1623 | |
| 1624 | // C/C++ function-like macros (`#define TRACE(x) ...`) become `constant` |
| 1625 | // nodes carrying the directive as their signature. A macro is a value, |
| 1626 | // never an executable callee: the resolver reads these to recognize a |
| 1627 | // call whose name is a macro visible in the translation unit and refuses |
| 1628 | // to bind it to a same-named function elsewhere (#1838). Mirrored in the |
| 1629 | // kernel (ccpp/mod.rs visit_node). |
| 1630 | if ((this.language === 'c' || this.language === 'cpp') && nodeType === 'preproc_function_def') { |
| 1631 | const name = getChildByField(node, 'name'); |
| 1632 | if (name) { |
| 1633 | this.createNode('constant', getNodeText(name, this.source), node, { |
| 1634 | signature: getNodeText(node, this.source).trim(), |
| 1635 | }); |
| 1636 | } |
| 1637 | return; |
| 1638 | } |
| 1639 | |
| 1640 | // C++ namespace blocks: carry the namespace name as a qualifiedName prefix |
| 1641 | // while walking the body, so `namespace flash { void compute_attn(); }` |
| 1642 | // indexes compute_attn with qualifiedName `flash::compute_attn` and a |
| 1643 | // namespace-qualified call (`flash::compute_attn(...)`) resolves by exact |
| 1644 | // qualified match instead of never resolving — C++ namespaces previously |
| 1645 | // left no trace in qualifiedNames at all, so every `ns::fn()` call site |
| 1646 | // was a permanently dead edge (surfaced by #387 flow validation on |
| 1647 | // flash-attention/cutlass, whose kernel dispatch is namespace-qualified). |
| 1648 | // C++17 nested forms (`namespace a::b {`) prefix as written. An anonymous |
| 1649 | // namespace falls through to the generic walk — its contents stay bare, |
no test coverage detected