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

Method visit_for_calls_and_structure

codegraph-kernel/src/rustlang.rs:1261–1310  ·  view source on GitHub ↗

`parent` is `node`'s parent, handed down by the walk (None at a body's root): `Node::parent()` walks down from the tree's root on every call.

(&mut self, node: Node<'t>, parent: Option<Node<'t>>)

Source from the content-addressed store, hash-verified

1259 /// `parent` is `node`'s parent, handed down by the walk (None at a body's
1260 /// root): `Node::parent()` walks down from the tree's root on every call.
1261 fn visit_for_calls_and_structure(&mut self, node: Node<'t>, parent: Option<Node<'t>>) {
1262 stack_guard!();
1263 let kind = node.kind();
1264 self.maybe_capture_fn_refs(node);
1265
1266 // Rocket route macros: handler paths live in a raw token tree.
1267 if kind == "macro_invocation" {
1268 self.extract_rust_route_macro(node);
1269 self.extract_rust_macro_refs(node);
1270 }
1271
1272 if kind == "call_expression" {
1273 self.extract_call(node);
1274 } else if kind == "struct_expression" {
1275 self.extract_instantiation(node);
1276 }
1277 self.extract_static_member_ref(node, parent);
1278
1279 // Nested NAMED fns become their own nodes (a nested fn inside an impl
1280 // method walks up to the impl and indexes as a METHOD).
1281 if matches!(kind, "function_item" | "function_signature_item") {
1282 let name = self.extract_name(node);
1283 if name != "<anonymous>" {
1284 self.extract_fn_or_method(node);
1285 return;
1286 }
1287 }
1288
1289 // Structural nodes inside bodies.
1290 if kind == "struct_item" {
1291 self.extract_aggregate(node, "struct");
1292 return;
1293 }
1294 if kind == "union_item" {
1295 self.extract_aggregate(node, "union");
1296 return;
1297 }
1298 if kind == "enum_item" {
1299 self.extract_enum(node);
1300 return;
1301 }
1302 if kind == "trait_item" {
1303 self.extract_interface(node);
1304 return;
1305 }
1306
1307 for c in node.named_children(&mut node.walk()) {
1308 self.visit_for_calls_and_structure(c, Some(node));
1309 }
1310 }
1311
1312 /// extractStaticMemberRef — the rust branch (#2328): an enum variant
1313 /// written as a path (`Mode::A`, `mode::Mode::B`, a `Mode::C(x)` /

Callers 1

visit_function_bodyMethod · 0.45

Calls 12

extract_fn_or_methodMethod · 0.80
maybe_capture_fn_refsMethod · 0.45
extract_callMethod · 0.45
extract_instantiationMethod · 0.45
extract_nameMethod · 0.45
extract_aggregateMethod · 0.45
extract_enumMethod · 0.45
extract_interfaceMethod · 0.45
walkMethod · 0.45

Tested by

no test coverage detected