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

Method visit_node

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

Source from the content-addressed store, hash-verified

633 // --- the dispatcher (visitNode, Swift-relevant branches) -----------------------
634
635 fn visit_node(&mut self, node: Node<'t>) {
636 stack_guard!();
637 let kind = node.kind();
638 let mut skip_children = false;
639
640 self.maybe_capture_fn_refs(node);
641
642 if kind == "function_declaration" {
643 if self.inside_class_like() {
644 self.extract_method(node);
645 } else {
646 self.extract_function(node);
647 }
648 skip_children = true;
649 } else if kind == "class_declaration" {
650 // classifyClassNode: `struct`/`enum` keyword children; actor and
651 // extension fall through to 'class'.
652 let mut classified = "class";
653 for i in 0..node.child_count() {
654 if let Some(c) = node.child(i) {
655 if c.kind() == "struct" {
656 classified = "struct";
657 break;
658 }
659 if c.kind() == "enum" {
660 classified = "enum";
661 break;
662 }
663 }
664 }
665 match classified {
666 "struct" => self.extract_struct(node),
667 "enum" => self.extract_enum(node),
668 _ => self.extract_class(node),
669 }
670 skip_children = true;
671 } else if kind == "protocol_declaration" {
672 self.extract_interface(node);
673 skip_children = true;
674 } else if kind == "typealias_declaration" {
675 skip_children = self.extract_type_alias(node);
676 } else if kind == "property_declaration" && !self.inside_class_like() {
677 // Top-level let/var (extractVariable's swift branch). Initializers
678 // are NEVER walked — candidates-only scan.
679 self.extract_variable(node);
680 self.scan_fn_ref_subtree(node, 0);
681 skip_children = true;
682 } else if matches!(kind, "property_declaration" | "protocol_property_declaration")
683 && self.inside_class_like()
684 {
685 skip_children = self.dedicated_property_branch(node);
686 } else if kind == "import_declaration" {
687 self.extract_import(node);
688 } else if kind == "call_expression" {
689 self.extract_call(node);
690 }
691 // init/deinit/subscript declarations, macro_invocation, directive,
692 // diagnostic, operator/precedence declarations, protocol function

Callers 5

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

Calls 14

maybe_capture_fn_refsMethod · 0.45
inside_class_likeMethod · 0.45
extract_methodMethod · 0.45
extract_functionMethod · 0.45
extract_structMethod · 0.45
extract_enumMethod · 0.45
extract_classMethod · 0.45
extract_interfaceMethod · 0.45
extract_type_aliasMethod · 0.45
extract_variableMethod · 0.45
scan_fn_ref_subtreeMethod · 0.45

Tested by

no test coverage detected