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

Method visit_node

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

Source from the content-addressed store, hash-verified

698 // --- the dispatcher (visitNode) --------------------------------------------
699
700 fn visit_node(&mut self, node: Node<'t>) {
701 stack_guard!();
702 let kind = node.kind();
703 let mut skip_children = false;
704
705 // Function-as-value capture — independent of the dispatch ladder.
706 self.maybe_capture_fn_refs(node);
707
708 // `window.App = {…}` / `App.utils = {…}`: the object's functions are
709 // the path's members (#2300). Its whole subtree is handled there.
710 if kind == "assignment_expression" && self.extract_assigned_object_owner(node, true) {
711 return;
712 }
713
714 if is_function_type(kind) {
715 // (the isInsideClassLike + methodTypes overlap is Python/Ruby-only)
716 self.extract_function(node, None);
717 skip_children = true;
718 } else if kind == "function_signature" && self.variant.is_ts() && is_ambient_function_signature(node, self.file_path) {
719 // A bodiless function that no implementation follows: a
720 // `declare function`, a function in a `declare module` body or a `.d.ts`.
721 self.extract_function(node, None);
722 skip_children = true;
723 } else if is_class_node(self.variant, node) {
724 self.extract_class(node);
725 skip_children = true;
726 } else if is_method_type(self.variant, kind)
727 && (!is_signature_method_type(kind) || self.inside_class_like())
728 {
729 if classify_ts_class_member(node) == Member::Property {
730 let prop = self.extract_property(node);
731 // The initializer walked under the property took its own
732 // candidates; the scan covers the rest of the field.
733 let mut walked: Option<HashSet<usize>> = None;
734 if let (Some((row, name)), Some(value)) = (prop, node.child_by_field_name("value")) {
735 self.stack.push(Scope { row, kind: "property", name });
736 self.visit_function_body(value);
737 self.stack.pop();
738 walked = Some(HashSet::from([value.id()]));
739 }
740 self.scan_fn_ref_subtree(node, 0, walked.as_ref());
741 } else {
742 self.extract_method(node);
743 }
744 skip_children = true;
745 } else if self.variant.is_ts() && kind == "interface_declaration" {
746 self.extract_interface(node);
747 skip_children = true;
748 } else if self.variant.is_ts() && kind == "enum_declaration" {
749 self.extract_enum(node);
750 skip_children = true;
751 } else if self.variant.is_ts() && kind == "type_alias_declaration" {
752 skip_children = self.extract_type_alias(node);
753 } else if is_variable_type(kind) && !self.inside_class_like() {
754 // An initializer extract_variable walked under the symbol it
755 // declares (a constant's, a component wrapper's) captured its own
756 // candidates; the scan skips it.
757 let walked = self.extract_variable(node);

Callers 4

extractFunction · 0.45
extract_classMethod · 0.45
extract_interfaceMethod · 0.45
extract_enumMethod · 0.45

Calls 15

is_function_typeFunction · 0.85
is_class_nodeFunction · 0.85
is_signature_method_typeFunction · 0.85
classify_ts_class_memberFunction · 0.85
is_variable_typeFunction · 0.85
is_property_typeFunction · 0.85
is_tsMethod · 0.80
pushMethod · 0.80
idMethod · 0.80
emit_re_export_refsMethod · 0.80

Tested by

no test coverage detected