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

Method visit_body

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

Source from the content-addressed store, hash-verified

2260 // --- visitFunctionBody (:5129-5286) — dart rows -----------------------
2261
2262 fn visit_body(&mut self, node: Node<'t>) {
2263 stack_guard!();
2264 self.maybe_capture_fn_refs(node);
2265
2266 let kind = node.kind();
2267 if kind == "new_expression" {
2268 // INSTANTIATION branch fires first — extractBareCall's
2269 // new_expression arm is dead. Children still recursed.
2270 self.extract_instantiation(node);
2271 } else if let Some(callee) = self.bare_call_name(node) {
2272 // extractBareCall (:5159-5173) — ref at the MATCHED node.
2273 if !self.stack.is_empty() {
2274 let caller_row = self.top_row();
2275 self.push_ref_at(caller_row, &callee, "calls", node);
2276 }
2277 }
2278
2279 self.extract_static_member_ref(node);
2280
2281 // A getter read `x.area` (#2338); a type the body names (#2327) — the
2282 // type argument of a generic call parsed as comparisons included.
2283 self.extract_member_read(node);
2284 let type_node = match kind {
2285 "type_identifier" => Some(node),
2286 "relational_operator" => self.misparsed_generic_call(node).map(|(_, type_name)| type_name),
2287 _ => None,
2288 };
2289 if let Some(type_node) = type_node.filter(|t| self.is_type_name_dart(*t)) {
2290 let name = self.text(type_node).to_string();
2291 let owner = self.top_row();
2292 self.push_ref_at(owner, &name, "references", type_node);
2293 }
2294 // A generic constructor call the grammar read as comparisons and a
2295 // dot shorthand, `(Future < void) > .delayed(d)`: the call, from where
2296 // a parsed one starts, and the types it names (dartMisparsedCtor).
2297 if kind == "relational_expression" && !self.stack.is_empty() {
2298 if let Some(ctor) = self.misparsed_ctor(node) {
2299 let owner = self.top_row();
2300 let callee = format!("{}.{}", self.text(ctor.type_name), self.text(ctor.name));
2301 self.push_ref_at(owner, &callee, "calls", ctor.head);
2302 let [first, second] = ctor.type_args;
2303 for type_node in [Some(ctor.type_name), first, second].into_iter().flatten() {
2304 if self.is_type_name_dart(type_node) {
2305 let name = self.text(type_node).to_string();
2306 self.push_ref_at(owner, &name, "references", type_node);
2307 }
2308 }
2309 }
2310 }
2311
2312 if kind == "function_signature" {
2313 // Nested named functions (:5245) — extractFunction walks the
2314 // nested body itself; the enclosing walker ALSO revisits the
2315 // sibling function_body (double-walk pass 2b) via recursion.
2316 self.extract_function(node);
2317 return;
2318 }
2319

Callers 3

visitMethod · 0.45
extract_functionMethod · 0.45
extract_methodMethod · 0.45

Calls 15

extract_member_readMethod · 0.80
mapMethod · 0.80
is_type_name_dartMethod · 0.80
misparsed_ctorMethod · 0.80
walkMethod · 0.80
textMethod · 0.65
maybe_capture_fn_refsMethod · 0.45
extract_instantiationMethod · 0.45
bare_call_nameMethod · 0.45
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected