Macro expansion M14: hover shows the one-step expansion; v0.5.0
Hovering `NAME(args) now appends an expands-to section: the definition the card already chose (single_step is blind to lookup, so they cannot disagree) with parameters substituted by the call's arguments - one step, so nested macro names stay as written. Strings, `" markers and escaped identifiers are never substituted into; count mismatches, unnarrowed multiple candidates and paren-less function-like uses get no section rather than a guess; an empty argument takes the parameter's declared default. 2000-char cap with a note. Version 0.5.0 closes the M7-M14 navigation run with a CHANGELOG entry covering all eight. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
36ddabac6c
commit
d26f08335b
17 files changed
+1264
-35
No files matched your search
@@ -13,6 +13,18 @@ bookkeeping, not expansion"). The table is also the substrate for the later
|
||||
single-step expansion display and for `` `WIDTH`` → "defined as 8 in
|
||||
defs.svh:12".
|
||||
|
||||
> **Both promises are kept, and neither needed a change here.** `` `WIDTH`` →
|
||||
> "defined as 8 in defs.svh:12" shipped with the server's hover card and was
|
||||
> narrowed to the include graph in M10 (`docs/features/include-nav/README.md`).
|
||||
> The **single-step expansion display** shipped in M14, 2026-08-25:
|
||||
> `crates/vfmt_server/src/expand.rs` substitutes a call site's arguments into
|
||||
> `Define::body` using `Define::params` exactly as recorded — defaults and all
|
||||
> — and adds an "expands to" section to the card. `defines.rs` is byte-identical
|
||||
> across that round: `params` "as written" and the LRM-literal body
|
||||
> normalization were the two decisions the consumer turned out to need, which
|
||||
> is the argument for both of them. Rules, non-goals and the reason a nested
|
||||
> `` `INNER`` is *not* expanded: `docs/features/macro-expansion/README.md`.
|
||||
|
||||
## Zero lexer changes, and why that worked
|
||||
|
||||
The task allowed touching `lexer.rs` if directive granularity made a post-lex
|
||||
@@ -187,6 +199,16 @@ above. Nothing depends on it yet, so it is free to change; the two things
|
||||
worth not changing casually are the body normalization rule (a hover string is
|
||||
user-visible) and "all definitions are kept".
|
||||
|
||||
> **No longer free to change (M14, 2026-08-25).** `vfmt_server`'s
|
||||
> `expand.rs` now reads `body` *and* `params` structurally: it splits a
|
||||
> parameter on its first `=` to get the name and the default, and it counts
|
||||
> `params` against the arguments at a call site, declining to expand on a
|
||||
> mismatch. So two things became contracts rather than conveniences —
|
||||
> parameters stored **as written** (`"b = 8"`, not `"b"`), and `` `define
|
||||
> NAME()`` recorded as `Some(vec![])` rather than one empty parameter, which
|
||||
> `expand.rs` mirrors so both sides count a zero-argument call the same way.
|
||||
> The body normalization rule is now user-visible twice per card.
|
||||
|
||||
**Requested of nobody.** No other module needs a change. In particular
|
||||
`parser.rs`, `format.rs` and `verify.rs` are untouched — CLAUDE.md hard
|
||||
invariant #4 does not apply to this round, because the safety net's
|
||||
@@ -227,6 +249,11 @@ and no AST node. The parameter-list scan tracks nesting with one `usize` that
|
||||
would be building for a consumer that does not exist.
|
||||
- [ ] **Not done:** stripping a `//` comment from a continuation line (see
|
||||
Assumptions), and cross-file `` `include`` following (workspace index).
|
||||
- [x] **Promised follow-up, delivered elsewhere (M14, 2026-08-25):**
|
||||
single-step expansion display on hover —
|
||||
`docs/features/macro-expansion/README.md`. It consumes this table
|
||||
unchanged; no file in this feature was edited for it. Cross-file
|
||||
`` `include`` following also landed, in M10's include graph.
|
||||
|
||||
## Work log
|
||||
|
||||
|
||||
Reference in new issue
Block a user