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

Source from the content-addressed store, hash-verified

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