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

Method visit_node

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

Source from the content-addressed store, hash-verified

472 // --- visitNode ------------------------------------------------------------
473
474 fn visit_node(&mut self, node: Node<'t>) {
475 stack_guard!();
476 let kind = node.kind();
477 let mut skip_children = false;
478
479 self.maybe_capture_fn_refs(node);
480
481 if matches!(kind, "function_item" | "function_signature_item") {
482 self.extract_fn_or_method(node);
483 skip_children = true;
484 } else if kind == "trait_item" {
485 self.extract_interface(node);
486 skip_children = true;
487 } else if kind == "struct_item" {
488 self.extract_aggregate(node, "struct");
489 skip_children = true;
490 } else if kind == "union_item" {
491 self.extract_aggregate(node, "union");
492 skip_children = true;
493 } else if kind == "enum_item" {
494 self.extract_enum(node);
495 skip_children = true;
496 } else if kind == "type_item" {
497 self.extract_type_alias(node);
498 // extractTypeAlias returns false for rust (plain alias) — children
499 // are visited (nothing in them has a branch).
500 } else if matches!(kind, "let_declaration" | "const_item" | "static_item")
501 && !self.inside_class_like()
502 {
503 // Inside a class-like scope the gate fails and the else-ladder
504 // falls through with children VISITED — a trait const's value
505 // expression emits calls refs from the trait node.
506 // The initializer extract_variable walked under the declared
507 // symbol took its own candidates; the scan covers the rest.
508 let walked = self.extract_variable(node);
509 self.scan_fn_ref_subtree(node, 0, &walked);
510 skip_children = true;
511 } else if kind == "use_declaration" {
512 self.extract_import(node);
513 // importTypes branch never sets skipChildren.
514 } else if kind == "call_expression" {
515 self.extract_call(node);
516 } else if kind == "struct_expression" {
517 self.extract_instantiation(node);
518 } else if kind == "impl_item" {
519 // Emits the implements back-reference; skipChildren stays false so
520 // the declaration_list is visited at FILE scope (impl pushes
521 // nothing on the stack).
522 self.extract_rust_impl_item(node);
523 }
524
525 if !skip_children {
526 for i in 0..node.named_child_count() {
527 if let Some(c) = node.named_child(i) {
528 self.visit_node(c);
529 }
530 }
531 }

Callers 4

extractFunction · 0.45
extract_interfaceMethod · 0.45
extract_aggregateMethod · 0.45
extract_enumMethod · 0.45

Calls 13

extract_fn_or_methodMethod · 0.80
maybe_capture_fn_refsMethod · 0.45
extract_interfaceMethod · 0.45
extract_aggregateMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 0.45
inside_class_likeMethod · 0.45
extract_variableMethod · 0.45
scan_fn_ref_subtreeMethod · 0.45
extract_importMethod · 0.45
extract_callMethod · 0.45

Tested by

no test coverage detected