dartMisparsedCtor (dart.ts) — a generic constructor call tree-sitter-dart parsed as comparisons and a dot shorthand, found from the relational expression `tail` that holds its `>`: `(Future < void) > .delayed(d)`, or, with two type arguments in a list, `Map < String` then `int > .of(m)` in the next item. Recovered when laid out as a call: `<` against the type, a type in each argument, `>` against
(&self, tail: Node<'t>)
| 1806 | /// then `int > .of(m)` in the next item. Recovered when laid out as a call: |
| 1807 | /// `<` against the type, a type in each argument, `>` against the `.name`. |
| 1808 | fn misparsed_ctor(&self, tail: Node<'t>) -> Option<MisparsedCtor<'t>> { |
| 1809 | if tail.kind() != "relational_expression" { |
| 1810 | return None; |
| 1811 | } |
| 1812 | let mut cursor = tail.walk(); |
| 1813 | let kids: Vec<Node<'t>> = tail.named_children(&mut cursor).collect(); |
| 1814 | let dot_at = kids.iter().position(|c| c.kind() == "dot_shorthand")?; |
| 1815 | if dot_at < 2 { |
| 1816 | return None; |
| 1817 | } |
| 1818 | let dot = kids[dot_at]; |
| 1819 | let gt = kids[dot_at - 1]; |
| 1820 | if gt.kind() != "relational_operator" || gt.child(0)?.kind() != ">" || gt.end_byte() != dot.start_byte() { |
| 1821 | return None; |
| 1822 | } |
| 1823 | let call = kids.get(dot_at + 1)?; |
| 1824 | let mut cc = call.walk(); |
| 1825 | if call.kind() != "selector" || !call.named_children(&mut cc).any(|c| c.kind() == "argument_part") { |
| 1826 | return None; |
| 1827 | } |
| 1828 | let name = dot.named_child(0).filter(|n| n.kind() == "identifier" && dot.named_child_count() == 1)?; |
| 1829 | let first = kids[0]; |
| 1830 | // One type argument: `(X < T) > .name(…)`. |
| 1831 | if dot_at == 2 && first.kind() == "relational_expression" { |
| 1832 | let lt = self.ctor_type_args_start(first)?; |
| 1833 | let (head, type_name) = self.ctor_callee(first, lt)?; |
| 1834 | let (arg, next) = self.type_arg_part(lt.next_named_sibling())?; |
| 1835 | if next.is_some() { |
| 1836 | return None; |
| 1837 | } |
| 1838 | return Some(MisparsedCtor { head, type_name, name, type_args: [Some(arg), None], gt, start: first }); |
| 1839 | } |
| 1840 | // Two, split at their comma: `X < A`, then `B > .name(…)` in the next item. |
| 1841 | let (last, last_next) = self.type_arg_part(Some(first))?; |
| 1842 | if last_next != Some(gt) { |
| 1843 | return None; |
| 1844 | } |
| 1845 | let start = self.prev_listed_expression(tail)?; |
| 1846 | let lt = self.ctor_type_args_start(start)?; |
| 1847 | let (head, type_name) = self.ctor_callee(start, lt)?; |
| 1848 | let (arg, next) = self.type_arg_part(lt.next_named_sibling())?; |
| 1849 | if next.is_some() { |
| 1850 | return None; |
| 1851 | } |
| 1852 | Some(MisparsedCtor { head, type_name, name, type_args: [Some(arg), Some(last)], gt, start }) |
| 1853 | } |
| 1854 | |
| 1855 | /// dartMisparsedCtorIn (dart.ts) — whether the relational expression `rel` |
| 1856 | /// holds part of a misparsed generic constructor call before its `>`, |
no test coverage detected