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

Method visit_node

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

Source from the content-addressed store, hash-verified

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