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

Method bare_call_name

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

Source from the content-addressed store, hash-verified

1215 // --- extractBareCall (dart.ts:305-379) --------------------------------
1216
1217 fn bare_call_name(&self, node: Node<'t>) -> Option<String> {
1218 if node.kind() == "selector" {
1219 let mut cursor = node.walk();
1220 let has_arg_part = node.named_children(&mut cursor).any(|c| c.kind() == "argument_part");
1221 if !has_arg_part {
1222 return None;
1223 }
1224 // Past comments: `box.grow /* by */ (3)` calls `box.grow`.
1225 let prev = prev_named(node)?;
1226 return self.callee_name(prev);
1227 }
1228
1229 // A generic call the grammar read as two comparisons
1230 // (`ref.read<Repo>(p)`), named at its `<`, where a parsed call's
1231 // argument part starts.
1232 if node.kind() == "relational_operator" {
1233 let (callee, _) = self.misparsed_generic_call(node)?;
1234 return self.callee_name(callee);
1235 }
1236
1237 // new_expression arm — DEAD in practice (the INSTANTIATION branch
1238 // fires first in the body walker); ported for fidelity.
1239 if node.kind() == "new_expression" {
1240 let mut cursor = node.walk();
1241 let found = node
1242 .named_children(&mut cursor)
1243 .find(|c| c.kind() == "type_identifier")
1244 .map(|t| self.text(t).to_string());
1245 return found;
1246 }
1247
1248 // const EdgeInsets.all(8.0) — const constructor call.
1249 if node.kind() == "const_object_expression" {
1250 let mut c1 = node.walk();
1251 let type_id = node.named_children(&mut c1).find(|c| c.kind() == "type_identifier");
1252 let mut c2 = node.walk();
1253 let name_id = node.named_children(&mut c2).find(|c| c.kind() == "identifier");
1254 return match (type_id, name_id) {
1255 (Some(t), Some(n)) => Some(format!("{}.{}", self.text(t), self.text(n))),
1256 (Some(t), None) => Some(self.text(t).to_string()),
1257 _ => None,
1258 };
1259 }
1260
1261 // `=> BlocProvider<CounterCubit>.value(…)` — a constructor called
1262 // with type arguments, as most expressions parse it. The type is the
1263 // LAST type_identifier: an import prefix (`p.X<T>.named`) is one too.
1264 if node.kind() == "constructor_invocation" {
1265 let mut c1 = node.walk();
1266 let type_id = node.named_children(&mut c1).filter(|c| c.kind() == "type_identifier").last();
1267 let mut c2 = node.walk();
1268 let name_id = node.named_children(&mut c2).find(|c| c.kind() == "identifier");
1269 return match (type_id, name_id) {
1270 (Some(t), Some(n)) => Some(format!("{}.{}", self.text(t), self.text(n))),
1271 (Some(t), None) => Some(self.text(t).to_string()),
1272 _ => None,
1273 };
1274 }

Callers 1

visit_bodyMethod · 0.45

Calls 6

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

Tested by

no test coverage detected