Compare commits

...
4 Commits
Author SHA1 Message Date
Guoliang ChenandClaude Mythos 5.2 71d13b5fbe Release 0.66.2: every source file names its author
ci / checks (push) Successful in 1m0s
ci / corpus (push) Successful in 18s
ci / linux (push) Successful in 6m4s
release / build-and-publish (push) Successful in 5m31s
Every tracked file that can carry a comment (880 of them) now opens with
"Author: Guoliang Chen, a Senior Digital Design Engineer" and closes with
"Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love,
luciochen.com", in the file's own comment syntax. No behaviour change: the
diff outside the version bump and changelogs is comment lines only.

- tools/stamp_author.py: writes the lines; idempotent, `--check` lists
  what is missing. Headers go under a shebang and under Markdown front
  matter.
- Left alone: test fixtures, cases and snapshots (byte-exact inputs), JSON
  and JSONL, logs, images, lockfiles, docs/site/dist (regenerated) and the
  LICENSE files (already carry the copyright line).
- tools/linux_check.sh: --help reads its header from line 3, now that the
  author line sits under the shebang.
- tools/gates.sh green on this tree: 5 545 tests, corpus 814/6 as before.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-24 12:11:09 -08:00
Guoliang ChenandClaude Mythos 5.2 3823b85667 Release 0.66.1: sticky scroll pins the module instance
ci / checks (push) Successful in 57s
ci / corpus (push) Successful in 14s
ci / linux (push) Successful in 4m56s
release / build-and-publish (push) Successful in 5m17s
A multi-line module instantiation now answers folding ranges, so VS Code's
sticky scroll pins it (TODO §72, docs/features/instance-folding): one range
from the module-type line, and one more per instance from the line its name
is on when that is a later line, so both `aes_control_fsm #(` and
`) u_aes_control_fsm (` stay pinned inside the connection list. The closing
`);` line stays visible.

- folding/instances.rs: what is an instantiation comes from
  vlog_semantic::instantiations::sites; where it closes is re-read from the
  tokens, and a statement whose tokens are not exactly that shape folds
  nothing.
- folding.rs: in_answer_order is a stable sort by start line over scopes,
  branches, instances; every earlier fold is unchanged and first on a shared
  start line (0.66.0 against this tree on 4 933 files: identical once the
  instance folds are removed).
