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

Source from the content-addressed store, hash-verified

917 }
918
919 fn visit_for_calls_and_structure(&mut self, node: Node<'t>) {
920 stack_guard!();
921 let kind = node.kind();
922 self.maybe_capture_fn_refs(node);
923
924 // A named object literal in a body (an IIFE's `const App = {…}`) owns
925 // its function members as one at module scope does, and so does
926 // `window.App = {…}` written in here (#2300). Each handles its subtree.
927 if kind == "variable_declarator" && self.extract_local_object_owner(node) {
928 return;
929 }
930 if kind == "assignment_expression" && self.extract_assigned_object_owner(node, false) {
931 return;
932 }
933
934 if kind == "call_expression" {
935 self.extract_call(node);
936 } else if kind == "new_expression" {
937 self.extract_instantiation(node);
938 }
939
940 // Local variable type annotations (TS family only).
941 if self.variant.is_ts() && kind == "variable_declarator" {
942 let owner = self.top_row();
943 self.extract_variable_type_annotation(node, owner);
944 }
945
946 // Nested NAMED functions become their own nodes — and so does the
947 // function a React handler hook binds a name to (`const onPress =
948 // useCallback(() => {…}, [])`). Mirrors TreeSitterExtractor's
949 // reactHookBoundName.
950 if is_function_type(kind) {
951 let name = self.extract_name(node);
952 if name != "<anonymous>" {
953 self.extract_function(node, None);
954 return;
955 }
956 if let Some(bound) = self.react_hook_bound_name(node) {
957 self.extract_function(node, Some(bound));
958 return;
959 }
960 // `const run = Effect.fn("Session.run")(function* () {…})` (#1747):
961 // the same declarator binding through a curried wrapper. Mirrors
962 // TreeSitterExtractor's curriedWrapperBoundName.
963 if let Some(bound) = self.curried_wrapper_bound_name(node) {
964 self.extract_function(node, Some(bound));
965 return;
966 }
967 // `const handleClear = () => {…}` inside a body (#1669): named by
968 // its declarator, like at module scope. Mirrors
969 // TreeSitterExtractor's declaratorBoundFunction.
970 if self.declarator_bound_function(node) {
971 self.extract_function(node, None);
972 return;
973 }
974 // `Ctor.prototype.m = function () {…}` in a body — a module
975 // wrapper, a factory — is a method of the constructor declared
976 // 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