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

Method bare_call_name

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

Source from the content-addressed store, hash-verified

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

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