diff --git a/CHANGELOG.md b/CHANGELOG.md index 615b69f..7bb6c19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ 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.48.1 — 2026-09-06 + +### The 0.48.0 packages, rebuilt from the right commit + +- **0.48.0's packages were built one commit early** — a release-chain + slip tagged the version commit before the feature commit landed, and + the tag was moved after the build had started — so its extension lacks + the DUT-centred hierarchy view its notes describe. 0.48.1 is the same + tree, packaged from the commit that has it. Nothing else changed. + ## 0.48.0 — 2026-09-06 ### A DUT-centred hierarchy view diff --git a/Cargo.lock b/Cargo.lock index 905387c..fa9b521 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,7 +97,7 @@ dependencies = [ [[package]] name = "lucisv" -version = "0.48.0" +version = "0.48.1" dependencies = [ "lucisv_core", "rayon", @@ -108,11 +108,11 @@ dependencies = [ [[package]] name = "lucisv_core" -version = "0.48.0" +version = "0.48.1" [[package]] name = "lucisv_server" -version = "0.48.0" +version = "0.48.1" dependencies = [ "lsp-server", "lsp-types", @@ -248,14 +248,14 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "vlog_formatter" -version = "0.48.0" +version = "0.48.1" dependencies = [ "vlog_parser", ] [[package]] name = "vlog_linter" -version = "0.48.0" +version = "0.48.1" dependencies = [ "lucisv_core", "vlog_formatter", @@ -265,11 +265,11 @@ dependencies = [ [[package]] name = "vlog_parser" -version = "0.48.0" +version = "0.48.1" [[package]] name = "vlog_refactor" -version = "0.48.0" +version = "0.48.1" dependencies = [ "vlog_formatter", "vlog_parser", @@ -278,7 +278,7 @@ dependencies = [ [[package]] name = "vlog_semantic" -version = "0.48.0" +version = "0.48.1" dependencies = [ "vlog_parser", ] diff --git a/Cargo.toml b/Cargo.toml index 8f364df..9b9affb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ ] [workspace.package] -version = "0.48.0" +version = "0.48.1" authors = ["Guoliang Chen"] edition = "2021" license = "MIT" diff --git a/crates/vlog_refactor/src/check/ledger.rs b/crates/vlog_refactor/src/check/ledger.rs index a7926a9..d33caf3 100644 --- a/crates/vlog_refactor/src/check/ledger.rs +++ b/crates/vlog_refactor/src/check/ledger.rs @@ -18,6 +18,8 @@ use vlog_parser::tokenize; use crate::rename::display; use crate::TextEdit; +use super::{Moving, Origin}; + // ---------------------------------------------------------------------- // lexical splice // ---------------------------------------------------------------------- @@ -180,12 +182,16 @@ pub(super) fn pieces_match( split.positions_match(edits, path, what) } -/// The range the move takes text out of file `i`, if it names that file at all: -/// a source's own region, or the empty range that says "this one only -/// receives". A file the move does not name has none, and keeps the per-file -/// contract. -pub(super) fn region_of(moving: &[(usize, TextRange)], i: usize) -> Option { - moving.iter().find(|(file, _)| *file == i).map(|(_, region)| *region) +/// The range the move takes text out of file `i`, if it names that file as one +/// it *edits* at all: a source's own region, or the empty range that says +/// "this one only receives". A file the move does not name — and a file it +/// only copies out of, which it does not edit — has none, and keeps the +/// per-file contract. +pub(super) fn region_of(moving: &[Moving], i: usize) -> Option { + moving + .iter() + .find(|moving| moving.file == i && moving.origin == Origin::Moved) + .map(|moving| moving.region) } /// Whether a piece sits inside the bytes a move takes out of its file. An @@ -349,9 +355,9 @@ impl Ledger { } /// The files a move names, and the never-dropped pieces travelling between -/// them: a **source** loses the pieces inside its own region, and a -/// **destination** — a file the move names with an empty range — is the only -/// place they may land. +/// them: a **source** loses the pieces inside its own region, a **copy** keeps +/// them and lends them out, and a **destination** — a file the move names with +/// an empty range — is the only place they may land. /// /// This is the whole of the widening [`super::verify_move`] exists for, and /// the whole of what it is allowed to forgive: the allowance is bound to the @@ -360,6 +366,10 @@ impl Ledger { #[derive(Default)] pub(super) struct Transit { files: Vec, + /// The files a move only copies out of: what a refusal calls each one, and + /// the never-dropped pieces its region holds. They have no ledger — a copy + /// is not edited, and [`super::verify_move`] refuses one that is. + copied: Vec<(String, Tally)>, } /// One file of a move: what a refusal calls it, whether it receives rather @@ -386,6 +396,30 @@ impl Transit { }); } + /// Take the pieces a move **copies** out of a file it does not edit: what + /// that file's region holds, once, which is what the destinations between + /// them may write. + pub(super) fn copy( + &mut self, + where_: &str, + text: &str, + region: TextRange, + what: &str, + ) -> Result<(), String> { + let Some(pieces) = pieces(text) else { + return Err(format!( + "{where_} does not lex, so {what} cannot say what it would copy out of it; no edits were made." + )); + }; + let mut tally = Tally::new(); + tally_into( + &mut tally, + pieces.iter().filter(|(span, _)| within(region, *span)).map(|(_, piece)| piece), + ); + self.copied.push((where_.to_string(), tally)); + Ok(()) + } + /// The three equations per file — the destinations, and only they, holding /// the transit as their allowance — and then rule 4 over the move whole. pub(super) fn check(&self, what: &str) -> Result<(), String> { @@ -395,6 +429,11 @@ impl Transit { *sent.entry(key.clone()).or_insert(0) += n; } } + for (_, tally) in &self.copied { + for (key, n) in tally { + *sent.entry(key.clone()).or_insert(0) += n; + } + } let nothing = Tally::new(); for file in &self.files { let receives = match file.receives { @@ -412,7 +451,9 @@ impl Transit { /// once — two destinations that each write the comment are two comments. fn lands(&self, sent: &Tally, what: &str) -> Result<(), String> { let names = |receives: bool| -> Vec { - self.files.iter().filter(|f| f.receives == receives).map(|f| f.where_.clone()).collect() + let named = self.files.iter().filter(move |f| f.receives == receives); + let copies = self.copied.iter().filter(|_| !receives); + named.map(|f| f.where_.clone()).chain(copies.map(|(name, _)| name.clone())).collect() }; let mut texts: Vec<&Kept> = sent.keys().collect(); texts.sort_unstable(); @@ -434,7 +475,7 @@ impl Transit { false => "nowhere".to_string(), }; return Err(format!( - "{what} would move the {noun} `{text}` out of {} {} and write it back {landing}; {rule}, so nothing was edited.", + "{what} would carry the {noun} `{text}` out of {} {} and write it back {landing}; {rule}, so nothing was edited.", and_list(&sources), times(out) )); diff --git a/crates/vlog_refactor/src/check/mod.rs b/crates/vlog_refactor/src/check/mod.rs index 2dafaf2..54efe79 100644 --- a/crates/vlog_refactor/src/check/mod.rs +++ b/crates/vlog_refactor/src/check/mod.rs @@ -145,6 +145,47 @@ pub(crate) fn verify_splice( verify_move(scope, edits, &[watch_name], what, &[]) } +/// What a move does with one file's bytes. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum Origin { + /// The bytes **leave**: the file is edited, its region is deleted, and + /// what was inside it lands in a destination. Extracting a module works + /// this way, and so does the empty region that names a destination. + Moved, + /// The bytes are **copied**: the file is not edited at all, and what its + /// region holds may be written once into the destinations. Inlining a + /// module works this way — `S`'s declaration stays exactly where it is and + /// its items are copied into `M`. + Copied, +} + +/// One file a move names, and what it does with that file's bytes. +#[derive(Debug, Clone, Copy)] +pub(crate) struct Moving { + pub(crate) file: usize, + pub(crate) region: TextRange, + pub(crate) origin: Origin, +} + +impl Moving { + /// The file a move takes its text **out of**, and the bytes it takes. + pub(crate) fn source(file: usize, region: TextRange) -> Moving { + Moving { file, region, origin: Origin::Moved } + } + + /// A file a move **copies** out of, and the bytes it copies. The file + /// itself must come out untouched, which is checked rather than assumed. + pub(crate) fn copy(file: usize, region: TextRange) -> Moving { + Moving { file, region, origin: Origin::Copied } + } + + /// A file that only **receives** — named with an empty region, because it + /// sends nothing. + pub(crate) fn destination(file: usize) -> Moving { + Moving { file, region: TextRange::empty(0), origin: Origin::Moved } + } +} + /// [`verify_splice`], for a refactoring that **moves text from one file into /// another** — which is what extracting a module into its own file is. /// @@ -180,6 +221,17 @@ pub(crate) fn verify_splice( /// that file's own rule 2, and by rule 4. See /// `docs/features/extract-inline-module/README.md` for the attack pairs. /// +/// **A third kind of file: one the move only *copies* out of** +/// ([`Origin::Copied`]). Inlining a module is the mirror of extracting one — +/// `S`'s items are copied into `M` and `S`'s own file is not touched at all — +/// so the pieces `M` writes have an origin without anything having been +/// deleted anywhere. Such a file sends its region's pieces into the transit +/// exactly as a source does, and is held to one further rule of its own: +/// +/// 0. **A copied file is not edited.** It appears in no edit, so its text is +/// the text it had; anything else is a contradiction the move does not get +/// to make, and is refused before the equations are even asked. +/// /// `watched` are the names whose meaning the refactoring changes (the module /// whose ports moved; both module names, for an extraction), which is what /// widens the resolution check beyond the edited files. @@ -188,7 +240,7 @@ pub(crate) fn verify_move( edits: &[(usize, Vec)], watched_names: &[&str], what: &str, - moving: &[(usize, TextRange)], + moving: &[Moving], ) -> Result<(), String> { let abandoned = format!("lucisv could not verify {what}, so it made no edits."); let edited: Vec<(PathBuf, String)> = edits @@ -203,6 +255,22 @@ pub(crate) fn verify_move( } let mut transit = Transit::default(); + // Rule 0, and the pieces a copy sends: a file the move only copies out of + // is one it may not have edited, and what its region holds is what the + // destinations are allowed to write. + for copied in moving.iter().filter(|m| m.origin == Origin::Copied) { + let (Some(path), Some(text)) = (scope.path(copied.file), scope.text(copied.file)) else { + return Err(abandoned); + }; + if edits.iter().any(|(i, _)| *i == copied.file) { + return Err(format!( + "{what} would edit {}, which it only copies out of; no edits were made.", + display(path) + )); + } + transit.copy(&display(path), text, copied.region, what)?; + } + for ((i, edits), (path, text)) in edits.iter().zip(&edited) { let Some(before) = scope.text(*i) else { return Err(abandoned) }; let split = Split::read(before, text, edits, path, what)?; diff --git a/editors/vscode/CHANGELOG.md b/editors/vscode/CHANGELOG.md index 170e0b9..96c4a6f 100644 --- a/editors/vscode/CHANGELOG.md +++ b/editors/vscode/CHANGELOG.md @@ -5,6 +5,11 @@ for you. The extension and its bundled language server share one version number; the full engineering notes live in the [project changelog](https://git.luci.ooo/lucio/lucisv/src/branch/master/CHANGELOG.md). +## 0.48.1 — 2026-09-06 + +- The 0.48.0 package was built without the DUT-centred hierarchy view; + 0.48.1 is the same release packaged correctly. Install this one. + ## 0.48.0 — 2026-09-06 - **DUT-centred hierarchy.** Right-click a module → Star as DUT: the diff --git a/editors/vscode/README.md b/editors/vscode/README.md index ca77cb9..856b428 100644 --- a/editors/vscode/README.md +++ b/editors/vscode/README.md @@ -30,7 +30,7 @@ Install **lucisv — Verilog/SystemVerilog** from the VS Code Extensions view, then open a Verilog or SystemVerilog file. There is no separate server or CLI setup. -The current release is **0.48.0**. Its platform packages include both +The current release is **0.48.1**. Its platform packages include both `lucisv-server` and the `lucisv` command-line tool: | Package target | Machines | diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 28e68bd..39c3db6 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -2,7 +2,7 @@ "name": "lucisv", "displayName": "lucisv — Verilog/SystemVerilog", "description": "Fast Verilog/SystemVerilog formatting, linting, navigation, refactoring, semantic highlighting and RTL design intelligence.", - "version": "0.48.0", + "version": "0.48.1", "publisher": "guoliangchen", "author": "Guoliang Chen", "license": "MIT",