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

Method visit_node

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

Source from the content-addressed store, hash-verified

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

Callers 5

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

Calls 15

childrenMethod · 0.80
maybe_capture_fn_refsMethod · 0.45
inside_class_likeMethod · 0.45
extract_methodMethod · 0.45
extract_functionMethod · 0.45
walkMethod · 0.45
extract_structMethod · 0.45
extract_enumMethod · 0.45
extract_classMethod · 0.45
extract_interfaceMethod · 0.45
extract_type_aliasMethod · 0.45

Tested by

no test coverage detected