feat: Fix Go struct/interface extraction by refactoring type_spec handling through type alias resolver

Addresses Go's tree-sitter parsing where structs and interfaces are wrapped in type_spec nodes rather than appearing as direct node types. Moves struct_type and interface_type detection from direct node type matching to a new resolveTypeAliasKind resolver that examines the inner type field, ensuring proper extraction with field visiting and inheritance detection.
This commit is contained in:
Colby McHenry
2026-04-06 18:33:37 -05:00
parent 630053f3a3
commit 982d987349
3 changed files with 62 additions and 7 deletions
+9
View File
@@ -174,4 +174,13 @@ export interface LanguageExtractor {
* When present, the receiver type is included in the qualified name for better searchability.
*/
getReceiverType?: (node: SyntaxNode, source: string) => string | undefined;
/**
* Resolve the actual node kind for a type alias declaration.
* Used by Go where `type_spec` is the named declaration wrapper for structs/interfaces:
* `type Foo struct { ... }` → type_spec (name: "Foo") → struct_type
* Returns 'struct', 'interface', etc. to override the default 'type_alias' kind,
* or undefined to keep it as a type alias.
*/
resolveTypeAliasKind?: (node: SyntaxNode, source: string) => NodeKind | undefined;
}