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:1239–1289  ·  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

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

Callers 1

visit_function_bodyMethod · 0.45

Calls 10

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