* A type argument the grammar read as an expression, starting at `node`: `T`, * `p.T`, `T<…>` or `p.T<…>`. Returns the identifier naming the type and the * node after the argument (null at the end of its parent). A type is written * in UpperCamelCase, or is one of Dart's lowercase built-ins (`int
(node: SyntaxNode | null)
| 323 | * in UpperCamelCase, or is one of Dart's lowercase built-ins (`int`, `void`). |
| 324 | */ |
| 325 | function dartTypeArgPart(node: SyntaxNode | null): { name: SyntaxNode; next: SyntaxNode | null } | undefined { |
| 326 | if (node?.type !== 'identifier') return undefined; |
| 327 | let name = node; |
| 328 | let rest = node.nextNamedSibling; |
| 329 | if (rest?.type === 'selector' && rest.namedChildCount === 1 && rest.firstNamedChild?.type === 'unconditional_assignable_selector') { |
| 330 | const id = rest.firstNamedChild.namedChildren.find((c: SyntaxNode) => c.type === 'identifier'); |
| 331 | if (!id) return undefined; |
| 332 | name = id; |
| 333 | rest = rest.nextNamedSibling; |
| 334 | } |
| 335 | if (rest?.type === 'selector' && rest.namedChildCount === 1 && rest.firstNamedChild?.type === 'type_arguments') { |
| 336 | rest = rest.nextNamedSibling; |
| 337 | } |
| 338 | if (!/^[_$]*[A-Z]/.test(name.text) && !DART_LOWERCASE_TYPES.has(name.text)) return undefined; |
| 339 | return { name, next: rest }; |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * The type a misparsed generic constructor call names, from the `<` that opens |
no test coverage detected