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

Method ctor_callee

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

dartCtorCallee (dart.ts) — the type a misparsed generic constructor call names, from the `<` that opens its type arguments inside `rel`: `X` in `X `, or `p.X` with its import prefix. The callee is all of `rel` before the `<`, under an `await` or a prefix operator too, and the `<` is written against it.

(&self, rel: Node<'t>, lt: Node<'t>)

Source from the content-addressed store, hash-verified

1721 /// `rel` before the `<`, under an `await` or a prefix operator too, and
1722 /// the `<` is written against it.
1723 fn ctor_callee(&self, rel: Node<'t>, lt: Node<'t>) -> Option<(Node<'t>, Node<'t>)> {
1724 let before = lt.prev_named_sibling()?;
1725 if before.end_byte() != lt.start_byte() {
1726 return None;
1727 }
1728 // `await Future<void>.delayed(d)` and `await p.Box<int>.named(…)` put
1729 // the callee under the `await`.
1730 let mut last = before;
1731 if is_prefixed(before.kind()) {
1732 if rel.named_child(0)? != before {
1733 return None;
1734 }
1735 while is_prefixed(last.kind()) {
1736 last = last.named_child(last.named_child_count().checked_sub(1)?)?;
1737 }
1738 }
1739 let (head, type_name) = if last.kind() == "selector" {
1740 // `p.X<T>.named(…)`: the import prefix, then the type.
1741 let accessor = last.named_child(0)?;
1742 if last.named_child_count() != 1 || accessor.kind() != "unconditional_assignable_selector" {
1743 return None;
1744 }
1745 let mut ac = accessor.walk();
1746 let type_name = accessor.named_children(&mut ac).find(|c| c.kind() == "identifier")?;
1747 (last.prev_named_sibling()?, type_name)
1748 } else {
1749 (last, last)
1750 };
1751 if head.kind() != "identifier" {
1752 return None;
1753 }
1754 // Written as it is, the callee is all of `rel` before the `<`.
1755 if last == before && rel.named_child(0)? != head {
1756 return None;
1757 }
1758 if !is_upper_camel(self.text(type_name)) {
1759 return None;
1760 }
1761 Some((head, type_name))
1762 }
1763
1764 /// dartCtorTypeArgsStart (dart.ts) — the `<` of a relational expression
1765 /// that opens a misparsed call's type arguments: its only operator.

Callers 2

misparsed_ctorMethod · 0.80
misparsed_ctor_inMethod · 0.80

Calls 4

is_prefixedFunction · 0.85
is_upper_camelFunction · 0.85
walkMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected