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

Method visit_body

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

Source from the content-addressed store, hash-verified

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

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