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

Method visit_for_calls_and_structure

codegraph-kernel/src/php.rs:620–675  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

618 }
619
620 fn visit_for_calls_and_structure(&mut self, node: Node<'t>) {
621 stack_guard!();
622 let kind = node.kind();
623 self.maybe_capture_fn_refs(node);
624
625 if matches!(
626 kind,
627 "function_call_expression" | "member_call_expression" | "scoped_call_expression"
628 ) {
629 self.extract_call(node);
630 } else if kind == "object_creation_expression" {
631 self.extract_instantiation(node);
632 if let Some(anon_body) = find_anonymous_class_body(node) {
633 self.extract_anonymous_class(node, anon_body);
634 return;
635 }
636 }
637
638 // Static value reads (`Cls::CONST`, `Cls::$prop`, `Cls::class`).
639 self.extract_static_member_ref(node);
640
641 // Nested NAMED functions; body-level class/trait/enum/interface
642 // declarations (the polyfill idiom). NOTE: no method_declaration
643 // branch — in-body anonymous-class methods vanish (delta #1), and the
644 // visitNode hook does NOT run here (a const_declaration in a body-level
645 // class still extracts via extractClass's own visitNode body walk).
646 if kind == "function_definition" {
647 let name = self.extract_name(node);
648 if name != "<anonymous>" {
649 self.extract_function(node);
650 return;
651 }
652 }
653 if kind == "class_declaration" {
654 self.extract_class(node, "class");
655 return;
656 }
657 if kind == "trait_declaration" {
658 self.extract_class(node, "trait");
659 return;
660 }
661 if kind == "enum_declaration" {
662 self.extract_enum(node);
663 return;
664 }
665 if kind == "interface_declaration" {
666 self.extract_interface(node);
667 return;
668 }
669
670 for i in 0..node.named_child_count() {
671 if let Some(c) = node.named_child(i) {
672 self.visit_for_calls_and_structure(c);
673 }
674 }
675 }
676
677 // --- extractors ----------------------------------------------------------------

Callers 1

visit_function_bodyMethod · 0.45

Calls 11

maybe_capture_fn_refsMethod · 0.45
extract_callMethod · 0.45
extract_instantiationMethod · 0.45
extract_nameMethod · 0.45
extract_functionMethod · 0.45
extract_classMethod · 0.45
extract_enumMethod · 0.45
extract_interfaceMethod · 0.45

Tested by

no test coverage detected