* The class a C# declared type names, as `new T()` would name it: `Foo`, * `List ` → `List`, `Ns.Foo` / `global::Foo` → `Foo`, `Foo?` → `Foo`. * Predefined, array, tuple and pointer types name no class → null. Mirrored * in the kernel (csharp.rs class_type_name).
(node: SyntaxNode | null, source: string)
| 268 | * in the kernel (csharp.rs class_type_name). |
| 269 | */ |
| 270 | function csharpClassTypeName(node: SyntaxNode | null, source: string): string | null { |
| 271 | if (!node) return null; |
| 272 | switch (node.type) { |
| 273 | case 'identifier': |
| 274 | return getNodeText(node, source) || null; |
| 275 | case 'generic_name': |
| 276 | return csharpClassTypeName(node.namedChildren.find((c: SyntaxNode) => c.type === 'identifier') ?? null, source); |
| 277 | case 'qualified_name': |
| 278 | case 'alias_qualified_name': |
| 279 | return csharpClassTypeName(getChildByField(node, 'name'), source); |
| 280 | case 'nullable_type': |
| 281 | return csharpClassTypeName(getChildByField(node, 'type'), source); |
| 282 | default: |
| 283 | return null; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /** First `simple_identifier` in `node`'s subtree (breadth-ish, first-found). |
| 288 | * Swift's property name nests as `property_declaration → <name> pattern → |
no test coverage detected