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

Method visit_for_calls_and_structure

codegraph-kernel/src/tsjs/mod.rs:805–889  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

803 }
804
805 fn visit_for_calls_and_structure(&mut self, node: Node<'t>) {
806 stack_guard!();
807 let kind = node.kind();
808 self.maybe_capture_fn_refs(node);
809
810 // A named object literal in a body (an IIFE's `const App = {…}`) owns
811 // its function members as one at module scope does, and so does
812 // `window.App = {…}` written in here (#2300). Each handles its subtree.
813 if kind == "variable_declarator" && self.extract_local_object_owner(node) {
814 return;
815 }
816 if kind == "assignment_expression" && self.extract_assigned_object_owner(node, false) {
817 return;
818 }
819
820 if kind == "call_expression" {
821 self.extract_call(node);
822 } else if kind == "new_expression" {
823 self.extract_instantiation(node);
824 }
825
826 // Local variable type annotations (TS family only).
827 if self.variant.is_ts() && kind == "variable_declarator" {
828 let owner = self.top_row();
829 self.extract_variable_type_annotation(node, owner);
830 }
831
832 // Nested NAMED functions become their own nodes — and so does the
833 // function a React handler hook binds a name to (`const onPress =
834 // useCallback(() => {…}, [])`). Mirrors TreeSitterExtractor's
835 // reactHookBoundName.
836 if is_function_type(kind) {
837 let name = self.extract_name(node);
838 if name != "<anonymous>" {
839 self.extract_function(node, None);
840 return;
841 }
842 if let Some(bound) = self.react_hook_bound_name(node) {
843 self.extract_function(node, Some(bound));
844 return;
845 }
846 // `const run = Effect.fn("Session.run")(function* () {…})` (#1747):
847 // the same declarator binding through a curried wrapper. Mirrors
848 // TreeSitterExtractor's curriedWrapperBoundName.
849 if let Some(bound) = self.curried_wrapper_bound_name(node) {
850 self.extract_function(node, Some(bound));
851 return;
852 }
853 // `const handleClear = () => {…}` inside a body (#1669): named by
854 // its declarator, like at module scope. Mirrors
855 // TreeSitterExtractor's declaratorBoundFunction.
856 if self.declarator_bound_function(node) {
857 self.extract_function(node, None);
858 return;
859 }
860 // `Ctor.prototype.m = function () {…}` in a body — a module
861 // wrapper, a factory — is a method of the constructor declared
862 // beside it (#2966). Mirrors TreeSitterExtractor's visitFunctionBody.

Callers 1

visit_function_bodyMethod · 0.45

Calls 15

is_function_typeFunction · 0.85
is_class_nodeFunction · 0.85
is_tsMethod · 0.80
react_hook_bound_nameMethod · 0.80
constructor_memberMethod · 0.80
maybe_capture_fn_refsMethod · 0.45
extract_callMethod · 0.45

Tested by

no test coverage detected