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:1236–1285  ·  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

1234 /// `parent` is `node`'s parent, handed down by the walk (None at a body's
1235 /// root): `Node::parent()` walks down from the tree's root on every call.
1236 fn visit_for_calls_and_structure(&mut self, node: Node<'t>, parent: Option<Node<'t>>) {
1237 stack_guard!();
1238 let kind = node.kind();
1239 self.maybe_capture_fn_refs(node);
1240
1241 // Rocket route macros: handler paths live in a raw token tree.
1242 if kind == "macro_invocation" {
1243 self.extract_rust_route_macro(node);
1244 self.extract_rust_macro_refs(node);
1245 }
1246
1247 if kind == "call_expression" {
1248 self.extract_call(node);
1249 } else if kind == "struct_expression" {
1250 self.extract_instantiation(node);
1251 }
1252 self.extract_static_member_ref(node, parent);
1253
1254 // Nested NAMED fns become their own nodes (a nested fn inside an impl
1255 // method walks up to the impl and indexes as a METHOD).
1256 if matches!(kind, "function_item" | "function_signature_item") {
1257 let name = self.extract_name(node);
1258 if name != "<anonymous>" {
1259 self.extract_fn_or_method(node);
1260 return;
1261 }
1262 }
1263
1264 // Structural nodes inside bodies.
1265 if kind == "struct_item" {
1266 self.extract_aggregate(node, "struct");
1267 return;
1268 }
1269 if kind == "union_item" {
1270 self.extract_aggregate(node, "union");
1271 return;
1272 }
1273 if kind == "enum_item" {
1274 self.extract_enum(node);
1275 return;
1276 }
1277 if kind == "trait_item" {
1278 self.extract_interface(node);
1279 return;
1280 }
1281
1282 for c in node.named_children(&mut node.walk()) {
1283 self.visit_for_calls_and_structure(c, Some(node));
1284 }
1285 }
1286
1287 /// extractStaticMemberRef — the rust branch (#2328): an enum variant
1288 /// 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