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

Source from the content-addressed store, hash-verified

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