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

Method visitPascalBlock

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

* Recursively visit a Pascal block/statement tree for call expressions

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

6615 * Recursively visit a Pascal block/statement tree for call expressions
6616 */
6617 private visitPascalBlock(node: SyntaxNode): void {
6618 for (let i = 0; i < node.namedChildCount; i++) {
6619 const child = node.namedChild(i);
6620 if (!child) continue;
6621 // Function-as-value capture (#756): Pascal bodies are walked here, not
6622 // in visitNode/visitForCallsAndStructure, so the capture hook fires here
6623 // — assignment RHS is the Delphi event-wiring idiom (`OnFire := Handler`).
6624 this.maybeCaptureFnRefs(child, child.type);
6625 if (child.type === 'exprCall') {
6626 this.extractPascalCall(child);
6627 // The walker doesn't descend into a call's arguments — dispatch the
6628 // argument container directly (`RegisterHandler(TargetCb)` / `(@Cb)`).
6629 const args = child.namedChildren.find((c: SyntaxNode) => c.type === 'exprArgs');
6630 if (args) this.maybeCaptureFnRefs(args, 'exprArgs');
6631 } else if (child.type === 'exprDot') {
6632 // A STATEMENT-level bare exprDot is a paren-less call (`Obj.Free;`,
6633 // `TFoo.GetInstance.DoIt;`). Anywhere else (assignment side, condition,
6634 // expression) a bare exprDot is ambiguous with a field/property access,
6635 // so there we only descend for paren'd inner calls.
6636 if (node.type === 'statement') {
6637 this.extractPascalParenlessCall(child);
6638 } else {
6639 for (let j = 0; j < child.namedChildCount; j++) {
6640 const grandchild = child.namedChild(j);
6641 if (grandchild?.type === 'exprCall') {
6642 this.extractPascalCall(grandchild);
6643 }
6644 }
6645 }
6646 } else {
6647 this.visitPascalBlock(child);
6648 }
6649 }
6650 }
6651}
6652
6653

Callers 3

visitPascalNodeMethod · 0.95
extractPascalDefProcMethod · 0.95
extractPascalCallMethod · 0.95

Calls 3

maybeCaptureFnRefsMethod · 0.95
extractPascalCallMethod · 0.95

Tested by

no test coverage detected