Rename the tool to lucisv (Language Utility for Coding In SystemVerilog)
This commit is contained in:
1 parent
a284e33110
commit
eeaffafd56
188 files changed
+2825
-2802
No files matched your search
@@ -5,8 +5,8 @@
|
||||
TODO §4's "one parse, two tools", delivered on the linter side: parse a file
|
||||
once and lint from those products, instead of every consumer re-lexing and
|
||||
re-parsing text somebody already parsed. `LintContext` gains a constructor
|
||||
that accepts pre-built parse products; `vfmt check` builds the products once
|
||||
per file; and `vfmt_server` — which already holds a fully analyzed `Document`
|
||||
that accepts pre-built parse products; `lucisv check` builds the products once
|
||||
per file; and `lucisv_server` — which already holds a fully analyzed `Document`
|
||||
per buffer — lints from that document's own tokens and tree rather than
|
||||
paying two extra lexes and an extra tolerant parse per keystroke. Behavior is
|
||||
the hard gate: every finding, position, fix, diagnostic and exit code is
|
||||
@@ -36,7 +36,7 @@ byte-identical to before; only duplicated work is removed.
|
||||
them, keeps them where they always were: on `Document`.
|
||||
- **The `--fix` loop's per-round re-parse is inherent.** Each round rewrites
|
||||
the text, and products of the old text describe nothing. Only the *first*
|
||||
round of `vfmt check --fix` (and all of a plain `vfmt check`) saves work.
|
||||
round of `lucisv check --fix` (and all of a plain `lucisv check`) saves work.
|
||||
- **Per-change recompute stays the server's model.** This round removes
|
||||
duplicate work *within* one change/request; it adds no caching or
|
||||
invalidation machinery beyond what `Document` already is (TODO §6:
|
||||
@@ -62,7 +62,7 @@ unchanged in behavior):
|
||||
construction.
|
||||
- `pub struct ParsedSource` + `ParsedSource::parse(source) -> ParsedSource` +
|
||||
`ParsedSource::context(&self, path) -> LintContext<'_>` — the owned bundle
|
||||
of products for callers with no `Document` of their own (`vfmt check`, and
|
||||
of products for callers with no `Document` of their own (`lucisv check`, and
|
||||
`run`/`LintContext::new` internally). `parse` lexes **once** and builds the
|
||||
tree from a clone of the token stream.
|
||||
- `LintContext::new(source, path)` **stays**, as the convenience wrapper the
|
||||
@@ -77,7 +77,7 @@ unchanged in behavior):
|
||||
**Consumed**
|
||||
|
||||
- `vlog_parser::parse_tolerant(tokens, source)` — newly consumed by
|
||||
`vlog_linter` and `vfmt_server` (both already depended on the crate; it was
|
||||
`vlog_linter` and `lucisv_server` (both already depended on the crate; it was
|
||||
already `pub`). Relied on: with the same tokens it returns exactly the tree
|
||||
`parse_source_tolerant(source)` would (that function *is* `tokenize` +
|
||||
`parse_tolerant`), and on a well-formed file the tree equals `parse`'s.
|
||||
@@ -86,12 +86,12 @@ unchanged in behavior):
|
||||
|
||||
**Changed call sites**
|
||||
|
||||
- `crates/vfmt/src/lint.rs::run_rules` — parses once via `ParsedSource` and
|
||||
- `crates/lucisv/src/lint.rs::run_rules` — parses once via `ParsedSource` and
|
||||
hands the products to the context.
|
||||
- `crates/vfmt_server/src/state.rs::Document` — gains the `tree: SourceFile`
|
||||
- `crates/lucisv_server/src/state.rs::Document` — gains the `tree: SourceFile`
|
||||
field (it was parsed and thrown away after `analyze`), and `Document::new`
|
||||
lexes once instead of twice.
|
||||
- `crates/vfmt_server/src/lint.rs::{violations, fixable}` — the one call site
|
||||
- `crates/lucisv_server/src/lint.rs::{violations, fixable}` — the one call site
|
||||
server-lint's README predicted: both lint from the document's own products
|
||||
via `from_parse` instead of re-parsing `doc.text`.
|
||||
|
||||
@@ -108,7 +108,7 @@ products for, per request, as of the start of this round:
|
||||
| `Document::new` (every buffer change) | the text lexed twice: `tokenize` for `doc.tokens`, then `parse_source_tolerant`'s internal `tokenize` | **Eliminated** — one lex, tree built by `parse_tolerant` over a clone of the tokens; the lex-error fallback still goes through `parse_source_tolerant` so the error tree and diagnostic are byte-identical |
|
||||
| `format::formatting` / `range_formatting` | `format_source`/`format_range` lex+parse strictly inside `vlog_formatter` | **Kept** — the formatter's parse is the *strict* one (a tree `Document` does not hold), and the runtime safety net (equivalence + convergence) is defined over `format_source` doing its own work; sharing would need `vlog_formatter` API changes, which is the concurrent round's crate and a different feature |
|
||||
| `Workspace::rebuild_index` (initialize + every didSave) | re-reads and re-parses every workspace file inside `WorkspaceIndex::build`, open unchanged buffers included | **Kept** — the documented full-scan index model (TODO §6 defers incrementality to salsa); making it incremental is invalidation machinery this round explicitly must not build |
|
||||
| `semanticTokens`, `hover`, `definition`, `references`, `documentSymbol`, `workspace/symbol`, `diagnostics::diagnostics` | none — all already read `doc.tokens` / `doc.semantics` / `doc.defines` / `doc.diagnostics` | already clean (verified by grep for `tokenize`/`parse` over `crates/vfmt_server/src`) |
|
||||
| `semanticTokens`, `hover`, `definition`, `references`, `documentSymbol`, `workspace/symbol`, `diagnostics::diagnostics` | none — all already read `doc.tokens` / `doc.semantics` / `doc.defines` / `doc.diagnostics` | already clean (verified by grep for `tokenize`/`parse` over `crates/lucisv_server/src`) |
|
||||
|
||||
## The protected_regions decision: left alone
|
||||
|
||||
@@ -121,7 +121,7 @@ construction"? Almost — the server would pass `doc.tree` and the CLI its
|
||||
current round's tree — but "almost" is the problem: the CLI's `--fix` loop
|
||||
rebuilds text every round, and a future caller passing last round's tree is
|
||||
precisely the bug the `&str` signature makes unwritable. The cost lands only
|
||||
on fix-application paths (`vfmt check --fix`, `textDocument/codeAction`),
|
||||
on fix-application paths (`lucisv check --fix`, `textDocument/codeAction`),
|
||||
never on the per-keystroke diagnostics path. Two further reasons to leave
|
||||
it: it is `vlog_formatter`'s code, which belongs to the concurrent
|
||||
dynamic-types round this session; and the interior parse is of the *current*
|
||||
@@ -134,22 +134,22 @@ answer.**
|
||||
- [x] `vlog_linter`: `LintContext<'a>`, `from_parse`, `ParsedSource`,
|
||||
`new` kept as the wrapper; single-lex parse recipe in one place.
|
||||
- [x] Rules, visitors, waivers untouched (they compile and read unchanged).
|
||||
- [x] `crates/vfmt/src/lint.rs`: `run_rules` parses once via `ParsedSource`.
|
||||
- [x] `crates/vfmt_server`: `Document.tree` kept; `Document::new` single-lex;
|
||||
- [x] `crates/lucisv/src/lint.rs`: `run_rules` parses once via `ParsedSource`.
|
||||
- [x] `crates/lucisv_server`: `Document.tree` kept; `Document::new` single-lex;
|
||||
`lint::violations`/`fixable` lint from the document's products.
|
||||
- [x] Server catalog above; semanticTokens/hover verified already clean.
|
||||
- [x] protected_regions decision written (left alone).
|
||||
- [x] Tests: products-in == source-in property over rule-test inputs;
|
||||
lex-error and broken-file paths; existing CLI + server suites green
|
||||
**unmodified**.
|
||||
- [x] Byte-identity: corpus `vfmt check` (text + JSON) vs a HEAD worktree
|
||||
- [x] Byte-identity: corpus `lucisv check` (text + JSON) vs a HEAD worktree
|
||||
binary; server diagnostics vs a HEAD worktree binary over a real stdio
|
||||
session.
|
||||
- [x] Timing before/after.
|
||||
- [x] TODO §4 checkbox + linter-core / server-lint annotation lines.
|
||||
- [ ] **Not done, deliberately:** `vfmt format` sharing the parse. The
|
||||
- [ ] **Not done, deliberately:** `lucisv format` sharing the parse. The
|
||||
formatter requires a *strict* parse and runs its safety net over its own
|
||||
products; wiring `vfmt check --fix --format` workflows is a future
|
||||
products; wiring `lucisv check --fix --format` workflows is a future
|
||||
feature and is not blocked by anything here.
|
||||
- [ ] **Not done, deliberately:** any caching/invalidation in the server
|
||||
beyond `Document`'s per-change recompute.
|
||||
@@ -161,7 +161,7 @@ answer.**
|
||||
- Read `CLAUDE.md`, TODO §4, and the linter-core / server-lint /
|
||||
shared-fence-filter READMEs in full (QA logs and Reviews included) before
|
||||
writing anything, then the code: `vlog_linter`'s `context.rs`/`lib.rs`,
|
||||
`crates/vfmt/src/lint.rs`, and every file in `crates/vfmt_server/src`.
|
||||
`crates/lucisv/src/lint.rs`, and every file in `crates/lucisv_server/src`.
|
||||
- **The design was forced by one fact: `SourceFile` is not `Clone`.** The
|
||||
server's `Document` owns one tree that must serve semantics, published
|
||||
diagnostics *and* linting, so the products constructor has to borrow —
|
||||
@@ -196,7 +196,7 @@ answer.**
|
||||
`lint::violations` and `lint::fixable` now share a four-line `context(doc)`
|
||||
helper over `from_parse`. `vlog_linter::run` is no longer imported there.
|
||||
The catalog above was compiled by grepping `tokenize|parse` over
|
||||
`crates/vfmt_server/src` and reading each hit.
|
||||
`crates/lucisv_server/src` and reading each hit.
|
||||
- **Tests.** The products-in == source-in property was put where it covers
|
||||
the most ground: inside the rule-test harness's `assert_lint_with`, so all
|
||||
55 inline-marker cases (every rule × fires/quiet/waived/unused-waiver,
|
||||
@@ -205,9 +205,9 @@ answer.**
|
||||
Two new unit tests in `context.rs`: borrowed-vs-owned accessor equality,
|
||||
and the lex-error fallback producing the exact old error tree. Existing
|
||||
CLI and server suites pass **unmodified** (`git diff` on
|
||||
`crates/vfmt/tests`, `crates/vfmt_server` tests: empty).
|
||||
`crates/lucisv/tests`, `crates/lucisv_server` tests: empty).
|
||||
- Did not touch `vlog_parser`, `vlog_formatter`, `vlog_semantic`,
|
||||
`vfmt_core`, `editors/**`, or any `Cargo.toml`/`Cargo.lock` (no dependency
|
||||
`lucisv_core`, `editors/**`, or any `Cargo.toml`/`Cargo.lock` (no dependency
|
||||
moved; `parse_tolerant` was already `pub`). Did not run
|
||||
`git commit`/`git push`.
|
||||
- **Concurrency note.** A dynamic-types round was announced live in
|
||||
@@ -220,18 +220,18 @@ answer.**
|
||||
**Results.**
|
||||
|
||||
- `cargo test -p vlog_linter`: 118 unit + 55 integration + 1 doctest, green
|
||||
(118 was 116: the two new `context.rs` tests). `cargo test -p vfmt`:
|
||||
(118 was 116: the two new `context.rs` tests). `cargo test -p lucisv`:
|
||||
green including all 69 CLI integration tests, unmodified.
|
||||
`cargo test -p vfmt_server`: 115 unit + 6 e2e, green, unmodified.
|
||||
`cargo test -p lucisv_server`: 115 unit + 6 e2e, green, unmodified.
|
||||
`cargo test --workspace`: **770 passed, 0 failed**.
|
||||
- `cargo clippy --workspace --all-targets`: silent. `cargo fmt -p
|
||||
vlog_linter -p vfmt -p vfmt_server -- --check`: clean (scoped, per the
|
||||
vlog_linter -p lucisv -p lucisv_server -- --check`: clean (scoped, per the
|
||||
concurrency rule). No `#[allow]`, no `unwrap`/`expect`/`panic!`/`unsafe`
|
||||
outside `#[cfg(test)]` in anything touched.
|
||||
- **Byte-identity, CLI** (HEAD worktree binary at `e9008b6` vs this tree,
|
||||
both release):
|
||||
- `vfmt check corpus/`: stdout, stderr and exit code (1) identical.
|
||||
- `vfmt check corpus/ --output-format json`: **2 418 071 bytes of JSON,
|
||||
- `lucisv check corpus/`: stdout, stderr and exit code (1) identical.
|
||||
- `lucisv check corpus/ --output-format json`: **2 418 071 bytes of JSON,
|
||||
byte-identical**, stderr identical, exit identical.
|
||||
- `check --fix` over ten crafted shapes in twin directories (tabs +
|
||||
trailing whitespace, fence, fence-in-broken-file, waiver, lex failure,
|
||||
@@ -246,7 +246,7 @@ answer.**
|
||||
byte-identical** between the two binaries, canonicalized only by
|
||||
stripping the differing scratch-dir prefix from the URI.
|
||||
- **Timing, CLI** (release, median of 7, 860-file corpus):
|
||||
`vfmt check corpus/` **265.5 → 207.9 ms** at `--threads 1` (−22 %),
|
||||
`lucisv check corpus/` **265.5 → 207.9 ms** at `--threads 1` (−22 %),
|
||||
**79.7 → 70.5 ms** at the default thread count (−12 %). The single-thread
|
||||
number is the honest one (the pool hides latency); the saving matches the
|
||||
arithmetic — the lint pipeline did 2 lexes + 1 parse per file and now does
|
||||
@@ -296,7 +296,7 @@ identity run below was done in an **isolated copy**: `scratchpad/qa-new` =
|
||||
a byte copy of the dev's HEAD worktree (`scratchpad/head-wt`, verified clean
|
||||
at `e9008b6`) with **exactly this round's six code files** overlaid.
|
||||
`diff -rq head-wt qa-new` reports those six files and nothing else. The
|
||||
baseline binaries are `head-wt/target/release/{vfmt,vfmt-server}`; the "new"
|
||||
baseline binaries are `head-wt/target/release/{lucisv,lucisv-server}`; the "new"
|
||||
ones were rebuilt from `qa-new`. `corpus/` was never written to — the `--fix`
|
||||
runs used copies.
|
||||
|
||||
@@ -327,7 +327,7 @@ runs used copies.
|
||||
`unterminated block comment` + `no-tabs`, identical on both binaries).
|
||||
3. *Server catalog complete* — **PASS.** `grep -rn
|
||||
'tokenize|parse_source_tolerant|parse_tolerant|format_source|format_range|
|
||||
rebuild_index' crates/vfmt_server/src` returns exactly the sites the
|
||||
rebuild_index' crates/lucisv_server/src` returns exactly the sites the
|
||||
catalog names: `state.rs:56-61` (`Document::new`, one lex),
|
||||
`format.rs:57,87` (kept, strict parse), `state.rs:123/137` +
|
||||
`server.rs:251` (`rebuild_index`, kept), `lint.rs:54`
|
||||
@@ -339,7 +339,7 @@ runs used copies.
|
||||
`git diff --name-only -- crates/vlog_formatter/src/fence.rs` is empty; the
|
||||
file is untouched by this round (and by the concurrent one).
|
||||
5. *Behavior identity* — **PASS, re-run from scratch, not taken on trust.**
|
||||
- `vfmt check corpus/` (820 files): stdout **692 198 bytes identical**,
|
||||
- `lucisv check corpus/` (820 files): stdout **692 198 bytes identical**,
|
||||
stderr identical, exit 1 both.
|
||||
- `--output-format json`: **2 418 071 bytes identical** (matches the dev's
|
||||
figure exactly), stderr identical, exit 1 both.
|
||||
@@ -351,8 +351,8 @@ runs used copies.
|
||||
case-missing-default,module-filename` over the whole corpus. **12/12
|
||||
identical.**
|
||||
- `check --fix` over 13 crafted shapes (multi-round tab+trailing, a real
|
||||
`// verilog_format: off/on` fence, the `// vfmt: off/on` alias, an
|
||||
unclosed fence, `// vfmt: waive`, unused + malformed + unknown-rule
|
||||
`// verilog_format: off/on` fence, the `// lucisv: off/on` alias, an
|
||||
unclosed fence, `// lucisv: waive`, unused + malformed + unknown-rule
|
||||
waivers, a lex-error file, a filename mismatch, CRLF, multi-byte +
|
||||
emoji + tab, an empty file, a class body, a parse-error file): every
|
||||
rewritten file byte-identical, stdout (path-normalized) and stderr
|
||||
@@ -383,14 +383,14 @@ runs used copies.
|
||||
**8.2 → 3.7 ms** (informational; dev reported 18.0 → 11.0 and 7.6 → 3.4).
|
||||
7. *Gates* — **PASS.** In the isolated tree: `cargo test --workspace`
|
||||
**770 passed, 0 failed** (27 result lines; vlog_linter 118 unit + 55
|
||||
integration + 1 doctest, vfmt 30 unit + 69 CLI, vfmt_server 115 unit + 6
|
||||
integration + 1 doctest, lucisv 30 unit + 69 CLI, lucisv_server 115 unit + 6
|
||||
e2e — every count the work log claims). `cargo clippy --workspace
|
||||
--all-targets` exit 0, **zero warnings**. `cargo fmt --all -- --check`
|
||||
clean (not just the scoped set). In the *merged* tree the scoped crates are
|
||||
also green (`cargo test -p vlog_linter -p vfmt -p vfmt_server`: 30/69/115/
|
||||
also green (`cargo test -p vlog_linter -p lucisv -p lucisv_server`: 30/69/115/
|
||||
6/118/55/1) with scoped clippy and fmt clean. Test churn is zero:
|
||||
`git diff --numstat crates/vlog_linter/tests/rules.rs` is **12 added, 0
|
||||
removed**, and no other test file in `vfmt`/`vfmt_server`/`vlog_linter` is
|
||||
removed**, and no other test file in `lucisv`/`lucisv_server`/`vlog_linter` is
|
||||
touched. No `unwrap`/`expect`/`panic!`/`unsafe`/`#[allow]` outside
|
||||
`#[cfg(test)]` in any of the six files.
|
||||
|
||||
@@ -445,11 +445,11 @@ runs used copies.
|
||||
- **QA-1 (MEDIUM — missing coverage, not a defect in shipped behavior).**
|
||||
The stale-tree bug that this round newly makes possible is caught by **no
|
||||
test in the workspace**. With the sabotage above in place, `cargo test -p
|
||||
vfmt_server` passes **115 unit + 6 e2e, 0 failed**, and `cargo test
|
||||
lucisv_server` passes **115 unit + 6 e2e, 0 failed**, and `cargo test
|
||||
--workspace` passes **773, 0 failed** (770 + 3 scratch probes). Only a live
|
||||
stdio session caught it. `Document.tree` is now a cached derivation of
|
||||
`Document.text`, and nothing asserts they agree. The cheapest guard is one
|
||||
`#[cfg(test)]` case in `crates/vfmt_server/src/lint.rs` or `state.rs`:
|
||||
`#[cfg(test)]` case in `crates/lucisv_server/src/lint.rs` or `state.rs`:
|
||||
`set_document` a buffer whose module name mismatches the filename, then
|
||||
`set_document` the renamed text, and assert `violations` no longer contains
|
||||
`module-filename` — an AST-rule finding, which is exactly the class that
|
||||
|
||||
Reference in new issue
Block a user