Repository navigation
feat(extract): model unions, unit structs and COM interfaces as containers - #213
Merged
Merged
Conversation
…iners
Three declarations that a reader treats as types were invisible or mis-shaped,
so the graph disagreed with the source.
A union was not a kind at all. A bare `union U { ... }` produced no node, while
`typedef union { ... } A;` was recorded as a type alias — and a C++ union's
member method, having no container to belong to, degraded into a free function
whose callers were then absorbed by a same-named struct method. That last part
is a false edge, not a gap: a call on the union bound to the wrong type
entirely. `union` is now a first-class kind for C, C++, ObjC and Rust, appended
to NodeKind so every other variant's discriminant — and therefore every
existing node id — stays put. TypeScript's `A | B` remains a type alias, as
upstream has it.
A Rust unit struct was dropped before its node was minted, taking its
`impl Trait for Unit` edge with it, which concentrated the loss in exactly the
marker and test-double layers. Bodiless structs are now definitions where the
language says they are, opt-in per language rather than globally. Function-local
structs stay unindexed, unchanged and deliberate.
The MSVC COM `interface` keyword parsed as a function, losing the container, its
members' method kind, and its base-class reference. It is now rewritten to
`struct` before parsing, behind a lexical mask: comments, character, string and
raw-string literals, and whole preprocessor logical lines are excluded, as is
`interface class`. A naive keyword match corrupts real code — it rewrites inside
a block comment, where a complete declaration becomes the next node's
docstring, and it turns C++/CLI `interface class` into invalid syntax.
EXTRACTION_VERSION 6 -> 7. The cpp golden is regenerated for seven new fixtures
and a rust corpus is added; the other fourteen are byte-identical, with every
pre-existing row compared across nodes, edges, refs and files. On this repo the
change adds 53 struct nodes and their 53 implements edges and removes nothing.
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (92.94%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## main #213 +/- ##
==========================================
- Coverage 95.27% 95.25% -0.02%
==========================================
Files 137 137
Lines 74430 74928 +498
==========================================
+ Hits 70912 71374 +462
- Misses 3518 3554 +36
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tier 3 of the post-
v1.5.0upstream sync. Three declarations a reader treats as types were invisible or mis-shaped, so the graph disagreed with the source.Item 9 —
unionbecomes a kind (upstream PR #1516)A bare
union U { ... }produced no node, andtypedef union { ... } A;was recorded as atype_alias. Worse, a C++ union's member method had no container to belong to, so it degraded into a freefunction— and callers were absorbed by a same-named struct method:That is a false edge, not a gap.
unionnow covers C, C++, ObjC (union_specifier) and Rust (union_item). TypeScript'sA | Bstays a type alias, as upstream has it. No newEdgeKind— upstream adds none.The variant is appended to
NodeKind, which keeps every other discriminant and therefore every existing node id stable.Item 7 — Rust unit structs (#1513)
struct Unit;was dropped before its node was minted, taking itsimpl Trait for Unitedge with it — so the loss concentrated in exactly the marker and test-double layers. Bodiless structs are now definitions where the language says so, opt-in per language rather than globally.Function-local structs remain unindexed, verified as independent of whether they have a body:
Item 8 — the MSVC COM
interfacekeyword (#1519)It parsed as a
function, losing three things at once: the container, its members'methodkind, and its base-class reference. It is now rewritten tostructbefore parsing — but behind a lexical mask, because a naive keyword match corrupts real code:docstring— verifiedinterface class IFoostruct class IFoo#definecontinuationSo comments, character/string/raw-string literals and whole preprocessor logical lines are excluded, as is
interface class. The negatives are pinned by extraction-invariance against measured values — the sharpest beingINegCli.docstring == "interface INegComment;"— not by "the substitution did not fire".Golden movement, enumerated
EXTRACTION_VERSION6 → 7, once. Thecppcorpus is regenerated for seven new fixtures (10 → 17 files) and arustcorpus is added; the other fourteen are byte-identical.Every pre-existing row is compared across all four artifacts —
nodes/filesfor exact equality,refsandedgesas multisets, with a new edge permitted only when its source node lives in a new fixture file. That width is not decorative:getwas already defined twice in the cpp corpus, so a third same-named member could have re-pointed an existing edge invisibly. The new member is namedread_fieldfor the same reason.Whole-repo self-index — the regression check that matters
structimplementsunionfunction/method/type_aliasextendsrefs0 edges removed, 931 added, and not one
callsedge changed — 53 new nodes entered the graph without re-pointing any candidate set. That is precisely the class of regression Tier 2 shipped and caught only by this diff, which is why it is a gate here.The predicted
structcount was 443; the real number is 439, and the difference is explained rather than absorbed: of 57 grep matches, 2 live inside Rust raw-string test data and 2 are function-local, leaving 53 eligible and 53 indexed.Verification
make cigreen: 129 suites / 3231 passed / 0 failed (baseline 128 / 3214).reference/golden/erlang/edges.jsonstill holds its 2 legitimate recursivecallsself-edges.class|structexclusion's RED lives in the 15-shape unit test rather than the combined-file test, and the re-pointed C++callsedge turns out to be fixed at extraction, not inmatchMethodCall. A test written for the latter passed with the change reverted and was deleted rather than shipped.