- OpenTitan hw: 18 200 multi-line instantiations, none without its fold.
- Not folded: two-dimensional instance arrays; an instance whose head an
  `ifdef splits.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-19 23:22:18 -08:00
Guoliang ChenandClaude Mythos 5.2 10cb6e020f Release 0.66.0: the overnight queue, complete
ci / checks (push) Successful in 57s
ci / corpus (push) Successful in 15s
ci / linux (push) Successful in 4m52s
release / build-and-publish (push) Successful in 5m18s
Closes TODO §71: eight owner-ordered features shipped as 0.65.2–0.65.11.
No engine change since 0.65.11.

- docs/topo.md refreshed through 0.65.11: contracts, server-lane edges,
  packaging rows, open handshakes 44–66, new modules, choke points; stale
  FACTS_FORMAT and state.rs references corrected.
- CLAUDE.md: file sizes re-measured.
- Feature READMEs: five stale facts corrected.
- large.rs: the two linear-time tests re-measure up to three times before
  failing (0.65.11's Linux CI run read 24.9x against a 24x limit under load).

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-19 21:01:14 -08:00
Guoliang ChenandClaude Mythos 5.2 cc1e2c8b72 Release 0.65.11: actions on the open file no longer wait for the workspace
ci / checks (push) Successful in 58s
ci / corpus (push) Successful in 15s
ci / linux (push) Failing after 4m33s
release / build-and-publish (push) Successful in 5m22s
A hover, definition, type definition, highlight, prepare-rename or signature
help on a name the file itself declares, and the outline, folding and
selection ranges, are answered from the open buffer ahead of a scan, a
rescan or a widen (server/ahead.rs, same_file.rs). The precondition is stated
once, on Server::answer_from_the_buffer; ahead::REACH lists the notifications
proved unable to change a buffer and everything else blocks.

Completion offers what the file can reach (imported package members,
inherited class members, included headers' macros) right after its own names
(completion/related.rs), and its answers are half the size (completion/wire.rs).

A new largeFile.threshold re-classifies buffers already open. The client's
answer to a settings pull is now ordered like a notification (amends
scan-ordering); colours answered while anything is held count as unsettled.

TODO 71.2. Four dev rounds, four QA rounds; the last ran with Fable 5.2 as
dev and QA after two QA failures. docs/features/fast-actions.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-19 20:52:22 -08:00
883 changed files with 11518 additions and 421 deletions

No files matched your search

+4
View File
@@ -1,3 +1,5 @@
# Author: Guoliang Chen, a Senior Digital Design Engineer
# CI: the three checks CLAUDE.md requires before any work is finished,
# plus the extension's JavaScript tests and the corpus gate, enforced on
# every push. Runs on the self-hosted macOS runner in host mode (no
@@ -64,3 +66,5 @@ jobs:
run: cargo clippy --all-targets -- -D warnings
- name: cargo test
run: cargo test --workspace
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
# Author: Guoliang Chen, a Senior Digital Design Engineer
# Release: pushing a tag `vX.Y.Z` builds every distribution artifact and
# publishes a Gitea release with the CHANGELOG section for that version as
# its notes. What the release page carries is the seven .vsix packages —
@@ -67,3 +69,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LUCISV_API_URL: ${{ vars.LUCISV_API_URL }}
run: tools/publish_release.sh "$GITHUB_REF_NAME" dist
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
# Author: Guoliang Chen, a Senior Digital Design Engineer
/target
/corpus
/corpus-check-results.tsv
@@ -8,3 +10,5 @@
/.zcode
/.claude
__pycache__/
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+137
View File
@@ -1,9 +1,144 @@
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
# Changelog
All notable changes to lucisv are recorded here. Versions follow
[semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes
(see `README.md`) are the only frozen contract.
## 0.66.2 — 2026-11-24
### Every source file names its author
- **No behaviour change.** Every tracked file that can carry a comment — 880
of them: the Rust sources, the extension's JavaScript, the scripts, the
manifests, the workflows and the documentation — now opens with an author
line and closes with one. The binaries and the formatter's, linter's and
language server's output are what 0.66.1 produced.
- `tools/stamp_author.py` writes the lines and is idempotent; run it after
adding files (`--check` lists what is missing). It leaves alone what a
comment would break or what is regenerated: test fixtures, cases and
snapshots, JSON and JSONL, logs, images, lockfiles, the built site under
`docs/site/dist` and the `LICENSE` files.
- `tools/linux_check.sh --help` reads its own header one line further down,
since the author line now sits under the shebang.
## 0.66.1 — 2026-11-19
### Sticky scroll pins the module instance
- **A module instantiation folds, so its header lines stay pinned** (TODO
§72, `docs/features/instance-folding`). `textDocument/foldingRange` answers
one range per multi-line instantiation from its module-type line, and one
more per instance from the line its name is on when that is a later line,
so both `aes_control_fsm #(` and `) u_aes_control_fsm (` are pinned while
the reader is in the connection list. The closing `);` line stays visible.
What is an instantiation comes from `vlog_semantic::instantiations::sites`;
where it closes is re-read from the tokens, and a statement whose tokens
are not exactly that shape folds nothing.
- Every fold answered before is unchanged and first on a shared start line
(0.66.0 against this tree on 4 933 files: 75 256 ranges identical once the
instance folds are removed). OpenTitan `hw`: 18 200 multi-line
instantiations, none without its fold. Worst file about 2 ms per request
(1.1 ms before).
- Not folded: two-dimensional instance arrays; an instance whose head an
`` `ifdef `` splits.
## 0.66.0 — 2026-11-19
### The overnight queue, complete
0.66.0 closes TODO §71: eight owner-ordered features, each shipped as its own
0.65.x release with a dev round, a QA round and the full gates. Nothing in
the engine changed between 0.65.11 and this release; it adds the topology
and size re-measurement (`docs/topo.md`, `CLAUDE.md`) and is the version to
install. Each line names the release that carries the detail below.
- **Editing and saving no longer re-index the workspace** (0.65.6/0.65.7).
A saved or changed file updates its own records and the files that depend
on it; only a change that can reach everything (a config, a filelist)
rescans.
- **Actions on the open file do not wait for the workspace** (0.65.11).
Hover, go-to-definition, highlights, the outline and folding for names the
file declares answer in milliseconds during a scan or a rescan, and
completion lists what the file can reach first.
- **Highlighting does not wait for the index** (0.65.10). Colours come from
the buffer at once, as a best guess for cross-file names, and are
corrected by one refresh when the index settles.
- **`` `ifdef `` / `` `else `` / `` `endif `` branches fold** and take part
in sticky scroll (0.65.4).
- **Formatter styles** (0.65.5): `auto` follows the file's own style, or
choose `lucisv`, `ansi`, `google`, `lowrisc`, `microsoft` or `nxp`; the presets are one readable
table in `vlog_formatter/src/style.rs`.
- **The module view marks where you are** (0.65.2): the current file's
module and its parents, in shades of orange.
- **Find References next to a name** (0.65.8): a caret just past a name's
last letter now finds it — the cause of "no references" that worked on a
second try — and edits arriving during a rescan are applied in order.
- **Comments are comments** (0.65.3): no bracket or code colouring inside
them, and `TODO`, `FIXME`, `FIX_ME`, `TBD` and your own words
(`lucisv.commentKeywords.custom`) are highlighted.
Also since 0.65.0: releases are gated by `tools/gates.sh`, which
compile-checks Windows and Linux (0.65.1, 0.65.7); CI runs the suite on
Linux as well as macOS, and `lucisv-mcp` no longer serves stale contents
after a same-instant rewrite (0.65.9).
One test change in this release: 0.65.11's Linux CI run failed on a
wall-clock test of the large-file path (24.9x measured against a 24x limit
on a loaded runner; nothing in that path had changed). The test now
re-measures up to three times before failing — a real quadratic regression
measures ~64x every time.
**Not yet seen in a running editor by a human** — every feature above was
verified through the server's protocol and the extension's tests, on
OpenTitan's `hw` tree. Open follow-ups are listed in TODO §71.
## 0.65.11 — 2026-11-19
### Actions on the open file no longer wait for the workspace
(`docs/features/fast-actions`; TODO §71.2. Measured on OpenTitan's `hw` tree
and on generated 20 000- and 40 000-file trees, with the server driven the
way VS Code drives it.)
- **Same-file answers come from the file.** A hover, a go-to-definition, a
type definition, highlights, a rename's first check or a signature help on
a name the file itself declares — and the outline, folding and selection
ranges — are answered from the open buffer at once, even while the index
is being built or rebuilt. Anything that might live in another file still
waits for the index it needs.
| hover on a local name (4 000 / 20 000 / 40 000 files) | 0.65.10 | now |
|---|---:|---:|
| during the startup scan | 547 / 665 / 831 ms | 2.4 / 1.5 / 1.9 ms |
| a new file triggers a rescan, request 5 ms later | 1.2 / 6.0 / 12.3 s | 47 / 167 / 321 ms |
| the same, request read together with the event | 1.2 / 6.0 / 12.3 s | 0.3 / 0.1 / 0.1 ms |
| the same, server busy with a previous delete | 1.3 / 7.0 / 14.3 s | 0.17 / 0.99 / 2.2 s |
- **Every early answer is the settled answer.** A request goes ahead only
when its buffer is open, every older message that could change the buffer
has been applied, its analysis is current, no settings are still on their
way, and the answer is the buffer's alone. 2.9 million early answers were
compared with the answer the finished index gives; none differed.
- **Completion keeps what the file can reach near the top.** Right after the
file's own names it now offers the members of the packages the file
imports, what its class inherits and the macros of the headers it
includes, so a huge workspace no longer pushes them out of the list; such
a name shows the icon and detail of the declaration the file actually
reaches. Completion answers are half the size for VS Code.
- **A new `lucisv.largeFile.threshold` applies to files already open,** the
editor's first settings answer included — not at each file's next edit.
- **Fixed on the way** (present since 0.65.8 and 0.65.10): the editor's
answer to a settings request could be applied ahead of an older settings
change or edit; colours answered while a file-watcher event was waiting
were not refreshed afterwards.
- **What it costs.** Until the editor has answered the server's first
settings request, same-file requests wait (the threshold may change how
the file is read): with an editor that takes 0.5 s to answer, the first
outline arrives after 515 ms — it was 1 043 ms on 0.65.10.
- **Still to come.** Not yet seen in a running editor by a human.
## 0.65.10 — 2026-11-19
### Highlighting no longer waits for the index
@@ -3326,3 +3461,5 @@ compiler directive any more. Details:
[macro items](docs/features/macro-items/README.md),
[directives in lists](docs/features/directives-in-lists/README.md) and
[in instances](docs/features/directives-in-instances/README.md).
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
+14
View File
@@ -1,3 +1,5 @@
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
# CLAUDE.md — rules for all agents working on lucisv
lucisv is a ruff-style Verilog/SystemVerilog formatter/linter in Rust.
@@ -89,6 +91,16 @@ Re-measured 2026-10-14 after TODO §55 (pure move, `docs/features/decomposition-
files over 600 workspace-wide: `lucisv_server/src/perf.rs` 907 (reasoned),
`vlog_parser/src/lexer.rs` 771, `vlog_formatter/src/format/stmt.rs` 604.
Re-measured 2026-11-19 at 0.66.0, after the overnight queue (TODO §71; non-blank,
non-comment lines before `mod tests`): two files over 600 — `perf.rs` 907
(reasoned) and `lexer.rs` 771 — then `vlog_semantic/src/resolve.rs` 587 and
`vlog_parser/src/parser/item.rs` 582, both at the mark: the next addition to
either goes in a new module. The queue's new modules are all small
(`server/ahead.rs`, `same_file.rs`, `completion/related.rs`, `server/viewport.rs`,
`server/caret.rs`, `state/watched.rs`, `folding/directives.rs`, formatter
`style.rs` / `auto.rs`); `server/dispatch.rs` is 503 and `server/index.rs`
is where four of the eight features met.
## Rust standards
- `cargo fmt` clean, `cargo clippy --all-targets` clean (no `#[allow]`
@@ -215,3 +227,5 @@ proven independent and run serially. Rules for a parallel wave:
not actually independent, which is a planning failure to record.
- After merging, the lead updates `docs/topo.md` for any edge a lane added
or amended, so the next wave plans against reality.
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
Generated
+9 -9
View File
@@ -97,7 +97,7 @@ dependencies = [
[[package]]
name = "lucisv"
version = "0.65.10"
version = "0.66.2"
dependencies = [
"lucisv_core",
"rayon",
@@ -108,11 +108,11 @@ dependencies = [
[[package]]
name = "lucisv_core"
version = "0.65.10"
version = "0.66.2"
[[package]]
name = "lucisv_mcp"
version = "0.65.10"
version = "0.66.2"
dependencies = [
"lucisv_core",
"serde",
@@ -126,7 +126,7 @@ dependencies = [
[[package]]
name = "lucisv_server"
version = "0.65.10"
version = "0.66.2"
dependencies = [
"lsp-server",
"lsp-types",
@@ -262,14 +262,14 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "vlog_formatter"
version = "0.65.10"
version = "0.66.2"
dependencies = [
"vlog_parser",
]
[[package]]
name = "vlog_linter"
version = "0.65.10"
version = "0.66.2"
dependencies = [
"lucisv_core",
"vlog_formatter",
@@ -279,11 +279,11 @@ dependencies = [
[[package]]
name = "vlog_parser"
version = "0.65.10"
version = "0.66.2"
[[package]]
name = "vlog_refactor"
version = "0.65.10"
version = "0.66.2"
dependencies = [
"vlog_formatter",
"vlog_parser",
@@ -292,7 +292,7 @@ dependencies = [
[[package]]
name = "vlog_semantic"
version = "0.65.10"
version = "0.66.2"
dependencies = [
"vlog_parser",
]
+5 -1
View File
@@ -1,3 +1,5 @@
# Author: Guoliang Chen, a Senior Digital Design Engineer
[workspace]
resolver = "2"
members = [
@@ -13,7 +15,7 @@ members = [
]
[workspace.package]
version = "0.65.10"
version = "0.66.2"
authors = ["Guoliang Chen"]
edition = "2021"
license = "MIT"
@@ -44,3 +46,5 @@ serde_json = "=1.0.140"
[profile.release]
lto = true
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
# lucisv — Language Utility for Coding In SystemVerilog
A Verilog and SystemVerilog formatter, linter, and language server written in Rust.
@@ -1145,3 +1147,5 @@ where the version number lives, how the `.vsix` is packaged, and what
marketplace publishing would take if it ever happens — is in
[`tools/RELEASING.md`](tools/RELEASING.md). lucisv is MIT licensed
([`LICENSE`](LICENSE)).
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
+4
View File
@@ -1,3 +1,5 @@
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
# ROADMAP — autonomous coverage loop
Running log of the coverage-improvement loop (started 2026-08-20). The metric
@@ -175,3 +177,5 @@ needs macro expansion, a deliberate non-goal) or not valid standalone
Verilog. The stop condition holds before round 1 of a restart, so **no dev
round was dispatched**. The loop resumes only if open question 2 is decided
(a preprocessing model would put ~1.7% back in reach) or the corpus grows.
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
+4
View File
@@ -1,3 +1,5 @@
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
# TODO-MCP — the Model Context Protocol block
Planned 2026-09-23 by the lead at 0.55.0. The analysis and design are in
@@ -498,3 +500,5 @@ Feature README `docs/features/mcp-read-only`. One dev (Opus), one QA
item's lines through `format_range` automatically — costs a refusal
path when the safety net objects. Default in this plan: not automatic;
the agent calls `format` with `lines`.
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
+48 -2
View File
@@ -1,3 +1,5 @@
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
# TODO — best practices adopted from ruff and Verible
Curated backlog for lucisv, drawn from `astral-sh/ruff` (architecture, CLI/UX,
@@ -7319,7 +7321,7 @@ subsection, plan and `docs/features/<name>/README.md` when its turn comes.
Today every
file edit re-indexes everything. A change to a `define` may have to;
a typical, localized edit must not.
- [ ] **71.2 Actions stay fast on a huge, heavily-dependent tree.** Do the
- [x] **71.2 Actions stay fast on a huge, heavily-dependent tree.** (0.65.11, `docs/features/fast-actions`) Do the
work dynamically: answer first from what is already in the same file
(hover to a definition in this file), and use the relationship map to
load completion candidates on demand.
@@ -7350,7 +7352,7 @@ subsection, plan and `docs/features/<name>/README.md` when its turn comes.
`signal[]` gets highlighted today), **but do highlight `TODO`,
`FIXME`, `FIX_ME`, `TBD`**, plus a user setting for custom words that
are highlighted only in comments.
- [ ] **71.9 Release `0.66.0`** once 71.1–71.8 have each shipped.
- [x] **71.9 Release `0.66.0`** once 71.1–71.8 have each shipped.
### 71 — wave 1 (lead, 2026-11-19): 71.6 runs beside §70
@@ -7482,3 +7484,47 @@ indexing, collide with each other and with §70's test files, and wait for
costs one refresh at settle even when nothing changed.
- [ ] An edit in one file that changes how another OPEN file colours sends
no refresh (as before this lane).
- Wave 8 (lead, 2026-11-19): 71.2 shipped as 0.65.11 after four dev rounds
and four QA rounds — two QA failures, so the last round ran with Fable 5.2
as dev and QA (`docs/features/fast-actions`, Review). Left open from it:
- [ ] Inside the startup settings wait, the client's answer to the pull is
applied ahead of an older settings push held with it
(`server/startup.rs`, `take_the_answer_out_of_held`; predates the
lane; needs a client whose push and answer disagree in one burst).
- [ ] `tests/fast_actions_bursts.rs`'s oracle accepts an answer the
reference gives after any later message of the round: 2–9 % of
injected stale answers pass when a later message restores the state.
- [ ] Whether a large open buffer is in the index depends on when it was
opened, saved or scanned (predates the lane; 77–98 answers differ
between a settled session and a fresh server on OpenTitan).
- [ ] The 40 000-file rescan after a delete takes either 12.3 s or
14.5–15.5 s, on 0.65.10 and on this tree alike; cause not found.
## 72. Sticky scroll pins the module instance (planned 2026-11-19, owner's order)
Owner: "only the module definition is floating. I want to extend this a
little so that the module instance would be floating as well." Folds come
only from keyword pairs and `` `ifdef `` branches, so nothing delimited by
`( )` pins. Surveyed on OpenTitan `hw` (4 047 files): 162 instances of 50+
lines, none pinned; 132 of them write `#(` on the type line, so the instance
name sits on a later `) u_name (` line. Example:
`hw/ip/aes/rtl/aes_control_fsm_n.sv:382-594`. One lane (dev, then QA),
feature README `docs/features/instance-folding/README.md`.
- [x] `crates/lucisv_server/src/folding/instances.rs` (new): one fold per
multi-line module instantiation from its module-type line, and one more
per instance from the line its name is on when that is a different
line, so both `aes_control_fsm #(` and `) u_aes_control_fsm (` pin
while the reader is in the connection list. The closing line stays
visible, as for every scope fold.
- [x] `crates/lucisv_server/src/folding.rs`: the third source merged through
`in_answer_order`; every fold the server answered before is still
there, unchanged and first on a shared start line.
- [x] Tests in the same change, and `folding/opentitan_sweep.rs` extended:
instances counted independently, existing folds proven unchanged.
- [x] `editors/vscode/README.md`: the sticky-scroll row names the instance.
- [x] Seen in a running VS Code (owner, 2026-11-19, on the local 0.66.1
build). Shipped as 0.66.1.
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
+4
View File
@@ -1,3 +1,5 @@
# Author: Guoliang Chen, a Senior Digital Design Engineer
[package]
name = "lucisv"
version.workspace = true
@@ -15,3 +17,5 @@ vlog_parser = { path = "../vlog_parser" }
vlog_formatter = { path = "../vlog_formatter" }
vlog_linter = { path = "../vlog_linter" }
rayon = { workspace = true }
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Hand-rolled command line parsing for the `lucisv` binary.
use lucisv_core::cache;
@@ -751,3 +753,5 @@ mod tests {
assert!(!parse(&["check", "rtl"]).unwrap().rules_doc);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,5 +1,9 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `--diff`'s unified diff. The printer lives in `lucisv_core::diff`, shared
//! with the MCP server's `dry_run` (Handshake MCP-1, a pure move); this module
//! keeps the CLI's `diff::unified` path.
pub use lucisv_core::diff::unified;
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The `lucisv check` driver: lint files, print diagnostics, apply fixes.
//!
//! Everything about *which* files are linted — the walk, `--exclude`,
@@ -880,3 +882,5 @@ mod tests {
assert_eq!(quote("bell\u{7}"), "\"bell\\u0007\"");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! lucisv — a Verilog/SystemVerilog formatter and linter in the spirit of
//! `ruff format` and `ruff check`.
//!
@@ -666,3 +668,5 @@ mod tests {
assert!(err.contains("parse error"), "{err}");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! End-to-end tests that drive the real `lucisv` binary.
//!
//! Fixtures use the most trivial Verilog possible so these tests stay
@@ -2463,3 +2465,5 @@ fn text_that_merely_says_package_changes_no_finding() {
"{plain}\n---\n{with_noise}"
);
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `--style` and `[format] style` through the real `lucisv` binary: the
//! flag, the config key, their precedence over each other and under the
//! explicit `indent`/`line-length`, the error for a name that is not a
@@ -169,3 +171,5 @@ fn changing_the_style_invalidates_the_cache_entry() {
let out = run(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 1, "{}", stderr(&out));
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
# Author: Guoliang Chen, a Senior Digital Design Engineer
[package]
name = "lucisv_core"
version.workspace = true
@@ -10,3 +12,5 @@ name = "lucisv_core"
path = "src/lib.rs"
[dependencies]
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Replacing a file's contents without ever leaving it half written.
//!
//! `fs::write` truncates the target and then writes into it, so a crash, a
@@ -449,3 +451,5 @@ mod tests {
assert_eq!(fs::metadata(&target).expect("stat").permissions().mode() & 0o777, 0o600);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The "already formatted" cache: a per-path record of content that a
//! previous run verified is a fixed point, so a repeat run can skip the
//! file entirely.
@@ -539,3 +541,5 @@ mod tests {
assert!(!Cache::load(&dir.path).is_clean(&weird, entry(1)));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `lucisv.toml` / `.lucisv.toml` discovery and its TOML-subset parser.
//!
//! Only what a small config file needs is supported (comments, `key = int`,
@@ -987,3 +989,5 @@ exclude = [ \"build\", \"*_gen.sv\", ]
assert_eq!(discovery.for_file(Path::new("y.sv")).unwrap().indent, Some(4));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! A small line-oriented unified diff: the CLI's `--diff` and the MCP
//! server's `dry_run` print the same hunks through this one function.
//! Moved here from `crates/lucisv/src/diff.rs` unchanged (Handshake MCP-1,
@@ -219,3 +221,5 @@ mod tests {
assert!(d.contains("-a\n-b\n+x\n+y\n"), "{d}");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! EDA filelist (`-f`) parsing: the project file every Verilog build
//! already has.
//!
@@ -591,3 +593,5 @@ missing.sv
assert_eq!(list.warnings.len(), 2, "{:?}", list.warnings);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The parts of lucisv that decide *which* files are processed and *with what
//! settings*, shared by the `lucisv` CLI and the `lucisv-server` language server.
//!
@@ -20,3 +22,5 @@ pub mod config;
pub mod diff;
pub mod filelist;
pub mod walk;
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! File discovery: directory walking, `--exclude` matching and the
//! `.gitignore` subset documented in
//! `docs/features/parallel-files/README.md`.
@@ -1103,3 +1105,5 @@ mod tests {
assert!(!tracker.has_conflict());
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
# Author: Guoliang Chen, a Senior Digital Design Engineer
[package]
name = "lucisv_mcp"
version.workspace = true
@@ -21,3 +23,5 @@ vlog_formatter = { path = "../vlog_formatter" }
vlog_linter = { path = "../vlog_linter" }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The one write path every edit tool goes through.
//!
//! A tool hands over a [`Plan`] — per file, the text it computed against and
@@ -361,3 +363,5 @@ mod tests {
fs::remove_dir_all(dir).unwrap();
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The index caches a startup reads instead of parsing (PLAN §6): the
//! language server's `index-cache`, **read only, never written**, and this
//! server's own `index-cache-mcp` beside it, in the same codec, written once
@@ -221,3 +223,5 @@ fn store_lines(bytes: &[u8]) -> Vec<&[u8]> {
#[cfg(test)]
mod tests;
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The caches against the rebuild oracle: an index started from records is
//! the index a cold build over the same files makes
//! (`WorkspaceIndex::fingerprint`), and every record that is not exactly
@@ -141,3 +143,5 @@ fn a_record_filed_under_another_path_or_hash_is_not_taken() {
assert!(parse("0000000000000007\tx").is_none(), "no checksum");
assert!(parse("7\tx\t0000000000000000").is_none(), "a hash of the wrong width");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `lucisv-mcp` — lucisv as a Model Context Protocol server, over stdio.
//!
//! A coding agent (Claude Code, Cursor, VS Code's agent mode) spawns this
@@ -142,3 +144,5 @@ mod tests {
assert_eq!(parse(&[]).unwrap(), Options::default());
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! One file, fully analyzed, and a small cache of them keyed by content.
//!
//! The index answers workspace questions without keeping any file's text;
@@ -140,3 +142,5 @@ mod tests {
assert!(cache.get(Path::new("a"), 1).is_none());
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Which files the project is made of, and what each one looked like when it
//! was last read: the filelist-or-walk ladder of PLAN §4.4 over
//! `lucisv_core`, and the per-file stamp the freshness sweep compares against.
@@ -508,3 +510,5 @@ mod tests {
}
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The project one server answers about: its roots, its files, the workspace
//! index over them, and the promise that no answer is older than the disk
//! was when the call arrived (PLAN §4.4).
@@ -359,3 +361,5 @@ fn relative_to(roots: &[PathBuf], path: &Path) -> String {
#[cfg(test)]
mod tests;
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The freshness promise, against the rebuild oracle: after every update
//! path the incrementally maintained index is the index a full build over
//! the files now on disk produces (`WorkspaceIndex::fingerprint`).
@@ -106,3 +108,5 @@ fn a_path_argument_must_land_inside_a_root() {
fs::remove_dir_all(dir).unwrap();
fs::remove_dir_all(outside).unwrap();
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The rendering rules every tool's text answer follows (PLAN §10.2): the
//! token budget is the product.
//!
@@ -205,3 +207,5 @@ mod tests {
assert_eq!(by_file(&sites), ["b.sv:3,9", "a.sv:1"]);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The `lucisv://` resources: the project overview, the lint rule
//! reference, one unit's outline and one file's outline — the same answers
//! `hierarchy` and `outline` give, addressable by URI for a host that
@@ -176,3 +178,5 @@ mod tests {
}
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The JSON-RPC 2.0 envelope and the MCP methods this server answers: the
//! `initialize` handshake and its version negotiation, `ping`, the tool
//! methods, the `lucisv://` resources, and an empty prompt list.
@@ -421,3 +423,5 @@ mod tests {
assert!(bad_tool["error"]["message"].as_str().unwrap().contains("nope"));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The declarations the files' own symbol tables hold — every one the
//! semantic model knows and `outline` lists: typedefs, enum values,
//! functions, tasks, genvars, generate blocks and what they declare,
@@ -94,3 +96,5 @@ fn unit_at(items: &[Item], span: TextRange) -> Option<&str> {
let inner = child_items(&item.kind).into_iter().find_map(|items| unit_at(items, span));
inner.or(own.filter(|(_, name_span)| *name_span != span).map(|(name, _)| name))
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `check`: what `lucisv check` would say about one file or the whole
//! design — the tolerant parse's errors, then the lint findings — one line
//! each, `file:line:col severity message [rule]`, errors first.
@@ -325,3 +327,5 @@ impl MentionOracle for Mentions<'_> {
PackageExports::exports(self.index, package)
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `rename`, and what every design-wide edit shares: the whole-set read the
//! engines are handed, and the step from a verified `RefactorEdit` to a
//! written plan with the name's unresolved mentions listed.
@@ -221,3 +223,5 @@ fn written_ranges(edits: &[TextEdit]) -> Vec<TextRange> {
}
out
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `find`: where a name is declared and, on `refs`, where each declaration
//! is used — the question an agent otherwise answers by grepping and
//! reading. Declarations come from the index (`names.rs`); uses from
@@ -197,3 +199,5 @@ mod tests {
}
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `format`: the CLI's `lucisv format` over a path or a glob, and with
//! `fix` the CLI's `lucisv check --fix` first — each file through the one
//! write path (`apply.rs`).
@@ -218,3 +220,5 @@ mod tests {
assert!(formatter_config(&auto).auto_style);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Path globs, as `format`'s `files` takes them: `*` and `?` within one
//! path component, `**` for any run of components, and a bare directory
//! for everything below it — the `.gitignore` / `rg -g` reading.
@@ -100,3 +102,5 @@ mod tests {
assert!(!path_match("ip/**", "hw/ip/aes.sv"));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `hierarchy`: the project's shape. Without a `root`, the counts and the
//! top modules; with one, the instance tree down from it or every
//! instantiation of it up to `depth` levels — read off the index's
@@ -369,3 +371,5 @@ fn statement(project: &Project, texts: &mut Texts, child: &Child) -> Vec<String>
}
out
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `outline unit:` — what a unit offers the code that uses it: a module's
//! or interface's parameters and ports in declaration order (plus an
//! interface's modports), a package's or class's members — without the
@@ -228,3 +230,5 @@ fn class_base(items: &[Item], name_span: TextRange) -> Option<String> {
}
child_items(&item.kind).into_iter().find_map(|items| class_base(items, name_span))
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `edit_item` — the structural edits under one name (`replace`,
//! `insert_before`, `insert_after`, `delete`), the general token saver: an
//! agent sends one item's text, never the file.
@@ -373,3 +375,5 @@ fn end_spot(analysis: &Analysis, unit: &str, file: &str) -> Result<Spot, String>
/// The keywords that close a unit `end` may name.
const END_WORDS: &[&str] = &["endmodule", "endinterface", "endprogram", "endpackage", "endclass"];
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The verifier's lexical rules — what a splice may do to the token stream
//! and its comments, before any parse is asked:
//!
@@ -173,3 +175,5 @@ fn markers(tokens: &[Token], start: u32, end: u32) -> Vec<&str> {
.map(|e| e.text.trim())
.collect()
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `op: delete`'s macro rule: a name spelled inside a macro call's
//! arguments (`` `ASSERT_KNOWN(k, sig) ``) or a `` `define`` body is a use
//! no lucisv engine resolves — the lexer keeps a macro call as one token and
@@ -106,3 +108,5 @@ mod tests {
assert!(spellings("`define S \"sig\"\n", "sig").is_empty(), "a string is not a use");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `edit_item op: delete`'s reference rule: an item is not deleted while a
//! name it owns (`verify::owned`) is still used anywhere in the project.
//!
@@ -260,3 +262,5 @@ fn position(project: &Project, set: &WholeSet, file: &Path, span: TextRange) ->
let (line, col) = LineIndex::new(text).line_col(span.start);
format!("{}:{line}:{col}", project.relative(file))
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Which bytes an item owns: the lines `edit_item`'s inserts and deletes
//! work on, and the span its `replace` replaces when its text brings comments.
//!
@@ -155,3 +157,5 @@ mod tests {
assert_eq!(slice(replace_region(src, item, "logic b;\n// own line")), "logic a;");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `op: delete`'s implicit-connection rule: a `.*` binds a signal without
//! spelling it, so `find_references` (which returns only spans that spell
//! the name) never lists it. For each deleted name, every `.*`
@@ -94,3 +96,5 @@ fn binds(index: &WorkspaceIndex, module: &str, name: &str) -> Option<bool> {
}
Some(index.member(module, name).iter().any(|def| def.kind == SymbolKind::Port))
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The verifier the three structural edits share — the one new piece of
//! logic in the MCP block, so it is guilty until proven innocent: every rule
//! here has an attack in `tests/attacks.rs`.
@@ -573,3 +575,5 @@ mod tests {
assert!(owned_names(&analysis, always).is_empty());
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Unresolved mentions: every whole-word spelling of a name that no engine
//! answer accounted for and that sits where no lucisv engine looks — inside
//! a string literal, a comment, a macro call's text, a `` `define`` body, or
@@ -345,3 +347,5 @@ mod tests {
assert_eq!(shared_components(a, b), 4);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The tool registry: every tool's name, description, argument list and
//! handler, in one table. The argument list is the single source of both the
//! `inputSchema` a host shows the agent and the validation a call's
@@ -313,3 +315,5 @@ mod tests {
assert_eq!(schema(hierarchy.params)["properties"]["depth"], json!({"type": "integer"}));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Names looked up — the by-name half every lean tool shares: every
//! declaration of a name (the index's units, exported members and module
//! internals, every declaration the files' own symbol tables hold, and the
@@ -232,3 +234,5 @@ mod tests {
assert_eq!(qualified(".x"), (None, ".x"));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `outline`: a file's declarations as a tree with line ranges (its parse
//! errors first), or — for `unit` — what a unit offers the code that uses
//! it (`interface.rs`), so an agent reads the shape before the source.
@@ -59,3 +61,5 @@ fn tree(analysis: &Analysis, nodes: &[DocumentSymbol], level: usize, out: &mut V
tree(analysis, &node.children, level + 1, out);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `port`'s `after`: the new port placed right after a named one, in the
//! layout of the line it follows, and each named connection placed right
//! after the instance's `.after(…)`.
@@ -446,3 +448,5 @@ mod tests {
assert_eq!(appended_expr(".e(x)", "d"), None);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Where a new list element goes after its anchor, and how it is written.
//!
//! The element always goes **after the separator that follows the anchor**
@@ -304,3 +306,5 @@ mod tests {
assert_eq!(split_declaration("input dbg_i").unwrap().ty, "");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The check a placement must pass before anything is written: the placed
//! edit is the engine's verified edit with elements **moved and nothing
//! else**. Per file, against the engine's result:
@@ -308,3 +310,5 @@ mod tests {
);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `port`: add a port to a module and connect it by name in every
//! instantiation, or remove one and its connection everywhere — the
//! design-wide edit a file write cannot do safely. `add` is
@@ -144,3 +146,5 @@ fn instantiations(project: &Project, module: &str) -> (usize, usize) {
let files: BTreeSet<_> = edges.iter().map(|edge| edge.file).collect();
(count, files.len())
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `read`: one item's exact source — a slice, never the file — preceded by
//! `file:first–last`. In a named `file` the item is sliced as
//! `read_item::select` slices it; without one the name is looked up
@@ -78,3 +80,5 @@ fn locate(project: &mut Project, selector: &str) -> Result<PathBuf, String> {
}
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The item slicer `read` and `edit_item` share: one item's exact span in
//! a file — a module, a function, a declaration, an instance, or an
//! unlabelled `always` block named by the line it covers.
@@ -317,3 +319,5 @@ module n; logic q; endmodule
assert!(refused.contains("`\\b` on line 12"), "{refused}");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Declaration sites read back off the disk: `find` and the by-name tools
//! answer with `file:line` for declarations in files no analysis is held
//! for. One read per file per call ([`Texts`]); the index's spans are
@@ -271,3 +273,5 @@ mod tests {
assert_eq!(capped("x y", 3), "x y");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The MCP stdio transport: one JSON-RPC message per line in, one per line
//! out. stdout carries protocol lines and nothing else; stderr is the log.
//!
@@ -93,3 +95,5 @@ mod tests {
assert_eq!(written, "{\"text\":\"a\\nb\"}\n");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The dev's attack suite on the structural edits' verifier (lane M4) —
//! CLAUDE.md invariant 4 applied to the MCP block's own safety net: every
//! case is an edit the verifier could plausibly let through, asserted
@@ -784,3 +786,5 @@ fn a_signal_bound_by_a_dot_star_is_still_referenced() {
let clk = json!({"file": "rtl/sw.sv", "item": "clk"});
refused(&tree, &mut server, "delete_item", clk, "bound by `.*` at rtl/sw.sv:7:18 `clk`");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The index caches over the wire (TODO-MCP M6, PLAN §6): the language
//! server's `index-cache` is read and never written — its bytes are hashed
//! before and after a whole session that indexes, answers and edits — every
@@ -276,3 +278,5 @@ fn an_unwritable_cache_directory_still_answers_and_says_so_on_exit() {
assert_eq!(stderr.matches("cannot write the index cache").count(), 1, "{stderr}");
assert!(fs::read_dir(scratch.cache()).unwrap().next().is_none(), "nothing was written");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The `hierarchy` cap counts instances, never `peek` lines (census round 5,
//! 2026-09-29): an agent asking for every instantiation of a module with
//! `peek` gets every one up to 100 (300 without `peek`), each with its
@@ -135,3 +137,5 @@ fn over_100_instances_with_peek_shows_100_and_over_300_without_shows_300() {
assert_eq!(plain.lines().count(), 301);
assert!(plain.ends_with("\n… and 51 more\n"), "{plain}");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The opentitan census (TODO-MCP M2, ported to the lean catalogue in M7):
//! `find`, `hierarchy`, `check` and `outline` over a real checkout,
//! read-only, each answer checked against what the language server answers
@@ -288,3 +290,5 @@ fn opentitan_startup_cold_and_warm_and_the_stat_sweep() {
let _ = std::fs::remove_dir_all(&cache);
assert_eq!(status(&root), before, "the checkout was only read");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! QA attacks on lane feedback-1 (unresolved mentions, `add_port`'s `after`
//! and its move-checker, the trimmed catalogue, the temp-store sweep),
//! 2026-09-23 — ported to the lean catalogue: `add_port` is `port` with
@@ -696,3 +698,5 @@ fn qa_the_sweep_takes_only_old_files_of_the_exact_temp_name() {
}
assert!(dir.join("inside").is_dir(), "a directory is never swept");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! QA attacks on lane feedback-2 (the count line on every paged answer, the
//! `in` path glob, the post-edit check line), 2026-09-23 — ported to the
//! lean catalogue: paging, `in` and the check line are gone (PLAN §10.2),
@@ -282,3 +284,5 @@ fn qa_the_glob_matches_paths_never_names_even_escaped_ones_holding_a_star() {
assert_eq!(formatted("esc/*.sv"), "1");
assert!(formatted("\\esc*mod").contains("\\esc*mod"), "a unit name is not a path");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! QA attacks on lane M1 (transport + read tools), 2026-09-23.
//!
//! Every test spawns the real binary over a scratch tree, as a host would.
@@ -954,3 +956,5 @@ fn qa_rework_a_rename_over_with_an_old_mtime_and_the_same_size_is_seen() {
set_mtime(&scratch.path("c.sv"), long_ago);
assert_eq!(s.text("find", json!({"name": "chyrlie"})), "module chyrlie c.sv:1\n");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! QA attacks on lane M2 (navigation, diagnostics, defines, resources),
//! 2026-09-23 — ported to the lean catalogue (`find`, `hierarchy`, `check`;
//! `docs/features/mcp-lean-catalogue/README.md` lists what was deleted: the
@@ -796,3 +798,5 @@ fn qa_recheck_one_files_check_is_its_lines_of_lucisv_check_dot() {
);
assert_eq!(s.text("check", json!({"file": "leaf.sv"})), "ok\n");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! QA attacks on lane M3 (the edit tools and their one write path),
//! 2026-09-23 — ported to the lean catalogue (`rename`, `port`,
//! `edit_item`, `format`); the tools it dropped took their attacks with
@@ -1226,3 +1228,5 @@ fn qa_a_large_file_behind_a_link_out_of_the_root_is_not_in_the_skipped_set() {
let text = text_of(&server.rename_d());
assert!(!text.contains(outside.root()), "{text}");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! QA attacks on lane M4 (the structural edits and their verifier),
//! 2026-09-23.
//!
@@ -1308,3 +1310,5 @@ fn qa_recheck_a_define_item_may_be_inserted_but_not_nested_in_an_always() {
}
assert!(strict(&tree.read("rtl/d.sv")));
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! QA attacks on lane M6 (the index caches and the rule-6 ruling),
//! 2026-09-23.
//!
@@ -702,3 +704,5 @@ fn qa_the_instructions_are_short_and_name_only_real_tools() {
assert!(text.contains(phrase), "{phrase}: {text}");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! QA attacks on lane M7 (the lean catalogue), 2026-09-24.
//!
//! Every test writes a small design into its own scratch directory, spawns
@@ -867,3 +869,5 @@ fn a_members_rename_lists_only_its_own_mentions_and_dotted_ones_elsewhere() {
let found = text(&tree, "find", json!({"name": "p.W", "refs": true}));
assert!(found.contains("unresolved:\n rtl/u.sv:2\n"), "a package member lists all: {found}");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! QA attacks on lane M8 (`--read-only`), 2026-09-29.
//!
//! Every test copies a fixture into its own scratch directory, spawns the
@@ -562,3 +564,5 @@ fn qa_the_node_cap_is_exact_at_300_and_301_plain_and_100_and_101_with_peek() {
}
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `lucisv-mcp --read-only` (PLAN §11), pinned against the real binary: the
//! five read tools within their budget, the edit tools unknown, full mode as
//! 0.58.0 shipped it, and the promise that nothing inside a root is created,
@@ -339,3 +341,5 @@ fn the_edit_calls_write_in_full_mode() {
assert_ne!(before, snapshot(&tree), "{name} wrote nothing in full mode");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The wire contract, pinned against the real binary: each test copies the
//! fixture design into its own temporary directory, spawns `lucisv-mcp` over
//! it and talks newline-delimited JSON-RPC to it, as a host would.
@@ -1264,3 +1266,5 @@ fn a_stale_temp_store_is_swept_and_a_young_one_and_other_files_are_spared() {
assert!(young.exists(), "a young one may be a live writer's");
assert!(other.exists(), "only `<store>.<pid>.tmp` is ours to sweep");
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
# Author: Guoliang Chen, a Senior Digital Design Engineer
[package]
name = "lucisv_server"
version.workspace = true
@@ -19,3 +21,5 @@ lsp-server = { workspace = true }
lsp-types = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The preset `style = "auto"` last settled on, per document.
//!
//! Under `auto`, every formatting request needs a concrete preset, and
@@ -402,3 +404,5 @@ endmodule
assert_eq!(styles.recall(&uri), None, "a whole-document format under a named style");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+5 -1
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The tables a completion request reads instead of walking the workspace.
//!
//! Completion fires on every keystroke, so nothing here may be computed per
@@ -843,7 +845,7 @@ fn macros_of(index: &WorkspaceIndex) -> Vec<Macro> {
}
/// One `` `define``'s completion entry.
fn macro_of(define: &vlog_parser::defines::Define) -> Macro {
pub(crate) fn macro_of(define: &vlog_parser::defines::Define) -> Macro {
let args = match &define.params {
Some(params) => format!("({})", params.join(", ")),
None => String::new(),
@@ -1670,3 +1672,5 @@ mod tests {
}
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Which byte a "symbol under the cursor" request is about.
//!
//! An LSP position is a caret *between* two characters, and a span here is
@@ -125,3 +127,5 @@ mod tests {
assert_eq!(lands_on("é|;"), Some(';'), "a non-ASCII letter is not a name");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `textDocument/codeAction` — one quick fix per Safe lint fix, plus one
//! `source.fixAll.lucisv` that applies all of them in a single pass.
//!
@@ -476,3 +478,5 @@ mod tests {
);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Tiers 2 and 3: what the buffer being typed in declares, and the words it
//! uses (TODO §68.1, `completion-ux`).
//!
@@ -142,3 +144,5 @@ endmodule
assert!(sort("al_used") < sort("always_ff"));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! What a connection-list entry inserts (TODO §68.1, `completion-ux`).
//!
//! After the `.` of `sub u_sub (.cl|` or `sub #(.WI|`, accepting a port or a
@@ -100,3 +102,5 @@ mod tests {
assert!(!paren_follows(".cl, .b(x)", 1));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The completion tests' harness: a scratch workspace on disk, and the
//! handful of helpers every provider's tests ask through.
//!
@@ -112,3 +114,5 @@ pub(super) fn find<'a>(items: &'a [CompletionItem], label: &str) -> Option<&'a C
pub(super) fn labels(items: &[CompletionItem]) -> Vec<&str> {
items.iter().map(|item| item.label.as_str()).collect()
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The member answer: after a `.` or a `::`, the members of what stands
//! before it and nothing else.
//!
@@ -1203,3 +1205,5 @@ endmodule
assert!(items.iter().any(|i| tier(i) == TIER_WORD || tier(i) == TIER_KEYWORD));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+33 -6
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! `textDocument/completion` — module hinting, templates, keywords, and every
//! name the project uses.
//!
@@ -79,6 +81,7 @@ use buffer::{buffer_word_tier, declared_tier};
use connection::Connection;
use member::member_answer;
use module::module_tier;
use related::{related_macros, related_tier};
use site::{at_module_item, at_statement, enclosing_scopes};
use tiers::{index_tier, keyword_tier, scope_tier, template_tier, word_tier};
use word::typed_word;
@@ -90,6 +93,7 @@ pub(crate) use module::{nearest_definition, plan_for};
pub(crate) use module::module_header;
pub(crate) use site::at_instantiation_site;
pub(crate) use tiers::layout_at;
pub(crate) use wire::{item_defaults_support, with_item_defaults};
mod buffer;
mod connection;
@@ -97,8 +101,10 @@ mod connection;
mod harness;
mod member;
mod module;
mod related;
mod site;
mod tiers;
mod wire;
mod word;
/// How many items one response carries, over every tier.
@@ -151,10 +157,14 @@ const TIER_SCOPE: char = '1';
/// (`completion-ux`, TODO §68.1).
const TIER_DECLARED: char = '2';
const TIER_BUFFER_WORD: char = '3';
const TIER_INDEX: char = '4';
const TIER_TEMPLATE: char = '5';
const TIER_KEYWORD: char = '6';
const TIER_WORD: char = '7';
/// What the file is related to — the packages it imports, the classes its
/// class extends, the headers it includes — below the file itself and above
/// the rest of the workspace (`related.rs`).
const TIER_RELATED: char = '4';
const TIER_INDEX: char = '5';
const TIER_TEMPLATE: char = '6';
const TIER_KEYWORD: char = '7';
const TIER_WORD: char = '8';
/// What a multi-line item tells the client about its own whitespace.
///
@@ -205,6 +215,7 @@ pub fn completions(
// The backtick itself is replaced, so the item may carry its own.
let replacing = TextRange::new(word.start.saturating_sub(1), offset);
let mut items = Items::new(doc, replacing);
related_macros(&mut items, ws, doc, &word.text);
for entry in ws.candidates().macros(&word.text) {
items.simple(
&format!("`{}", entry.name),
@@ -243,6 +254,7 @@ pub fn completions(
scope_tier(&mut items, doc, &word, fuzzy.as_ref());
declared_tier(&mut items, doc, &word, fuzzy.as_ref());
buffer_word_tier(&mut items, doc, &word, fuzzy.as_ref());
related_tier(&mut items, ws, doc, &word, fuzzy.as_ref());
index_tier(&mut items, ws, &word, fuzzy.as_ref());
template_tier(&mut items, ws, doc, &word, snippets, at_item, at_statement);
keyword_tier(&mut items, &word);
@@ -273,6 +285,10 @@ struct Items {
items: Vec<CompletionItem>,
seen: HashSet<String>,
incomplete: bool,
/// How many of `items` the related tier added — which [`LIMIT`] does not
/// count, so every other tier fills exactly as far as it would without
/// them (`related.rs`).
related: usize,
}
impl Items {
@@ -282,6 +298,7 @@ impl Items {
items: Vec::new(),
seen: HashSet::new(),
incomplete: false,
related: 0,
}
}
@@ -289,7 +306,7 @@ impl Items {
/// only sets [`Items::incomplete`] — which is why the tiers ask first
/// rather than building items nobody will see.
fn full(&mut self) -> bool {
if self.items.len() >= LIMIT {
if self.items.len() - self.related >= LIMIT {
self.incomplete = true;
return true;
}
@@ -310,6 +327,14 @@ impl Items {
if self.full() || self.seen.contains(name) {
return;
}
self.unlimited(name, kind, tier, detail);
}
/// [`Items::simple`] past the cap: the caller has its own.
fn unlimited(&mut self, name: &str, kind: CompletionItemKind, tier: char, detail: String) {
if !self.seen.insert(name.to_string()) {
return;
}
let item = CompletionItem {
label: name.to_string(),
kind: Some(kind),
@@ -322,7 +347,7 @@ impl Items {
})),
..Default::default()
};
self.push(item);
self.items.push(item);
}
/// A port or parameter after a connection list's `.`: the bare name, or
@@ -894,3 +919,5 @@ mod tests {
);
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Tier 0 — module names at module-item position — and the instantiation
//! planning that `inline.rs`'s ghost and `instantiate.rs`'s command share.
//!
@@ -921,3 +923,5 @@ endmodule
assert!(vlog_refactor::module_definition(&index, "nope").is_err());
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -0,0 +1,345 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The **related** tier: what this file is related to through the workspace
//! index, ranked above the rest of the workspace and below the file itself
//! (`docs/features/fast-actions/README.md`, completion through the
//! relationship map).
//!
//! The tier-5 table answers "every package member, typedef, class and module
//! the workspace declares whose name matches", alphabetically, until the
//! response is full — so in a workspace of tens of thousands of files the
//! members of the one package this file actually imports were cut off behind
//! names from files it has nothing to do with (measured: 46 of 47 matching
//! `aes_pkg` names offered at `ae` in 4 000 files, 11 of 47 in 40 000). What a
//! file is related to is known without reading anything: the packages its
//! scope chain imports, the classes its enclosing class extends, the headers
//! its `` `include``s reach. Those names come first.
//!
//! **No item is taken away.** A related item does not count against
//! [`LIMIT`](super::LIMIT): the tiers after it fill exactly as far as they
//! did before, and a name the related tier claimed is skipped by them
//! without being counted, so every label of the old answer is still offered,
//! with the same edit and format (the completion-equivalence test holds the
//! server to that). **What does change** for a name the related tier claims
//! is its icon and its detail: they now describe the declaration the file is
//! related to — the member of the package it imports, the macro of the header
//! it includes, the member of the class it extends — where the workspace tier
//! described the first declaration of that name in the whole workspace
//! (`NumRegs` of whichever register package sorts first; a module of the name
//! where the imported package declares a function). The tier has its own
//! cap, [`RELATED_LIMIT`], past which it says the answer is incomplete.
use lsp_types::CompletionItemKind;
use vlog_parser::defines::DefineKind;
use vlog_semantic::{Def, ScopeKind, Semantics, SymbolKind};
use super::tiers::innermost_scope;
use super::word::Word;
use super::{completion_kind, Items, TIER_RELATED};
use crate::candidates::{rank_cmp, starts_with_ignore_case, Query, Score};
use crate::state::{Document, Workspace};
use crate::symbols::kind_label;
/// How many related names one response carries at most.
///
/// A package of a few hundred members is the large case (`aes_pkg` has 259
/// on its connection surface); at an empty prefix the related tier would
/// otherwise double a response that is already incomplete.
pub(super) const RELATED_LIMIT: usize = 256;
/// One related name: what to show, and how it ranks.
struct Related {
name: String,
kind: SymbolKind,
detail: String,
}
impl Items {
/// Add a related item, unless a higher tier already offered that name or
/// the tier is full. Not counted against [`LIMIT`](super::LIMIT).
fn related(&mut self, name: &str, kind: CompletionItemKind, detail: String) {
if self.seen.contains(name) {
return;
}
if self.related >= RELATED_LIMIT {
self.incomplete = true;
return;
}
self.related += 1;
self.unlimited(name, kind, TIER_RELATED, detail);
}
}
/// The related tier for a name being typed: the members of every package
/// the scope chain at the cursor imports, and of the classes the enclosing
/// class extends.
pub(super) fn related_tier(
items: &mut Items,
ws: &Workspace,
doc: &Document,
word: &Word,
fuzzy: Option<&Query>,
) {
let mut found = imported(ws, &doc.semantics, word.start);
found.extend(inherited(ws, &doc.semantics, word.start));
let mut matched: Vec<(Related, Option<Score>)> = found
.into_iter()
.filter_map(|related| match fuzzy {
None => starts_with_ignore_case(&related.name, &word.text).then_some((related, None)),
Some(query) => query.score(&related.name).map(|score| (related, Some(score))),
})
.collect();
matched.sort_by(|(a, sa), (b, sb)| match (sa, sb) {
(Some(sa), Some(sb)) => rank_cmp((&a.name, *sa), (&b.name, *sb)),
_ => a.name.cmp(&b.name),
});
for (related, _) in matched {
items.related(&related.name, completion_kind(related.kind), related.detail);
}
}
/// The related tier after a backtick: the macros the headers this buffer
/// reaches through its `` `include``s define, ahead of every other macro in
/// the workspace.
pub(super) fn related_macros(items: &mut Items, ws: &Workspace, doc: &Document, prefix: &str) {
let mut names: Vec<(String, String)> = Vec::new();
for path in crate::includes::reachable_from(ws, doc) {
let Some(table) = ws.index().file_id(&path).and_then(|file| ws.index().defines(file))
else {
continue;
};
let defines = table.entries().iter().filter(|d| d.kind == DefineKind::Define);
for define in defines.filter(|d| starts_with_ignore_case(&d.name, prefix)) {
names.push((define.name.clone(), crate::candidates::macro_of(define).detail));
}
}
names.sort();
names.dedup_by(|a, b| a.0 == b.0);
for (name, detail) in names {
items.related(&format!("`{name}"), CompletionItemKind::CONSTANT, detail);
}
}
/// Every member of every package imported by a scope enclosing `offset`,
/// innermost scope first, a wildcard bringing all of a package's members and
/// an explicit import the one it names.
fn imported(ws: &Workspace, semantics: &Semantics, offset: u32) -> Vec<Related> {
let mut out = Vec::new();
let mut at = innermost_scope(semantics, offset).or(Some(semantics.file_scope()));
while let Some(id) = at {
let Some(scope) = semantics.scope(id) else { break };
at = scope.parent;
for import in &scope.imports {
for (name, defs) in ws.index().members_of(&import.package) {
if import.item.as_deref().is_some_and(|item| item != name) {
continue;
}
let Some(def) = defs.first() else { continue };
out.push(Related {
name: name.to_string(),
kind: def.kind,
detail: format!("{} — {}::{name}", kind_label(def.kind), import.package),
});
}
}
}
out
}
/// Every member the enclosing class inherits, as the index's member chain for
/// that class lists it — its own members included, which the scope tier has
/// already claimed — each named after the class that **declares** it, the
/// way the workspace tier names a member (`base_c::count`).
fn inherited(ws: &Workspace, semantics: &Semantics, offset: u32) -> Vec<Related> {
let mut at = innermost_scope(semantics, offset);
while let Some(id) = at {
let Some(scope) = semantics.scope(id) else { break };
if scope.kind == ScopeKind::Class {
let Some(key) = semantics.member_key(id) else { return Vec::new() };
let index = ws.index();
return index
.members_of_chain(&key)
.into_iter()
.map(|(name, def)| {
let owner = declaring_class(ws, &key, name, def).unwrap_or(&key);
Related {
name: name.to_string(),
kind: def.kind,
detail: format!("{} — {owner}::{name}", kind_label(def.kind)),
}
})
.collect();
}
at = scope.parent;
}
Vec::new()
}
/// Which class of `class`'s `extends` chain declares `def` as `name`: the
/// class itself, then its base, then that base's base — each hop the one
/// `vlog_semantic`'s `base_chain` takes, a recorded base or else the class a
/// typedef aliases (`typedef mid_c alias_t; class leaf_c extends alias_t;`).
/// `None` only for a chain the index cannot follow, and the caller then
/// names the class it started from.
fn declaring_class<'a>(
ws: &'a Workspace,
class: &'a str,
name: &str,
def: &Def,
) -> Option<&'a str> {
let index = ws.index();
let mut hop = Some(class);
let mut seen: Vec<&str> = Vec::new();
while let Some(unit) = hop.filter(|unit| !seen.contains(unit)) {
if index.members_of(unit).any(|(member, defs)| member == name && defs.first() == Some(def))
{
return Some(unit);
}
seen.push(unit);
hop = index.base_of(unit).or_else(|| aliased_class(ws, unit)).map(last_segment);
}
None
}
/// The class a typedef names, when `unit` is a typedef the index holds once —
/// the alias hop of `vlog_semantic`'s `base_chain` (`aliased_unit`), read
/// through the index's public tables.
fn aliased_class<'a>(ws: &'a Workspace, unit: &str) -> Option<&'a str> {
match ws.index().units(unit) {
[def] if def.kind == SymbolKind::Typedef => def.type_name.as_deref(),
_ => None,
}
}
/// The last `::` segment of a possibly qualified class path — the name the
/// member and inheritance tables are keyed by.
fn last_segment(path: &str) -> &str {
path.rsplit("::").next().unwrap_or(path)
}
#[cfg(test)]
mod tests {
use crate::completion::harness::*;
use crate::completion::*;
/// A package the buffer imports, and one it does not, both holding names
/// that start alike.
fn two_packages(name: &str) -> Tree {
let tree = Tree::new(name);
tree.write(
"near.sv",
"package near_pkg;\n localparam int ZED_NEAR = 1;\n typedef logic zed_t;\nendpackage\n",
);
tree.write("far.sv", "package far_pkg;\n localparam int ZED_FAR = 2;\nendpackage\n");
tree
}
#[test]
fn an_imported_packages_members_rank_above_the_rest_of_the_workspace() {
let top = "module top;\n import near_pkg::*;\n assign x = ze\nendmodule\n";
let (_tree, ws, uri, position) = opened(two_packages("rel_import"), top, "= ze");
let items = items(completions(&ws, &uri, position, true));
let near = find(&items, "ZED_NEAR").expect("the imported member");
let far = find(&items, "ZED_FAR").expect("the other package's member is still offered");
assert_eq!(tier(near), TIER_RELATED);
assert_eq!(tier(far), TIER_INDEX);
assert!(near.sort_text < far.sort_text, "related above the workspace");
assert_eq!(near.detail.as_deref(), Some("localparam — near_pkg::ZED_NEAR"));
assert_eq!(tier(find(&items, "zed_t").expect("the typedef")), TIER_RELATED);
}
#[test]
fn an_explicit_import_relates_the_one_name_it_imports() {
let top = "module top;\n import near_pkg::zed_t;\n assign x = ze\nendmodule\n";
let (_tree, ws, uri, position) = opened(two_packages("rel_explicit"), top, "= ze");
let items = items(completions(&ws, &uri, position, true));
// The binder makes an explicitly imported name a declaration of this
// scope, so it is offered by the scope tier, above even this one.
assert!(tier(find(&items, "zed_t").expect("imported")) <= TIER_RELATED);
assert_eq!(tier(find(&items, "ZED_NEAR").expect("still offered")), TIER_INDEX);
}
#[test]
fn related_items_take_nothing_from_the_tiers_after_them() {
// More project names than the cap, and an import whose members all
// match too: the workspace tiers still fill the whole cap.
let tree = two_packages("rel_cap");
let mut many = String::from("package many_pkg;\n");
for i in 0..LIMIT + 40 {
many.push_str(&format!(" localparam int ZED_{i:04} = {i};\n"));
}
many.push_str("endpackage\n");
tree.write("many.sv", &many);
let top = "module top;\n import near_pkg::*;\n assign x = ZE\nendmodule\n";
let (_tree, ws, uri, position) = opened(tree, top, "= ZE");
let Some(CompletionResponse::List(list)) = completions(&ws, &uri, position, true) else {
panic!("a list");
};
let related = list.items.iter().filter(|i| tier(i) == TIER_RELATED).count();
assert_eq!(related, 2, "the two near_pkg names");
assert_eq!(list.items.len() - related, LIMIT, "the cap counts the others only");
assert!(list.is_incomplete);
}
#[test]
fn a_class_relates_what_it_inherits() {
let tree = Tree::new("rel_class");
tree.write(
"base.sv",
"class base_c;\n int zed_count;\n function void zed_reset();\n endfunction\nendclass\n",
);
let top = "class derived_c extends base_c;\n function void go();\n ze\n endfunction\nendclass\n";
let (_tree, ws, uri, position) = opened(tree, top, " ze");
let items = items(completions(&ws, &uri, position, true));
let count = find(&items, "zed_count").expect("inherited");
assert_eq!(tier(count), TIER_RELATED);
assert_eq!(tier(find(&items, "zed_reset").expect("inherited")), TIER_RELATED);
// Named after the class that declares it, as the workspace tier
// names a member — not after the class that inherits it.
assert_eq!(count.detail.as_deref(), Some("variable — base_c::zed_count"));
}
#[test]
fn a_backtick_ranks_what_the_included_headers_define_first() {
let tree = Tree::new("rel_macro");
tree.write("near.svh", "`define ZED_NEAR 1\n");
tree.write("far.svh", "`define ZED_FAR 2\n");
let top = "`include \"near.svh\"\nmodule top;\n assign x = `ZE\nendmodule\n";
let (_tree, ws, uri, position) = opened(tree, top, "`ZE");
let items = items(completions(&ws, &uri, position, true));
let near = find(&items, "`ZED_NEAR").expect("the included header's macro");
let far = find(&items, "`ZED_FAR").expect("every other macro is still offered");
assert_eq!(tier(near), TIER_RELATED);
assert!(near.sort_text < far.sort_text);
assert_eq!(near.detail.as_deref(), Some("`define ZED_NEAR"), "the detail tier 5 gives");
}
#[test]
fn a_member_two_classes_up_names_the_class_that_declares_it() {
let tree = Tree::new("rel_grand");
tree.write("base.sv", "class root_c;\n int zed_deep;\nendclass\nclass mid_c extends root_c;\n int zed_mid;\nendclass\n");
let top =
"class leaf_c extends mid_c;\n function void go();\n ze\n endfunction\nendclass\n";
let (_tree, ws, uri, position) = opened(tree, top, " ze");
let items = items(completions(&ws, &uri, position, true));
let detail = |label: &str| find(&items, label).and_then(|i| i.detail.clone());
assert_eq!(detail("zed_deep").as_deref(), Some("variable — root_c::zed_deep"));
assert_eq!(detail("zed_mid").as_deref(), Some("variable — mid_c::zed_mid"));
}
#[test]
fn a_member_reached_through_a_typedef_alias_names_the_class_that_declares_it() {
// QA R2: `leaf_c extends alias_t`, and `alias_t` is a typedef of
// `mid_c` — the member is `mid_c`'s.
let tree = Tree::new("rel_alias");
tree.write("base.sv", "class mid_c;\n int zed_mid;\nendclass\ntypedef mid_c alias_t;\n");
let top = "class leaf_c extends alias_t;\n function void go();\n ze\n endfunction\nendclass\n";
let (_tree, ws, uri, position) = opened(tree, top, " ze");
let items = items(completions(&ws, &uri, position, true));
let mid = find(&items, "zed_mid").expect("inherited through the alias");
assert_eq!(tier(mid), TIER_RELATED);
assert_eq!(mid.detail.as_deref(), Some("variable — mid_c::zed_mid"));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! What may be written here: the module-item gate and the statement gate,
//! judged over the token stream's scope chain.
//!
@@ -262,3 +264,5 @@ mod tests {
}
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Tiers 1 to 5: the five ordinary tiers, in the order they fill the
//! response.
//!
@@ -944,3 +946,5 @@ endmodule
assert!(labels(&items).contains(&"ov_in_buffer"), "{:?}", labels(&items));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+152
View File
@@ -0,0 +1,152 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! What a completion answer costs on the wire, for a client that can take
//! less (`docs/features/fast-actions/README.md`, "payload").
//!
//! Every item of one answer replaces the same range, and almost every item
//! inserts its own label as plain text — so the `textEdit` each one carries
//! (49 % of a 130 KB answer, measured) and its `insertTextFormat` (8 %) say
//! the same thing five hundred times. LSP 3.17's `CompletionList.itemDefaults`
//! says it once: an item with no `textEdit` replaces `editRange` with its
//! `textEditText`, or with its label when it has none, in
//! `insertTextFormat`. `vscode-languageclient` 9 applies exactly that rule
//! (`protocolConverter.asCompletionInsertText`), and advertises both defaults.
//!
//! **The same edits, fewer bytes.** The rewrite is lossless by construction:
//! an item keeps its own `textEdit` unless its range *is* the default, keeps
//! its own format unless it *is* the default, and moves a `newText` that is
//! not its label into `textEditText`. Done on the serialized answer because
//! `lsp-types` 0.97 has neither field.
use lsp_types::InitializeParams;
use serde_json::{Map, Value};
/// `insertTextFormat: PlainText`, the format nearly every item has.
const PLAIN_TEXT: u64 = 1;
/// Whether the client applies `itemDefaults.editRange` and
/// `itemDefaults.insertTextFormat` — `textDocument.completion.completionList
/// .itemDefaults` listing both. A client that said nothing gets every item
/// whole, which is what every client got before this was read.
pub(crate) fn item_defaults_support(params: &InitializeParams) -> bool {
let listed = params
.capabilities
.text_document
.as_ref()
.and_then(|text_document| text_document.completion.as_ref())
.and_then(|completion| completion.completion_list.as_ref())
.and_then(|list| list.item_defaults.as_ref());
listed.is_some_and(|names| {
["editRange", "insertTextFormat"].iter().all(|wanted| names.iter().any(|n| n == wanted))
})
}
/// Rewrite a serialized `CompletionList` so the range and the format every
/// item shares are said once, in `itemDefaults`. Anything that is not a list
/// with items comes back as it was.
pub(crate) fn with_item_defaults(mut answer: Value) -> Value {
let Some(list) = answer.as_object_mut() else { return answer };
let Some(Value::Array(items)) = list.get_mut("items") else { return answer };
let Some(range) = items.first().and_then(edit_range).cloned() else { return answer };
for item in items.iter_mut().filter_map(Value::as_object_mut) {
lift_edit(item, &range);
if item.get("insertTextFormat").and_then(Value::as_u64) == Some(PLAIN_TEXT) {
item.remove("insertTextFormat");
}
}
let mut defaults = Map::new();
defaults.insert("editRange".to_string(), range);
defaults.insert("insertTextFormat".to_string(), Value::from(PLAIN_TEXT));
list.insert("itemDefaults".to_string(), Value::Object(defaults));
answer
}
/// The range a plain `textEdit` replaces, if the item has one.
fn edit_range(item: &Value) -> Option<&Value> {
let edit = item.get("textEdit")?;
edit.get("newText")?;
edit.get("range")
}
/// Drop `item`'s `textEdit` when it replaces `range`, keeping its text in
/// `textEditText` unless that text is the label.
fn lift_edit(item: &mut Map<String, Value>, range: &Value) {
let Some(edit) = item.get("textEdit") else { return };
if edit.get("range") != Some(range) {
return;
}
let Some(Value::Object(mut edit)) = item.remove("textEdit") else { return };
let new_text = edit.remove("newText").unwrap_or(Value::Null);
if item.get("label") != Some(&new_text) {
item.insert("textEditText".to_string(), new_text);
}
}
#[cfg(test)]
mod tests {
use super::*;
use serde_json::json;
fn range(line: u32) -> Value {
json!({ "start": { "line": line, "character": 4 }, "end": { "line": line, "character": 6 } })
}
/// The edit an item makes under the LSP 3.17 rule, defaults applied.
fn effective(item: &Value, defaults: &Value) -> (Value, Value, Value) {
let format = item.get("insertTextFormat").unwrap_or(&defaults["insertTextFormat"]).clone();
match item.get("textEdit") {
Some(edit) => (edit["range"].clone(), edit["newText"].clone(), format),
None => (
defaults["editRange"].clone(),
item.get("textEditText").unwrap_or(&item["label"]).clone(),
format,
),
}
}
#[test]
fn every_item_makes_the_same_edit_with_the_defaults_applied() {
let before = json!({ "isIncomplete": true, "items": [
{ "label": "sig", "insertTextFormat": 1,
"textEdit": { "range": range(2), "newText": "sig" } },
{ "label": "if begin/end", "insertTextFormat": 2,
"textEdit": { "range": range(2), "newText": "if (${1:cond}) begin\n$0\nend" } },
{ "label": "`W", "insertTextFormat": 1,
"textEdit": { "range": range(2), "newText": "`W" } },
{ "label": "odd", "insertTextFormat": 1,
"textEdit": { "range": range(7), "newText": "odd" } },
]});
let after = with_item_defaults(before.clone());
let defaults = &after["itemDefaults"];
assert_eq!(defaults["editRange"], range(2));
for (old, new) in
before["items"].as_array().unwrap().iter().zip(after["items"].as_array().unwrap())
{
let old_effect = (
old["textEdit"]["range"].clone(),
old["textEdit"]["newText"].clone(),
old["insertTextFormat"].clone(),
);
assert_eq!(effective(new, defaults), old_effect, "{new}");
}
assert!(after["items"][0].get("textEdit").is_none(), "the label is the text");
assert!(after["items"][0].get("textEditText").is_none());
assert_eq!(after["items"][1]["textEditText"], before["items"][1]["textEdit"]["newText"]);
assert!(after["items"][3].get("textEdit").is_some(), "another range keeps its edit");
assert!(after.to_string().len() < before.to_string().len());
}
#[test]
fn an_answer_that_is_not_a_list_of_edits_is_left_alone() {
for answer in [
Value::Null,
json!([]),
json!({ "isIncomplete": false, "items": [] }),
json!({ "items": [{ "label": "x", "insertText": "x" }] }),
] {
assert_eq!(with_item_defaults(answer.clone()), answer);
}
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! What is typed: the identifier run ending at the cursor and what stands
//! around it — a backtick, a `.` or a `::`, and the spine a separator
//! follows.
@@ -244,3 +246,5 @@ pub(super) fn line_head_is_blank(text: &str, at: u32) -> bool {
let line_start = head.rfind('\n').map_or(0, |newline| newline + 1);
head.get(line_start..).is_some_and(|head| head.chars().all(|c| c == ' ' || c == '\t'))
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Byte offsets ↔ LSP positions.
//!
//! Everything below the protocol speaks UTF-8 byte offsets; LSP `Position`
@@ -518,3 +520,5 @@ mod tests {
});
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! The VS Code instance-oriented design hierarchy.
//!
//! LSP call hierarchy deliberately groups a module's calls by target module
@@ -523,3 +525,5 @@ mod tests {
.unwrap_or_else(|| panic!("no module {name}: {modules:#?}"))
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Diagnostics, published on every buffer change.
use lsp_types::{Diagnostic, DiagnosticSeverity};
@@ -199,3 +201,5 @@ mod tests {
assert!(diags[0].range.start < diags[0].range.end, "must be drawable");
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
+4
View File
@@ -1,3 +1,5 @@
// Author: Guoliang Chen, a Senior Digital Design Engineer
//! Single-step macro expansion, for hover **display** only.
//!
//! One step means one thing: the definition's body with the call site's
@@ -430,3 +432,5 @@ mod tests {
assert!(!has_macro_use("plain text"));
}
}
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
Loaded 100 of 883 files, more files were not shown because too many files have changed in this diff. Show more