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

Method ctor_info

codegraph-kernel/src/dart.rs:501–518  ·  view source on GitHub ↗

dartCtorInfo (dart.ts:61-70).

(&self, node: Node<'t>)

Source from the content-addressed store, hash-verified

499
500 /// dartCtorInfo (dart.ts:61-70).
501 fn ctor_info(&self, node: Node<'t>) -> Option<(String, String)> {
502 let ctor = self.constructor_signature(node)?;
503 // The names before the parameters: a redirecting factory names its
504 // target after them (`factory Foo() = _Impl.named;`).
505 let mut cursor = ctor.walk();
506 let ids: Vec<Node<'t>> = ctor
507 .named_children(&mut cursor)
508 .take_while(|c| c.kind() != "formal_parameter_list")
509 .filter(|c| c.kind() == "identifier")
510 .collect();
511 let class_name = self.enclosing_type_name(node)?;
512 let first = ids.first()?;
513 if self.text(*first) != class_name {
514 return None; // misparsed method, not a ctor
515 }
516 let ctor_name = ids.get(1).map(|n| self.text(*n)).unwrap_or(class_name);
517 Some((class_name.to_string(), ctor_name.to_string()))
518 }
519
520 /// extractDartReturnType (dart.ts:80-92).
521 fn return_type_of(&self, node: Node<'t>) -> Option<String> {

Callers 3

return_type_ofMethod · 0.80
is_misparsed_functionMethod · 0.80
extract_nameMethod · 0.80

Calls 8

walkMethod · 0.80
enclosing_type_nameMethod · 0.80
mapMethod · 0.80
textMethod · 0.65
getMethod · 0.65
constructor_signatureMethod · 0.45
collectMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected