From ba58365c6f054fb82c40dca2c4fed8a8241c5a38 Mon Sep 17 00:00:00 2001 From: ctype_lab Date: Thu, 6 Aug 2026 16:53:13 +0900 Subject: [PATCH] docs(union): describe first-class union nodes --- CHANGELOG.md | 2 +- CLAUDE.md | 2 +- docs/design/ccpp-kernel-port-checklist.md | 7 +++---- docs/design/rust-lang-kernel-port-checklist.md | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d12356..5362328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixes -- Unions are now indexed in C, C++, Objective-C and Rust. A `union` declaration previously produced no symbol at all, so it never appeared in search or `codegraph_explore`, and anything attached to it disappeared with it — in Rust, every `impl SomeTrait for MyUnion` lost its edge, and the methods from that impl were left pointing at a type the graph did not contain. A `typedef union { … } Name;` in C now carries the typedef's name like `typedef struct` already did. Re-index after upgrading to pick up the new symbols. +- C, C++, Objective-C and Rust unions are now indexed as first-class `union` nodes. A `union` declaration previously produced no symbol at all, so it never appeared in search or `codegraph_explore`, and anything attached to it disappeared with it — in Rust, every `impl SomeTrait for MyUnion` lost its edge, and the methods from that impl were left pointing at a type the graph did not contain. A `typedef union { … } Name;` in C now carries the typedef's name and remains distinguishable from a struct. Re-index after upgrading to replace the earlier struct-shaped union nodes. - `codegraph_explore` now concentrates its answer on the code that actually answers your question instead of spreading it across files that merely share a word with it, so more of the answer arrives in a single call. Thanks @LeDuyViet for the detailed measurements and reproduction. (#1500) - Files only weakly related to your question now come back as a name, symbol and line number instead of spending the answer on their source — name one of them in a follow-up `codegraph_explore` to get it back in full. (#1500) diff --git a/CLAUDE.md b/CLAUDE.md index 1ae8ae9..4f24f1c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -66,7 +66,7 @@ The public API surface is `src/index.ts` — the `CodeGraph` class wires all the Defined in `src/types.ts`. Both extractors and resolvers must use these exact strings. -- **NodeKind**: `file`, `module`, `class`, `struct`, `interface`, `trait`, `protocol`, `function`, `method`, `property`, `field`, `variable`, `constant`, `enum`, `enum_member`, `type_alias`, `namespace`, `parameter`, `import`, `export`, `route`, `component`. +- **NodeKind**: `file`, `module`, `class`, `struct`, `interface`, `trait`, `protocol`, `function`, `method`, `property`, `field`, `variable`, `constant`, `enum`, `enum_member`, `type_alias`, `namespace`, `parameter`, `import`, `export`, `route`, `component`, `union`. - **EdgeKind**: `contains`, `calls`, `imports`, `exports`, `extends`, `implements`, `references`, `type_of`, `returns`, `instantiates`, `overrides`, `decorates`. ### Multi-agent installer diff --git a/docs/design/ccpp-kernel-port-checklist.md b/docs/design/ccpp-kernel-port-checklist.md index 520b2fd..3fe0562 100644 --- a/docs/design/ccpp-kernel-port-checklist.md +++ b/docs/design/ccpp-kernel-port-checklist.md @@ -139,10 +139,9 @@ walker mirrors, with file:line anchors (as of `705e501`). Read WITH ## Extractor configs (languages/c-cpp.ts — read the whole file when porting) **cExtractor (line 180):** functionTypes=[function_definition]; NO -class/method/interface types; structTypes=[struct_specifier] -(superseded: `union_specifier` joined structTypes — a named `union U { … };` -is a definition, extracted with kind `struct`, and `typedef union { … } N;` -resolves through resolveTypeAliasKind like `typedef struct`); +class/method/interface types; structTypes=[struct_specifier]; +unionTypes=[union_specifier] (a named `union U { … };` is a definition, and +`typedef union { … } N;` resolves to a first-class `union` node); enumTypes=[enum_specifier]; enumMemberTypes=[enumerator]; typeAliasTypes=[type_definition]; importTypes=[preproc_include]; callTypes=[call_expression]; variableTypes=[declaration]; diff --git a/docs/design/rust-lang-kernel-port-checklist.md b/docs/design/rust-lang-kernel-port-checklist.md index d6f01b3..8727d85 100644 --- a/docs/design/rust-lang-kernel-port-checklist.md +++ b/docs/design/rust-lang-kernel-port-checklist.md @@ -54,9 +54,9 @@ Types: functionTypes=[`function_item`, **`function_signature_item`**] (the latter = a trait method DECLARATION `fn render(&self);` — extracted so a trait's method set is first-class); classTypes=[] (impl blocks instead); methodTypes = same two; interfaceTypes=[`trait_item`] with -**interfaceKind:'trait'**; structTypes=[`struct_item`] (superseded: -`union_item` joined structTypes — same `body` field, same extractor, kind -`struct`); enumTypes=[`enum_item`]; +**interfaceKind:'trait'**; structTypes=[`struct_item`]; +unionTypes=[`union_item`] (same body walk, distinct `union` node kind); +enumTypes=[`enum_item`]; enumMemberTypes=[`enum_variant`]; typeAliasTypes=[`type_item`]; importTypes=[`use_declaration`]; callTypes=[`call_expression`]; variableTypes=[`let_declaration`, `const_item`, `static_item`].