(body: SyntaxNode, _functionId: string)
| 7825 | } |
| 7826 | |
| 7827 | private visitFunctionBody(body: SyntaxNode, _functionId: string): void { |
| 7828 | if (!this.extractor) return; |
| 7829 | |
| 7830 | // `parent` is handed down by the walk (absent at the body's root): reading |
| 7831 | // `node.parent` walks down from the tree's root on every call. |
| 7832 | const visitForCallsAndStructure = (node: SyntaxNode, parent?: SyntaxNode): void => { |
| 7833 | const nodeType = node.type; |
| 7834 | |
| 7835 | // A function-like macro defined inside a body is still a macro (#1838). |
| 7836 | if ((this.language === 'c' || this.language === 'cpp') && nodeType === 'preproc_function_def') { |
| 7837 | this.visitNode(node); |
| 7838 | return; |
| 7839 | } |
| 7840 | |
| 7841 | // Function-as-value capture (#756) — function bodies are walked here, |
| 7842 | // not in visitNode, so the capture hook must fire in both walkers. |
| 7843 | this.maybeCaptureFnRefs(node, nodeType); |
| 7844 | |
| 7845 | // A named object literal in a body — an IIFE's `const App = {…}`, a |
| 7846 | // handler map in a function — owns its function members as one at |
| 7847 | // module scope does, and so does `window.App = {…}` written in here |
| 7848 | // (#2300). Each handles its whole subtree. |
| 7849 | if (nodeType === 'variable_declarator' && this.extractLocalObjectOwner(node)) return; |
| 7850 | if (nodeType === 'assignment_expression' && this.extractAssignedObjectOwner(node, false)) return; |
| 7851 | |
| 7852 | // Rocket route-registration macros (`routes![…]` / `catchers![…]`): the |
| 7853 | // handler paths live in a raw token tree the call walker can't see. So |
| 7854 | // do the calls in an expression macro's arguments (`format!`, #3251). |
| 7855 | if (nodeType === 'macro_invocation') { |
| 7856 | this.extractRustRouteMacro(node); |
| 7857 | this.extractRustMacroCalls(node); |
| 7858 | } |
| 7859 | |
| 7860 | // A CFML `include "x.cfm";` in a function body includes the template |
| 7861 | // there, as it does at component scope (#2651). |
| 7862 | if (nodeType === 'include_statement' && this.language === 'cfscript') this.extractImport(node); |
| 7863 | // So does a PHP `require`/`include` (#3296): the function depends on |
| 7864 | // the file, as a call it makes is its own. (A namespace `use` can't |
| 7865 | // sit in a body.) |
| 7866 | if (this.language === 'php' && nodeType !== 'namespace_use_declaration' && this.extractor!.importTypes.includes(nodeType)) { |
| 7867 | this.extractImport(node); |
| 7868 | } |
| 7869 | |
| 7870 | if (this.extractor!.callTypes.includes(nodeType)) { |
| 7871 | this.extractCall(node); |
| 7872 | } else if (INSTANTIATION_KINDS.has(nodeType) || this.isVbnetConstructorShapedArrayCreation(node)) { |
| 7873 | // `new Foo()` inside a function body — emit an `instantiates` |
| 7874 | // reference. Without this branch the body walker only knew |
| 7875 | // about `call_expression`, so constructor invocations |
| 7876 | // produced no graph edges at all. |
| 7877 | this.extractInstantiation(node); |
| 7878 | // Anonymous class with body: `new T() { ... }` (Java/C#). Extract as |
| 7879 | // a class so interface-impl synthesis (Phase 5.5) can bridge T's |
| 7880 | // methods to the overrides — same rationale as in visitNode. |
| 7881 | const anonBody = this.findAnonymousClassBody(node); |
| 7882 | if (anonBody) { |
| 7883 | this.extractAnonymousClass(node, anonBody); |
| 7884 | return; |
no outgoing calls
no test coverage detected