fix(c,cpp,objc,rust): index union declarations

A `union` declaration produced no symbol at all in any of the four
languages that have one. The type never entered the graph, and neither
did anything attached to it — in Rust every `impl Trait for MyUnion`
lost its edge, and the impl's methods were left with a qualifiedName
pointing at a type the graph did not contain.

`union_specifier` / `union_item` were absent from the extraction layer
entirely: no `<x>Types` list on the TS side, no dispatch branch in
either kernel walker.

They join `structTypes` (kind `struct` — NodeKind has no `union`), which
is the extension point the table-driven extractors already provide. The
body guard in extractStruct is untouched, so a bodiless `union U;` stays
a forward declaration and is still skipped, exactly like `struct U;`.

`resolveTypeAliasKind` accepts `union_specifier` too, so
`typedef union { … } N;` takes the typedef's name the way
`typedef struct { … } N;` already did. Without it the anonymous union
body would mint a second `<anonymous>` node beside the alias.

Both walkers change together so kernel<->wasm parity holds.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
ctype_labandClaude Opus 5 committed 2026-08-06 15:46:53 +09:00
1 parent d6d17288be
commit 85e9ac6762
5 files changed
+51 -15

No files matched your search

+9 -2
View File
@@ -102,7 +102,9 @@ export const objcExtractor: LanguageExtractor = {
methodTypes: ['method_definition'],
interfaceTypes: ['protocol_declaration'],
interfaceKind: 'protocol',
structTypes: ['struct_specifier'],
// Objective-C is a C superset: `union U { … };` is a definition, same as in
// the C extractor.
structTypes: ['struct_specifier', 'union_specifier'],
enumTypes: ['enum_specifier'],
enumMemberTypes: ['enumerator'],
typeAliasTypes: ['type_definition'],
@@ -128,7 +130,12 @@ export const objcExtractor: LanguageExtractor = {
const child = node.namedChild(i);
if (!child) continue;
if (child.type === 'enum_specifier' && getChildByField(child, 'body')) return 'enum';
if (child.type === 'struct_specifier' && getChildByField(child, 'body')) return 'struct';
// `typedef union { … } name;` resolves like `typedef struct` — see the C extractor.
if (
(child.type === 'struct_specifier' || child.type === 'union_specifier') &&
getChildByField(child, 'body')
)
return 'struct';
}
return undefined;
},