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

Function rustImplTypeName

src/extraction/languages/rust.ts:53–72  ·  view source on GitHub ↗
(typeNode: SyntaxNode | null, source: string)

Source from the content-addressed store, hash-verified

51 * exactly as before.
52 */
53export function rustImplTypeName(typeNode: SyntaxNode | null, source: string): string | undefined {
54 if (!typeNode) return undefined;
55 switch (typeNode.type) {
56 case 'type_identifier':
57 case 'identifier':
58 return getNodeText(typeNode, source);
59 // `Foo<T>` — the `type` field is the bare (or scoped) name, never the args.
60 case 'generic_type':
61 return rustImplTypeName(getChildByField(typeNode, 'type'), source);
62 // `m::Foo` — the last segment is the type's name.
63 case 'scoped_type_identifier':
64 case 'scoped_identifier':
65 return rustImplTypeName(getChildByField(typeNode, 'name'), source);
66 // `&Foo` / `&'a mut Foo` — the referenced type.
67 case 'reference_type':
68 return rustImplTypeName(getChildByField(typeNode, 'type'), source);
69 default:
70 return undefined;
71 }
72}
73
74/**
75 * The type an item written directly in an `impl` block belongs to: `ValueHint`

Callers 3

extractRustImplItemMethod · 0.90
rustImplItemOwnerFunction · 0.85
rust.tsFile · 0.85

Calls 2

getNodeTextFunction · 0.90
getChildByFieldFunction · 0.90

Tested by

no test coverage detected