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:794–869  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

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

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
maybe_capture_fn_refsMethod · 0.45
extract_callMethod · 0.45
extract_instantiationMethod · 0.45

Tested by

no test coverage detected