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:1257–1308  ·  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

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

Callers 1

visit_function_bodyMethod · 0.45

Calls 11

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

Tested by

no test coverage detected