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

Source from the content-addressed store, hash-verified

725 }
726
727 fn visit_for_calls_and_structure(&mut self, node: Node<'t>) {
728 stack_guard!();
729 let kind = node.kind();
730 self.maybe_capture_fn_refs(node);
731
732 if kind == "call_expression" {
733 self.extract_call(node);
734 } else if kind == "new_expression" {
735 self.extract_instantiation(node);
736 }
737
738 // Local variable type annotations (TS family only).
739 if self.variant.is_ts() && kind == "variable_declarator" {
740 let owner = self.top_row();
741 self.extract_variable_type_annotation(node, owner);
742 }
743
744 // Nested NAMED functions become their own nodes — and so does the
745 // function a React handler hook binds a name to (`const onPress =
746 // useCallback(() => {…}, [])`). Mirrors TreeSitterExtractor's
747 // reactHookBoundName.
748 if is_function_type(kind) {
749 let name = self.extract_name(node);
750 if name != "<anonymous>" {
751 self.extract_function(node, None);
752 return;
753 }
754 if let Some(bound) = self.react_hook_bound_name(node) {
755 self.extract_function(node, Some(bound));
756 return;
757 }
758 // `const run = Effect.fn("Session.run")(function* () {…})` (#1747):
759 // the same declarator binding through a curried wrapper. Mirrors
760 // TreeSitterExtractor's curriedWrapperBoundName.
761 if let Some(bound) = self.curried_wrapper_bound_name(node) {
762 self.extract_function(node, Some(bound));
763 return;
764 }
765 // `const handleClear = () => {…}` inside a body (#1669): named by
766 // its declarator, like at module scope. Mirrors
767 // TreeSitterExtractor's declaratorBoundFunction.
768 if self.declarator_bound_function(node) {
769 self.extract_function(node, None);
770 return;
771 }
772 }
773
774 if is_class_type(self.variant, kind) {
775 self.extract_class(node);
776 return;
777 }
778 if self.variant.is_ts() && kind == "enum_declaration" {
779 self.extract_enum(node);
780 return;
781 }
782 if self.variant.is_ts() && kind == "interface_declaration" {
783 self.extract_interface(node);
784 return;

Callers 1

visit_function_bodyMethod · 0.45

Calls 15

is_function_typeFunction · 0.85
is_class_typeFunction · 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
top_rowMethod · 0.45
extract_nameMethod · 0.45

Tested by

no test coverage detected