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

Function csharpClassTypeName

src/extraction/tree-sitter.ts:273–288  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

271 * in the kernel (csharp.rs class_type_name).
272 */
273function csharpClassTypeName(node: SyntaxNode | null, source: string): string | null {
274 if (!node) return null;
275 switch (node.type) {
276 case 'identifier':
277 return getNodeText(node, source) || null;
278 case 'generic_name':
279 return csharpClassTypeName(node.namedChildren.find((c: SyntaxNode) => c.type === 'identifier') ?? null, source);
280 case 'qualified_name':
281 case 'alias_qualified_name':
282 return csharpClassTypeName(getChildByField(node, 'name'), source);
283 case 'nullable_type':
284 return csharpClassTypeName(getChildByField(node, 'type'), source);
285 default:
286 return null;
287 }
288}
289
290/** First `simple_identifier` in `node`'s subtree (breadth-ish, first-found).
291 * Swift's property name nests as `property_declaration → <name> pattern →

Callers 1

extractTargetTypedNewMethod · 0.85

Calls 2

getNodeTextFunction · 0.90
getChildByFieldFunction · 0.90

Tested by

no test coverage detected