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

Method visit_node

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

Source from the content-addressed store, hash-verified

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

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