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

Method visit_node

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

Source from the content-addressed store, hash-verified

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