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

Method visit_body

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

Source from the content-addressed store, hash-verified

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

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
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