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

Method bare_call_name

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

Source from the content-addressed store, hash-verified

1336 // --- extractBareCall (dart.ts:305-379) --------------------------------
1337
1338 fn bare_call_name(&self, node: Node<'t>) -> Option<String> {
1339 if node.kind() == "selector" {
1340 let mut cursor = node.walk();
1341 let has_arg_part = node.named_children(&mut cursor).any(|c| c.kind() == "argument_part");
1342 if !has_arg_part {
1343 return None;
1344 }
1345 // Past comments: `box.grow /* by */ (3)` calls `box.grow`.
1346 let prev = prev_named(node)?;
1347 return self.callee_name(prev);
1348 }
1349
1350 // A generic call the grammar read as two comparisons
1351 // (`ref.read<Repo>(p)`), named at its `<`, where a parsed call's
1352 // argument part starts.
1353 if node.kind() == "relational_operator" {
1354 let (callee, _) = self.misparsed_generic_call(node)?;
1355 return self.callee_name(callee);
1356 }
1357
1358 // new_expression arm — DEAD in practice (the INSTANTIATION branch
1359 // fires first in the body walker); ported for fidelity.
1360 if node.kind() == "new_expression" {
1361 let mut cursor = node.walk();
1362 let found = node
1363 .named_children(&mut cursor)
1364 .find(|c| c.kind() == "type_identifier")
1365 .map(|t| self.text(t).to_string());
1366 return found;
1367 }
1368
1369 // const EdgeInsets.all(8.0) — const constructor call.
1370 if node.kind() == "const_object_expression" {
1371 let mut c1 = node.walk();
1372 let type_id = node.named_children(&mut c1).find(|c| c.kind() == "type_identifier");
1373 let mut c2 = node.walk();
1374 let name_id = node.named_children(&mut c2).find(|c| c.kind() == "identifier");
1375 return match (type_id, name_id) {
1376 (Some(t), Some(n)) => Some(format!("{}.{}", self.text(t), self.text(n))),
1377 (Some(t), None) => Some(self.text(t).to_string()),
1378 _ => None,
1379 };
1380 }
1381
1382 // `=> BlocProvider<CounterCubit>.value(…)` — a constructor called
1383 // with type arguments, as most expressions parse it. The type is the
1384 // LAST type_identifier: an import prefix (`p.X<T>.named`) is one too.
1385 if node.kind() == "constructor_invocation" {
1386 let mut c1 = node.walk();
1387 let type_id = node.named_children(&mut c1).filter(|c| c.kind() == "type_identifier").last();
1388 let mut c2 = node.walk();
1389 let name_id = node.named_children(&mut c2).find(|c| c.kind() == "identifier");
1390 return match (type_id, name_id) {
1391 (Some(t), Some(n)) => Some(format!("{}.{}", self.text(t), self.text(n))),
1392 (Some(t), None) => Some(self.text(t).to_string()),
1393 _ => None,
1394 };
1395 }

Callers 1

visit_bodyMethod · 0.45

Calls 6

prev_namedFunction · 0.85
mapMethod · 0.80
textMethod · 0.65
walkMethod · 0.45
callee_nameMethod · 0.45

Tested by

no test coverage detected