dartMisparsedGenericCall (dart.ts) — a generic call tree-sitter-dart parsed as two comparisons, `(ref.read < Repo) > (p)`, found from its `<`: the node its callee ends with (under any `await` or prefix operator) and the identifier naming its type argument. Recovered when the type argument names a type and the code is laid out as a call — `<` against the callee, `(` against the `>`. A call chained
(&self, lt: Node<'t>)
| 1362 | /// its bare name, which the resolver types from the chain written before |
| 1363 | /// it, as it types a parsed chain's `X().m` (#750). |
| 1364 | fn misparsed_generic_call(&self, lt: Node<'t>) -> Option<(Node<'t>, Node<'t>)> { |
| 1365 | if lt.kind() != "relational_operator" || lt.child(0)?.kind() != "<" { |
| 1366 | return None; |
| 1367 | } |
| 1368 | let inner = lt.parent()?; |
| 1369 | let outer = inner.parent()?; |
| 1370 | if inner.kind() != "relational_expression" || outer.kind() != "relational_expression" { |
| 1371 | return None; |
| 1372 | } |
| 1373 | let left = outer.named_child(0)?; |
| 1374 | if left.start_byte() != inner.start_byte() || left.end_byte() != inner.end_byte() { |
| 1375 | return None; |
| 1376 | } |
| 1377 | let gt = outer.named_child(1)?; |
| 1378 | if gt.kind() != "relational_operator" || gt.child(0)?.kind() != ">" { |
| 1379 | return None; |
| 1380 | } |
| 1381 | let args = outer.named_child(2)?; |
| 1382 | if !matches!(args.kind(), "parenthesized_expression" | "record_literal") || args.start_byte() != gt.end_byte() { |
| 1383 | return None; |
| 1384 | } |
| 1385 | // A comment against the `<` (`ref.read /* c */<Repo>(p)`) is a |
| 1386 | // sibling of its own, so the callee is not against it. |
| 1387 | let before = lt.prev_named_sibling()?; |
| 1388 | if is_comment(before) || before.end_byte() != lt.start_byte() { |
| 1389 | return None; |
| 1390 | } |
| 1391 | // The type argument: `T`, `p.T`, `T<…>` or `p.T<…>`, and nothing else. |
| 1392 | let head = lt.next_named_sibling()?; |
| 1393 | if head.kind() != "identifier" { |
| 1394 | return None; |
| 1395 | } |
| 1396 | let mut type_name = head; |
| 1397 | let mut rest = head.next_named_sibling(); |
| 1398 | if let Some(sel) = rest { |
| 1399 | let accessor = sel.named_child(0).filter(|a| a.kind() == "unconditional_assignable_selector"); |
| 1400 | if sel.kind() == "selector" { |
| 1401 | if let Some(accessor) = accessor { |
| 1402 | let mut ac = accessor.walk(); |
| 1403 | let name = accessor.named_children(&mut ac).find(|c| c.kind() == "identifier"); |
| 1404 | type_name = name?; |
| 1405 | rest = sel.next_named_sibling(); |
| 1406 | } |
| 1407 | } |
| 1408 | } |
| 1409 | if let Some(sel) = rest { |
| 1410 | let only_type_args = sel.named_child_count() == 1 |
| 1411 | && sel.named_child(0).map(|t| t.kind() == "type_arguments").unwrap_or(false); |
| 1412 | if sel.kind() == "selector" && only_type_args { |
| 1413 | rest = sel.next_named_sibling(); |
| 1414 | } |
| 1415 | } |
| 1416 | if rest.is_some() { |
| 1417 | return None; |
| 1418 | } |
| 1419 | let name = self.text(type_name); |
| 1420 | if !is_upper_camel(name) && !is_lowercase_type(name) { |
| 1421 | return None; |
no test coverage detected