Compare commits

...
3 Commits
Author SHA1 Message Date
lucioandClaude Fable 5.1 94b0711efb Release 0.48.2 — the 0.48.0 packages rebuilt from the commit that has the hierarchy view
ci / checks (push) Successful in 1m3s
ci / corpus (push) Successful in 34s
release / build-and-publish (push) Successful in 6m51s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-06 00:14:15 -05:00
lucioandClaude Fable 5.1 449b874798 DUT-centred hierarchy view: star a module as DUT, its children and its parents in their own sections, everything else re-rooted
ci / checks (push) Successful in 1m7s
ci / corpus (push) Successful in 31s
release / build-and-publish (push) Successful in 6m20s
TODO §56 (docs/features/dut-hierarchy), the owner's request of 2026-09-06.

Client-only, over the flat `lucisv/moduleHierarchy` snapshot the server
already sends. `hierarchySections.js`: per starred DUT, in starred
order, the DUT's forward subtree (the DUT at the top) and an upward tree
from the DUT through every module that instantiates it (labelled `via
<instance>`, cycles cut with one `recursive` row), then one section for
every module in no DUT's subtree or ancestor closure, re-rooted where
its only parents are DUT ancestors (the review ruling — a monitor beside
the DUT under the same bench stays on screen); a module both below one
DUT and above another appears in both DUT sections; a starred name the
index lacks keeps its sections with a "not in the index" row. Star and
unstar from the webview row menu (the pane is a WebviewView, so the
menu is the renderer's, driven by a `menuTable()` per render), the
`lucisv.hierarchy.{starDut,unstarDut,clearDuts}` commands and title
actions, persistence in `workspaceState` in starred order, and the
`lucisv.hierarchy.duts` setting whose entries show locked. With nothing
starred the pane is byte-identical to before (pinned).

opentitan `hw/ip` (847 modules): `aes` → 3 sections with `tb` in its
parents and 5 modules under `aes_tb` re-rooted into others; `aes` +
`hmac` → 5 sections; every module reachable in both configurations; QA's
200-trial fuzz found no overlap and no gap. `extract_test.js` added to
`.vscodeignore`.

(Committed after the 0.48.0 version commit: the release chain broke at a
test-output grep and cut the tag one commit early; the tag is moved here.)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-06 00:04:05 -05:00
lucioandClaude Fable 5.1 4d342367b9 Release 0.48.0 — a DUT-centred hierarchy view
ci / checks (push) Successful in 1m5s
ci / corpus (push) Successful in 37s
release / build-and-publish (push) Successful in 6m54s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-06 00:03:33 -05:00
31 changed files with 2270 additions and 49 deletions

No files matched your search

+30
View File
@@ -4,6 +4,36 @@ 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.2 — 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 never
built**: its tag caught a concurrent lane's half-written verifier
edits. 0.48.2 is the 0.48.0 tree, packaged from the commit that has
the view. Nothing else changed.
## 0.48.0 — 2026-09-06
### A DUT-centred hierarchy view
- **Star a module as DUT** from the hierarchy pane's row menu (or the
`lucisv.hierarchy.starDut` command, or a checked-in
`lucisv.hierarchy.duts` setting, whose entries show locked). Each DUT
gets two collapsible sections: the DUT with its instance subtree, the
DUT at the very top, and the DUT's parents — an upward tree from the
DUT through every module that instantiates it, transitively, which is
where the DV bench lands. One section holds every other module: those
in no DUT's subtree or ancestor chain, re-rooted where their only
parents are DUT ancestors, so a monitor beside the DUT under the same
bench stays visible. One DUT → three sections; two → five. A module
both below one DUT and above another appears in both DUT sections.
With nothing starred the pane is exactly as before. Client-only, over
the hierarchy snapshot the server already sends.
## 0.47.0 — 2026-09-06
### Organize imports, extract module
Generated
+8 -8
View File
@@ -97,7 +97,7 @@ dependencies = [
[[package]]
name = "lucisv"
version = "0.47.0"
version = "0.48.2"
dependencies = [
"lucisv_core",
"rayon",
@@ -108,11 +108,11 @@ dependencies = [
[[package]]
name = "lucisv_core"
version = "0.47.0"
version = "0.48.2"
[[package]]
name = "lucisv_server"
version = "0.47.0"
version = "0.48.2"
dependencies = [
"lsp-server",
"lsp-types",
@@ -248,14 +248,14 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "vlog_formatter"
version = "0.47.0"
version = "0.48.2"
dependencies = [
"vlog_parser",
]
[[package]]
name = "vlog_linter"
version = "0.47.0"
version = "0.48.2"
dependencies = [
"lucisv_core",
"vlog_formatter",
@@ -265,11 +265,11 @@ dependencies = [
[[package]]
name = "vlog_parser"
version = "0.47.0"
version = "0.48.2"
[[package]]
name = "vlog_refactor"
version = "0.47.0"
version = "0.48.2"
dependencies = [
"vlog_formatter",
"vlog_parser",
@@ -278,7 +278,7 @@ dependencies = [
[[package]]
name = "vlog_semantic"
version = "0.47.0"
version = "0.48.2"
dependencies = [
"vlog_parser",
]
+1 -1
View File
@@ -12,7 +12,7 @@ members = [
]
[workspace.package]
version = "0.47.0"
version = "0.48.2"
authors = ["Guoliang Chen"]
edition = "2021"
license = "MIT"
+5 -5
View File
@@ -5435,12 +5435,12 @@ the existing bookmark does (`hierarchyView.js` `BOOKMARK_KEY`).
- Docs: the extension README's hierarchy section, the site's editors page
(lead applies), the feature README.
- [ ] 56.1 model: reverse map, `sections()`, others-exclusion, cycle cut
- [ ] 56.2 view: section nodes, icons, context values, persistence,
- [x] 56.1 model: reverse map, `sections()`, others-exclusion, cycle cut
- [x] 56.2 view: section nodes, icons, context values, persistence,
setting union
- [ ] 56.3 commands, menus, package.json, tests, acceptance checklist row
- [x] 56.3 commands, menus, package.json, tests, acceptance checklist row
- [ ] docs (lead applies README/site)
- [ ] Gates: `node --test editors/vscode/*_test.js`; vsix smoke; the plain
- [x] Gates: `node --test editors/vscode/*_test.js`; vsix smoke; the plain
view pinned unchanged
- [ ] QA: every section shape attacked on the fixture and on opentitan
- [x] QA: every section shape attacked on the fixture and on opentitan
(real snapshot, read-only); persistence; the setting; menus
+662
View File
@@ -0,0 +1,662 @@
# dut-hierarchy
## Goal
A design holds hundreds of modules and one — or a few — that matter: the DUT,
usually with a testbench above it. The hierarchy pane treats every module the
same, so the module the user actually works on is buried among roots that are
alphabetically ahead of it and its DV bench is a root of its own. This feature
lets the user **star a module as DUT** from the pane's context menu and splits
the pane into sections: per starred DUT, **the DUT with its children** (its
forward instance subtree, the DUT at the very top) and **the DUT's parents** (an
upward tree from the DUT through every module that instantiates it,
transitively — typically the DV), then one **all other modules** section. One
DUT gives three sections, two DUTs five. Unstar from the same menu. Everything
is composed in the extension over the snapshot the server already sends
(`lucisv/moduleHierarchy`: `files`, `modules`, `instances`, flat) — the server
changes nothing in this round.
## Assumptions
- **The pane is a `WebviewView`, not a `TreeDataProvider`.** That was decided in
`docs/features/vscode-hierarchy-sidebar` (a webview is the only API at the
extension's VS Code floor with a persistent search input inside the view).
Consequences for this feature are in Handshakes: there is no `viewItem`
context key and no `view/item/context` menu; the row menu is the pane's own
HTML menu, driven by a per-row `contextValue` the host computes.
- The reverse edge "module → modules that instantiate it" is exactly the
forward edge read backwards: an instance contributes an edge only when its
type resolves to exactly one declaration (`instance.targetId`), which is the
same rule the forward tree uses. An unresolved or ambiguous type contributes
no upward edge, so an ambiguous DUT name has an empty parents tree — the same
answer the forward view gives for ambiguity.
- Two declarations of one module name are two modules. A starred *name* that
several declarations carry is resolved to the first in the model's
deterministic order and the section is marked `ambiguous`; the other
declarations keep their ordinary place in the pane.
- **`others` is additive** (the lead's ruling, 2026-09-05, replacing the
question this bullet used to ask). The owner's spec is "any dangling module
that is not a child of the DUT would be put in a different section", so
`others` holds **every module that is in no DUT's forward subtree and in no
DUT's ancestor closure** — not `model.roots` minus that set. Its roots are the
members of that set with no parent left inside it: a monitor the DV bench
instantiates beside the DUT is not a child of the DUT, and with the bench
excluded it has no parent on screen, so it is re-rooted at the top of
`others`. A module that still has an ordinary parent stays under it and is not
re-rooted, so nothing is shown twice. An `others` root's forward subtree is
the plain, unfiltered one: a module that is also below a DUT is still shown
under its parent here, exactly as before. A DUT itself can never appear in
`others` — everything that instantiates it is in its ancestor closure and is
therefore excluded.
- Starring is an explicit user act, so it may expand rows on the user's behalf:
the two new sections and the DUT row inside each open once, when the DUT list
changes. This is the second exception to the owner's 2026-08-29 rule that
nothing expands by itself (the first is a bookmark's ancestor chain).
- **A bookmark is painted wherever its own path is on screen**, and a path is
what is stored — not an instance. Bookmarking inside a DUT section stores the
DUT-relative path (`aes.u_ctrl`) and is painted there; bookmarking under a
root stores the full path and is painted there. The two are different paths
to one instantiation, so a bookmark made in one place is not painted in the
other, and a bookmark whose path runs through an excluded module
(`tb.u_dut.…` while `dut` is starred) is not painted at all until the DUT is
unstarred — the module it names may well still be on screen, but not at that
path. Nothing is ever *lost*: the model
still resolves the path, so `refresh()` never drops it. Tested in
`hierarchySections_test.js::aBookmarkIsPaintedWhereverItsPathIsShown`.
- The `lucisv.hierarchy.duts` setting is a workspace-level list a team checks
in. Its entries cannot be unstarred from the pane, because the pane cannot
edit a checked-in file on the user's behalf; the menu says so.
## Handshakes
### `hierarchyModel.js` — three additive changes, no behaviour change
Consumed: `buildHierarchy`'s flat model (`modules`, `byId`, `roots`, per-instance
`targetId`), `childrenOf`, `treeRows`, `idForPath`, `searchHierarchy`.
Promised/changed by this feature (all additive, the plain pane byte-identical):
- `rootNode` is now exported. `hierarchySections.js` builds a section's root
from it and re-ids it with the section prefix; every descendant id is derived
from the parent id, so one prefix moves a whole subtree into its section.
- `treeRows`' rows and `searchRow`'s rows carry `moduleName` (for a tree
instance row, the instantiated type — the same string the label shows in
parentheses). It is what lets the star/unstar decision be a pure function of a
row.
- `bookmarkChain` keeps its roots-first walk and, **only when that finds
nothing**, retries over every module. A row inside a DUT section has a
DUT-relative full path (`aes.u_ctrl`), and without the retry bookmarking such
a row would store a path that can never be re-resolved. Every path that
resolved before resolves to the same chain.
### `hierarchyView.js` ← `hierarchySections.js`
- `sections(model, duts)` → the section list (below).
- `sectionRows(model, sections, expanded, bookmarkPath)` → `{ rows, nodes }` in
exactly the shape `treeRows` returns, with the section header at depth 0 and
everything under it shifted one level.
- `decorate(rows, duts, locked)` → the same rows with a `contextValue`
(`module`, `module.dut`, `module.dut.locked`, `instance`, …) and, for a locked
DUT, a `title` tooltip.
- `menuTable()` → `contextValue` → the menu items that row offers. Sent once per
render; the webview renders `payload.menus[row.contextValue]` and has no rule
of its own.
- `sectionPrefixes(duts)` → the id prefixes, so the bookmark's ancestor
expansion reaches the copy of the chain inside each section.
- `defaultOpenIds(sections)` / `OTHERS_ID` → what a star opens once, and the
one section it closes.
### `media/hierarchy.js` (the renderer)
- Builds the row menu from `payload.menus[row.contextValue]` instead of a fixed
list, and opens it for any row whose `contextValue` has items (module rows
included — previously only instances had a menu).
- Renders `row.icon` when the host sends one (section and notice rows) and
`row.title` as the row tooltip.
### The server — nothing
No request, notification or schema change. The upward tree is one pass over the
snapshot already sent.
### Requested of the lead (docs this lane may not edit)
See "Docs to apply at merge (lead)".
## Status / TODO
- [x] 56.1 model: reverse map, `sections()`, others-exclusion, cycle cut
(`editors/vscode/hierarchySections.js`)
- [x] 56.2 view: section nodes, icons, context values, persistence, setting
union (`editors/vscode/hierarchyView.js`, `media/hierarchy.js`)
- [x] 56.3 commands, menus, `package.json`, tests, acceptance checklist row
- [x] Gates: `node --test editors/vscode/*_test.js`; server smoke; the vsix
package step; the plain view pinned unchanged
- [x] A real opentitan snapshot through `sections()` with `aes`, then
`aes` + `hmac`
- [x] Rework (lead's ruling): `others` is additive — every module outside every
DUT, re-rooted where the exclusion took its parents
(`editors/vscode/hierarchySections.js`, `hierarchySections_test.js`)
- [x] Hygiene: `extract_test.js` in `.vscodeignore`
- [ ] Docs the lead applies: `README.md`, `docs/site/` editors page
- [ ] QA
## Work log
### 2026-09-05 — dev (the whole of §56)
**Shipped.**
- `editors/vscode/hierarchySections.js` (new, 284 production lines): the reverse
index, `sections()`, the upward tree, `sectionRows()`, `decorate()` and
`menuTable()`.
- `editors/vscode/hierarchySections_test.js` (new): every shape §56 lists.
- `editors/vscode/hierarchyModel.js`: `rootNode` exported, `moduleName` on
tree/search rows, `bookmarkChain`'s all-modules retry.
- `editors/vscode/hierarchyView.js`: the DUT list (workspaceState + setting),
the three commands, section rendering, the seeded default expansion, the
menu table in the render payload.
- `editors/vscode/media/hierarchy.js`, `media/hierarchy.css`: a menu built from
the payload, section/notice icons, row tooltips.
- `editors/vscode/package.json`: three commands, three more `view/title`
entries, the `lucisv.hierarchy.duts` setting.
- `editors/vscode/.vscodeignore`: the new test file is not shipped.
- `editors/vscode/README.md`, `docs/manual-acceptance.md`: the user-facing text.
**The section algorithm.** `sections(model, duts)` walks the starred list in
order. For each name it emits `{ kind: 'dut', name, root }` — `rootNode` for the
named module, re-ided `dut:<name>/root:<id>`, so the subtree under it is exactly
the one the plain pane shows — and `{ kind: 'parents', name, root }`, whose root
is the same module as an *upward* node (`parents:<name>/up:<id>`) and whose
children come from the reverse index: one child per (module, instance) pair with
`instance.targetId === node.moduleId`, labelled with the instantiating module
and `via <instance name>`. The walk carries a `seen` set down the path, so a
cycle (`a` instantiates `b` instantiates `a`) closes with one row marked
`recursive` that does not open again — the same shape the forward tree uses.
Both trees are lazy: children are built when a row is opened, never before.
While walking, the DUT's forward subtree and its full ancestor closure are
collected into one `excluded` set of module ids. `{ kind: 'others', roots }` is
`model.roots` filtered by that set. Two consequences, both intended and tested:
- **Both below and above.** A module below DUT1 and above DUT2 is in both DUT
sections (it is reached by two different walks, with two different id
prefixes, and opens independently in each) and is excluded from `others`.
- **The excluded-root cost.** `others` loses a root that is an ancestor of a
DUT, and with it anything only reachable through that root. See Assumptions.
A starred name the snapshot does not hold keeps both of its sections; each shows
a single non-expandable notice row, so the section count stays `2 × DUTs + 1`
whatever the index says.
**Persistence and the setting.** The starred list lives in `workspaceState`
under `lucisv.hierarchy.duts`, an array of names in the order starred, written
on every star/unstar/clear and read (and sanitized — non-strings and blanks
dropped) in the constructor. The `lucisv.hierarchy.duts` *setting* (string
array, `window` scope — the pane is workspace-wide, not per file) is read on
every render and on
`onDidChangeConfiguration`. The effective list is the union, **setting entries
first in setting order, then starred entries the setting does not already
name**; setting entries are "locked": starring one again is a no-op, unstarring
one is refused with the reason, and their rows carry the locked `contextValue`
whose menu holds one disabled item whose tooltip says where the DUT comes from.
`lucisv.hierarchy.clearDuts` empties the starred list only, and says so when the
setting still names DUTs.
**Deviation from the plan, and why.** §56.3 asks for `view/item/context` entries
gated on `viewItem`. The pane is a `WebviewView`; VS Code has no `viewItem`
context key for it and would never show such a menu, so contributing one would
be dead configuration. The intent — "the menu shows Unstar DUT on a starred
module and Star as DUT on any other" — is delivered by the pane's own HTML menu:
the host stamps every row with a `contextValue` and ships one `menuTable()` per
render, and the renderer shows exactly the items that table names. The three
commands are contributed and work from the palette (each takes an optional
module name, and prompts with a Quick Pick when invoked without one), and
`view/title` carries "Clear DUTs" and the existing entries. The `when` clauses
that do exist (`view == lucisv.hierarchy`) and the whole `contextValue` → menu
table are asserted in `hierarchySections_test.js`.
**Second deviation.** The plan's "others" is exclusive (see Assumptions); the
owner's sentence "all other modules" could be read as additive, which would
re-root a DV bench's monitor when its bench is excluded. The plan won; the lead
should rule if the manual pass finds it surprising on opentitan. On `hw/ip` the
whole cost of the exclusion is three roots out of 295, all of them benches, so
it reads as intended there. *(Superseded the same day: the lead ruled for the
additive reading — see the rework entry below. Everything above describes what
the first round shipped, `others` included.)*
**Two corrections made while reviewing my own code, both with the reasoning
written next to them.** (1) `treeOrSections` records the "already seeded" key
even when the DUT list is empty, so starring the same module again after a
"Clear DUTs" seeds its sections again instead of trusting a stale key; it is
only weakly observable (the expansion set keeps the ids), so the test asserts
the re-starred sections are open rather than the key itself. (2)
`collectSubtree` walks with its own visited set rather than the shared
exclusion set: a module already excluded as DUT1's *ancestor* would otherwise
stop DUT2's downward walk at it, leaving that walk short. With today's root
choice the difference cannot change `others.roots` (nothing below a module is a
root), so it is a defensive correction with no test of its own — said here
rather than left silent.
**Files touched outside the plan's expected set.** Three, all consequences of
the two above: `editors/vscode/media/hierarchy.js` and `media/hierarchy.css`
(the pane's renderer is where a webview's row menu lives, so the star/unstar
items had to be built there), and `editors/vscode/.vscodeignore` (the new test
file must not ship). Noted while there and **not** fixed, because it is not
this feature's: `extract_test.js` is missing from `.vscodeignore` and is
therefore packaged into the .vsix — a one-line hygiene fix for whoever owns
that file next.
**Not done.** Nothing in the plan is unfinished. Two things a later round could
take further, both written down rather than smuggled in: the additive reading
of `others` above, and a bookmark that follows an instantiation rather than a
path (see Assumptions).
**Opentitan, real snapshot** (release server over `hw/ip`, `index.scope` pushed
to `workspace`, scratch `storagePath`, read-only — `git status --porcelain` on
the checkout showed the same three pre-existing modified files before and
after). 835 files, 847 modules, 295 roots, `complete: true`.
| starred | sections | DUT section | parents section | others |
|---|---|---|---|---|
| — | 1 | — | — | 295 roots |
| `aes` | **3** | `aes`, 5 direct children, 577 rows fully open | `aes` → `aes_tb`, `aes_wrap`, **`tb`**; `aes_wrap` → `aes_wrap_tb` (5 rows) | 292 roots |
| `aes`, `hmac` | **5** | + `hmac`, 11 direct children, 302 rows | + `hmac` → `tb` (2 rows) | 291 roots |
The DV bench is in `aes`'s parents section, which is the point of the feature.
The three roots `aes` drops from `others` are `aes_tb`, `aes_wrap_tb` and `tb`
— exactly its transitive ancestors; `hmac` drops the *other* declaration named
`tb` (two files declare one, and they are two modules). `sections()` over the
whole of `hw/ip` costs 2.85 ms the first time (it builds the reverse index) and
0.15 ms after.
**Gates.** `tools/guard.sh -- node --test editors/vscode/*_test.js`: 5 files,
all pass. `cargo build --release -p lucisv_server` + `tools/guard.sh -- node
editors/vscode/smoke.js target/release/lucisv-server`: OK. `npx @vscode/vsce
package` into the scratchpad: OK (the contributions validate).
### 2026-09-05 — dev (rework: `others` is additive)
The lead ruled on the question the first round left open (Assumptions, now
rewritten): the owner's "any dangling module that is not a child of the DUT
would be put in a different section" is additive, so a monitor beside the DUT
under the same bench belongs in `others`, and the exclusive formula that put it
in *no* section was wrong. Only `others` changed — the two DUT sections, the id
scheme, the memoized reverse index and the seeded expansion are untouched.
**The algorithm.** `othersRoots(model, excluded)` replaces
`model.roots.filter(…)`. The set is every module not in `excluded` (unchanged:
each DUT's forward subtree plus its ancestor closure); its roots are the members
with no parent left in the set, emitted in three passes over one shared
`covered` set:
1. `model.roots` minus the excluded — today's answer, and with nothing starred
it is still the whole answer, byte-identical to `model.roots`. Each one marks
its forward subtree covered.
2. Every remaining module that is neither excluded nor covered and has no
parent in the set: re-rooted. This is the monitor whose bench is in the
DUT's parents section.
3. Whatever is still uncovered is inside a recursive component no root enters —
the model's own fallback rule, and marked `recursive` the way the model
marks it.
Roots come out in the model's order (alphabetically, then the fallbacks), which
is exactly how `buildHierarchy` orders `model.roots`, so the section does not
grow an odd tail. Coverage is what prevents duplicates: a module reachable from
one excluded and one ordinary parent is covered by the ordinary parent's walk in
pass 1 and is never re-rooted. It cannot be duplicated the long way round
either, and that is a property of the exclusion rather than of the pass order: a
path from one module of the set to another can never leave the set, because a
module above an ancestor of the DUT is itself an ancestor, and a module below
the DUT's subtree is itself in it — both excluded. So a pass-2 candidate is
reachable from no other root in the section. A root's forward subtree is still the plain,
unfiltered one — a module that is also below a DUT is shown under its parent
here as before, and a *DUT* can never turn up in it, because everything that
instantiates a DUT is in that DUT's ancestor closure. Coverage skips a module it
has already descended through, so the whole pass is one walk over the graph.
**Tests** (`hierarchySections_test.js`, 16 → 21). A `graph({ module: [types] })`
helper builds the small snapshots. New: the monitor beside the DUT (`bench →
{dut, monitor}` — `monitor` is a root of `others`, `bench` is in the parents
section, and every module in the snapshot is asserted to be on screen
somewhere); a module under **two** excluded benches (re-rooted once, not twice);
a module with one excluded and one ordinary parent (shown once, under the
ordinary parent); two DUTs whose benches nest (`bench → {dut1, sub_bench}`,
`sub_bench → {dut2, monitor}` — five sections, `monitor` re-rooted); and a cycle
reachable only through an excluded bench (pass 3 — opened at a `recursive`
root). The existing exclusion test keeps its name's meaning but is renamed
`othersHoldsEveryModuleOutsideEveryDut`: starring `leaf2` now re-roots `leaf1`
and `leaf3`, which it used to hide. `thePlainViewIsUntouched` is unchanged and
green.
**Opentitan, re-derived** (release server over `hw/ip`, `index.scope` pushed to
`workspace`, scratch `storagePath`; `git status --porcelain` on the checkout
showed the same three pre-existing modified files before and after). 835 files,
847 modules, 295 roots, `complete: true`.
| starred | others before | others after | re-rooted |
|---|---|---|---|
| — | 295 | 295 | — |
| `aes` | 292 | **297** | `aes_tb_c_dpi`, `aes_tb_reqs`, `tlul_adapter_tb_reqs`, `tlul_delayer`, `vh_regs` |
| `aes`, `hmac` | 291 | **297** | the five above + `hmac_if` |
All five are instantiated only by `aes_tb` (`hw/ip/aes/pre_dv/aes_tb/rtl/`),
which is one of `aes`'s excluded ancestors; `hmac_if` is instantiated only by
`hmac`'s `tb`. Every one of them was in no section at all before this rework.
No root the old formula kept was lost, and a walk over the new `others` roots
plus the DUT sections reaches every one of the 847 modules — nothing is off
screen with `aes` or with `aes` + `hmac` starred.
**Cost.** `sections(model, ['aes'])` over the whole of `hw/ip`: 1.9 ms → 3.5 ms
on the first call (both dominated by building the reverse index) and 0.03 ms →
0.33 ms on later ones — one extra walk over 847 modules per render of a starred
pane. With nothing starred the pane never calls `sections()` at all
(`treeOrSections` returns `treeRows`), so the plain view pays nothing.
**Also fixed here** (the hygiene item the first round found and left):
`extract_test.js` is now in `editors/vscode/.vscodeignore`, so no `*_test.js`
ships in the .vsix — confirmed against the packaged file list.
**Gates.** `tools/guard.sh -- node --test editors/vscode/*_test.js`: 5 files, 5
pass, 0 fail. `npx @vscode/vsce package` into the scratchpad: OK, 338 files.
## QA log
### 2026-09-06 — QA (Sonnet 5)
**Scope.** Read the plan (TODO §56), the dev's account (this README, both
work-log entries), and the diffs of every file it lists. Attacked the model
and view with scratch tests (removed afterwards, none of the lane's files
touched besides this log and the TODO checkbox), re-derived the opentitan
numbers against the real, read-only checkout, and ran every gate.
**1. Sections — attacked on the existing fixtures, `graph()`, and new scratch
graphs (`/private/tmp/.../scratchpad/attack_sections.js`, removed).** All of
the following hold, matching the algorithm's own description and this
README's Assumptions:
- Zero/one/two DUTs: `2n+1` sections, order = starred order (pinned by the
dev's `oneDutIsThreeSectionsAndTwoAreFive`).
- A DUT that is a root: its parents section holds only the DUT row, no
children (`parents.root.hasChildren === false`) — verified with a fresh
`dut → leaf` graph.
- A DUT that is a leaf: its DUT section is the DUT alone
(`dut.root.hasChildren === false`) — verified with `bench → dut`.
- A DUT instantiated twice by one parent: the parents tree shows the parent
**twice**, one row per instance, each with its own `via <instance>` label
and its own row id — a 2-way explore tree, as the plan asked. Verified with
`bench → [[dut,u_dut_a],[dut,u_dut_b]]`.
- A module instantiated by two benches, itself instantiating the DUT: the
upward tree branches at that node (two children under `mid`). Verified.
- A parent chain of depth 6: the upward walk climbs all six levels,
`depth` incrementing by one per hop. Verified.
- Two DUTs where DUT2 is inside DUT1's subtree (`dut1 → dut2 → leaf`): DUT2
appears both under DUT1's forward tree (unfiltered — `dutSection`'s root is
always the plain subtree) and as its own two sections; DUT1 appears in
DUT2's parents tree. Five sections, all present and correctly shaped.
Verified, and the mirror (starring DUT2 before DUT1) changes only section
*order*, never content.
- The same module starred twice: `sections()` itself performs **no dedup** —
`sections(model, ['dut','dut'])` yields 5 sections (two DUT×2 pairs plus
others). Dedup is the caller's job: `hierarchyView.js`'s `moduleNames()`
wraps every stored/configured list in a `Set` before it ever reaches
`sections()`, and this is exercised in the dev's own `hierarchyView_test.js`
(`configuredDuts = ['top', '']`, the blank and any repeat dropped). Pinning
this contract here so a future caller of `sections()` that skips
`moduleNames()` doesn't get a silent surprise (see LOW finding below).
- A starred name absent from the snapshot: both its sections keep a single
non-expandable "not in the index" notice row; section count stays `2n+1`
(dev's `aStarredNameTheSnapshotLacksKeepsItsSections`, re-run, green).
- A starred name matching two declarations: `ambiguous: true` on both
sections, header says "ambiguous", the **first** declaration in the model's
order is what is shown (dev's `twoDeclarationsOfOneNameAreMarkedAmbiguous`).
Went one step further than the existing test: confirmed the Assumptions
claim that "an ambiguous DUT name has an empty parents tree" actually holds
— with two declarations of `dut`, `tb`'s instance of `dut` becomes
itself ambiguous (`instance.definitions.length === 2`), so `targetId` is
unset and the reverse index carries no edge to either declaration;
`parents.root.hasChildren` is `false`. This isn't special-cased code, it
falls out of `parentIndex` using `instance.targetId` — correct and matches
the forward view's own ambiguity answer, as documented.
- A cycle through the DUT itself (`a → b → a`, starred `a`): both the forward
walk and the upward walk terminate at one `recursive`-marked row that does
not reopen (dev's `theParentsWalkCutsACycle`); re-verified.
- **Others is additive and complete.** Re-ran the dev's own reasoning as a
fuzz test: a seeded-random 40-module DAG (0.15 edge probability, i < j only
so it's acyclic — plus deliberately keeping a couple of exact-duplicate
edges to also exercise the twice-instantiated case), 200 random DUT
selections (1–3 DUTs each). For every trial: every one of the 40 modules is
on screen in some section, and no module is both an `others` root and a
member of any starred DUT's forward subtree. 200/200 trials passed with no
failures.
- No module appears in `others` *and* in a DUT subtree: covered by the fuzz
test above (assertion is exactly this) and by the dev's own
`othersHoldsEveryModuleOutsideEveryDut`/`aModuleUnderAnExcludedBenchIsReRootedInOthers`.
- A module both below DUT1 and above DUT2: dev's
`aModuleBothBelowOneDutAndAboveAnotherIsInBothSections` — two rows, two ids,
neither in `others`; re-run, green.
- Re-rooted module ordering: `othersRoots` emits in `model.roots`' own order
(alphabetical, then fallbacks) — confirmed by reading `othersRoots` and by
the passing `aModuleUnderTwoExcludedBenchesIsReRootedOnce` /
`aCycleReachableOnlyThroughAnExcludedBenchStillHasARoot` tests (recursive
fallback root correctly marked).
- A module with one excluded and one ordinary parent: shown once, under the
ordinary parent, never re-rooted (dev's
`aModuleWithOneOrdinaryParentIsNotReRooted`; re-run, green).
- **The plain view is byte-identical to `model.roots` with no DUT.** Read
`thePlainViewIsUntouched`: it is a real deep-equality check over every
visible field (`id, kind, label, detail, depth, hasChildren, expanded,
warning, bookmarked`) between `decorate(treeRows(...).rows, [], [])` and
`treeRows(...).rows` directly — not a placeholder. Also confirmed
structurally: `treeOrSections()` in `hierarchyView.js` calls `treeRows`
directly and never calls `sections()` at all when `duts.length === 0`, so
the plain pane pays zero extra cost, exactly as claimed.
**2. View/persistence.** Read and re-ran `hierarchyView_test.js`'s DUT block
(lines ~199–330): the fake-`workspaceState` round trip (star, "reload" via a
second `HierarchyView` over the same `state` map, order kept, `7` and `''`
dropped by `moduleNames`'s sanitizer); the setting union (setting entries
first, locked, unstar refused with the exact reason string, re-star a
no-op with an information message); `onDidChangeConfiguration` re-render
(`configurationChanged({...})` reshapes the section list); `clearDuts` clears
stars only (locked setting DUT's section survives, with a message naming it);
the seeded expansion opens the two new sections and the DUT row at depth 1 in
each, `others` stays closed, and — the dev's own "two corrections" note —
re-starring the same module after a `clearDuts` reseeds (`seededFor` keeps
recording even at `duts.length === 0`). All green as shipped.
Added one attack of my own the plan explicitly asked for and the existing
tests don't cover directly: **collapsing a DUT section survives an unrelated
snapshot refresh.** Built a second fake-`vscode` harness
(`attack_sections.js`, removed after the run) that stars a DUT, collapses its
section via a `toggle` message, then fires the `lucisv/moduleHierarchyChanged`
notification handler with the *same* starred list and waits out the refresh
debounce. The section stayed collapsed. This is exactly what
`seedExpansion`'s `if (this.seededFor === key) return;` guard promises (`key`
is unchanged when the DUT list doesn't change), and it held.
**Search inside sections and reveal-on-open — read, not just tested, because
the plan's phrasing assumed more than the feature does.** `render()` in
`hierarchyView.js` sends search results (`searchHierarchy`) as a **flat** list
whenever the query box is non-empty, entirely independent of which sections
are open or which DUTs are starred — this is pre-existing behaviour from
`vscode-hierarchy-sidebar`, unchanged by §56. A search hit still gets a
correct `contextValue` via `decorate(found.rows, duts, locked)`, so
star/unstar works from a search result, but there is no per-section grouping
of search results to "resolve into" — search was never section-shaped, before
or after this feature, and nothing in the README's Handshakes claims
otherwise ("the existing search... behaviour work[s] inside every section"
means it keeps working, not that it becomes section-aware). Not a defect.
Likewise, **no "reveal a file's module when it is opened" feature exists
anywhere in this codebase** — grepped `editors/vscode` for
`onDidOpenTextDocument`/`activeTextEditor`/`revealOnOpen` and found nothing,
in this feature or the sidebar it builds on. The QA brief's "reveal-on-open of
a file whose module is only in a parents section" item does not correspond to
an implemented or claimed capability; the only reveal behaviour that exists is
bookmark-driven (`setBookmark` expands the bookmarked row's ancestors), which
*is* implemented per-section (`sectionPrefixes`) and is covered by
`aBookmarkIsPaintedWhereverItsPathIsShown` — re-run, green, and its claims
(DUT-relative path painted inside the section, ordinary path painted at the
root, a path through an excluded module painted nowhere but never dropped)
all hold on inspection of `isBookmarked`/`bookmarkChain`'s retry.
**Bookmark painting inside a DUT section.** Matches the README exactly: a
bookmark is a stored *path*, painted wherever that exact path resolves to an
id on screen (`isBookmarked` matches the bookmark id or `.../<id>` suffix per
section prefix). Re-verified `bookmarkChain`'s all-modules retry does not
change any *previously resolving* path's id (the retry only changes which
node search order finds a match through; `rootNode(model, module, false)`'s
`false` for `fallback` affects only `detail`/`warning` display fields on a
node that is never rendered — the chain is an array of ids, and `rootNode`'s
`id` field does not depend on `fallback`). No crash, no incorrect painting in
any of the model/view tests or the scratch attacks.
**3. Menus/commands.**
- `menuTable()` per render: read and re-verified against
`contextValuesAndMenusSayWhatEachRowOffers` — a starred row → `[UNSTAR]`, an
ordinary row → `[STAR]` (or `INSTANCE_ACTIONS + STAR/UNSTAR` for an
instance), a locked row → one disabled item with the setting-naming
tooltip. Every `contextValue` `decorate()` can produce has a menu entry
(asserted by the same test's closing loop) — no row can silently offer
nothing.
- The three commands exist in `package.json`'s `contributes.commands`
(`starDut`, `unstarDut`, `clearDuts`) and in `view/title` gated
`"when": "view == lucisv.hierarchy"` — confirmed by reading `package.json`
directly and by the dev's `packageJsonContributesTheCommandsMenusAndSetting`
test, both green.
- Ran every command through the extension's registered handler with the
dev's fake `vscode` (`commands.get(...)`), with and without a module name:
`starDut('top')` (named) and `starDut()` (Quick Pick, `picked` captures the
candidate list — confirmed sorted, deduped, and scoped correctly: "every
module name" for starring, "only what this workspace starred" for
unstarring). Both paths work; re-run, green.
- The `lucisv.hierarchy.duts` setting's `contributes.configuration` entry:
`type: "array"`, `items.type: "string"`, `scope: "window"`,
`default: []`, with a `markdownDescription` naming both the checked-in and
starred routes and the lock — read directly in `package.json` and pinned by
the dev's test.
- `.vscodeignore` excludes every `*_test.js`: listed all five
(`extract_test.js`, `hierarchyModel_test.js`, `hierarchySections_test.js`,
`hierarchyView_test.js`, `restart_test.js`) against the file and confirmed
none of them, nor any other `*_test.js`, appears in `npx @vscode/vsce
package`'s file listing (§5 below).
**4. Opentitan (read-only, scratch index store).** Re-derived the dev's table
independently, with my own hand-rolled LSP client
(`/private/tmp/.../scratchpad/opentitan_client.js`, removed after the run) —
`initializationOptions.storagePath` under the scratchpad,
`lucisv.index.scope: "workspace"` pushed via `workspace/didChangeConfiguration`,
`rootUri`/`workspaceFolders` pointed at `hw/ip`, polling
`lucisv/moduleHierarchy` until `complete: true`.
| starred | sections | others roots | direct parents |
|---|---|---|---|
| — | 1 | 295 | — |
| `aes` | 3 | 297 | `aes_tb`, `aes_wrap`, `tb` |
| `aes`, `hmac` | 5 | 297 | `aes`: same three; `hmac`: `tb` |
835 files, 847 modules, 295 roots, `complete: true` — matches the dev's
numbers exactly. The five re-rooted names the dev called out
(`aes_tb_c_dpi`, `aes_tb_reqs`, `tlul_adapter_tb_reqs`, `tlul_delayer`,
`vh_regs`) are present in the `others` list for `aes`; `hmac_if` joins them
only once `hmac` is also starred — matches. Verified independently (not just
by trusting the label) that opentitan really does declare 31 separate modules
named `tb` across `hw/ip` (`grep -rl '^module tb\b'`), so `aes`'s `tb` and
`hmac`'s `tb` genuinely are two different modules, as the dev's note claims.
`sections(['aes'])`: 4.2 ms cold, 0.6 ms warm (my machine/session, not a
controlled comparison against the dev's 2.85 ms/0.15 ms, but the same order of
magnitude and the same qualitative shape — most of the cost is the one-time
reverse-index build). **Full-reachability check**: walked the module graph
directly (not the rendered tree, to stay linear over 847 nodes) from every
DUT's forward+ancestor closure plus every `others` root's forward subtree —
**847 of 847 modules reachable** for both `['aes']` and `['aes','hmac']`. No
module is off screen in either configuration.
`git -C /Users/guoliangchen/repo/opentitan status --porcelain` before and
after this session's use: unchanged, exactly the three pre-existing modified
files (`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
`hw/top_earlgrey/ip/ast/rtl/ast.sv`).
**5. Gates.**
- `tools/guard.sh -- node --test editors/vscode/*_test.js`: 5 files, 5 pass, 0
fail (`extract_test.js`, `hierarchyModel_test.js`,
`hierarchySections_test.js`, `hierarchyView_test.js`, `restart_test.js`).
- `tools/guard.sh -m 8 -t 900 -- cargo build --release -p lucisv_server`:
already up to date (0.02 s, no crate source changed by this lane — verified
`git status --porcelain -- crates/` is empty), binary present.
- `tools/guard.sh -- node editors/vscode/smoke.js target/release/lucisv-server`:
OK, 20 messages, includes a passing `lucisv/moduleHierarchy` round trip.
- `npx @vscode/vsce package` into the scratchpad: OK, 338 files, 3.1 MB, no
`*_test.js` in the listing; guard not required (not a test/fuzzer/sweep, and
it finished in a few seconds well under any memory concern, consistent with
how the dev logged the same step).
- No guard kill on any run.
**Findings.**
- LOW — `sections(model, duts)` performs no de-duplication of its own `duts`
argument (confirmed by direct test: two identical names cost two identical
section pairs). Today's only caller (`hierarchyView.js`'s `treeOrSections`)
always passes `this.duts()`, which is already deduped through
`moduleNames()`'s `Set`, so this is not reachable from the shipped extension
today. Worth a one-line doc comment on `sections()` saying the caller owns
dedup, so a future caller (a test, a second view) doesn't get a surprise
five-section render from `['aes','aes']`. Not blocking.
- LOW — the QA brief's "search inside every section" and "reveal-on-open of a
file" items don't correspond to implemented behaviour: search has always
been flat/section-independent (pre-existing, unchanged by §56), and no
file-open reveal feature exists in this extension at all (verified by grep
across `editors/vscode` for `onDidOpenTextDocument`/`activeTextEditor`/
`revealOnOpen`). Recorded here so the brief isn't silently treated as
satisfied; nothing to fix in the dev's code — the feature never promised
either shape.
- No MEDIUM or HIGH findings. Every shape in TODO §56, the model's own
Assumptions, and the rework's stated invariants held under direct testing,
fuzzing (200 random DUT selections over a random 40-module DAG), and a real
847-module snapshot.
**Verdict: PASS.** No rework needed. The two LOW items above are hygiene notes
for a later round, not conditions on this one.
## Review
**2026-09-06 — lead.** Accepted after one ruling; ships in 0.48.0. This is
the owner's request built as asked — star from the row menu, the DUT with
its children at the very top, its parents as an upward tree, all other
modules in one collapsible section, two sections per DUT plus one — and
built where it belongs, in the extension over the snapshot the server
already sends, with no server change. The one deviation (a webview row
menu rather than `view/item/context`, because the pane is a `WebviewView`)
delivers the intent exactly. The ruling: the first version's "others"
dropped any module reachable only through a DUT's ancestors — a monitor
beside the DUT under the same bench — which the owner's "any dangling
module not a child of the DUT" does not allow; the rework re-roots them,
and on opentitan that put five real modules under `aes_tb` back on screen,
with a walk over every section reaching all 847 modules in both
configurations and QA's 200-trial fuzz finding no overlap and no gap. The
setting-with-lock for a team's checked-in DUTs is a good addition. QA's
LOWs (a doc comment on `sections()`'s de-dup contract; two brief items
that name no shipped capability) need nothing.
## Docs to apply at merge (lead)
`docs/topo.md`: one new node, `dut-hierarchy`, with a single inbound edge from
`vscode-hierarchy-sidebar` (it consumes that feature's model and renderer and
adds nothing the server sees). No edge to any Rust crate — the server is
untouched by this round.
For `README.md`'s VS Code section and the site's editors page:
> **DUT-centred hierarchy.** Right-click a module in the Hierarchy pane and
> choose **Star as DUT**. The pane splits into sections: the DUT with its
> children, the DUT's parents (an upward tree through everything that
> instantiates it — usually the testbench), and every module in neither —
> including whatever the bench held beside the DUT, which that last section
> re-roots rather than hide. Star a
> second DUT and you get five sections. Unstar from the same menu, or clear
> every DUT from the pane's title bar. Starred DUTs are remembered per
> workspace; a team can also check them in with
> `"lucisv.hierarchy.duts": ["aes", "hmac"]`, and DUTs that come from the
> setting are shown locked.
+3
View File
@@ -21,6 +21,9 @@ hour. Record the release, the date and any failure in the table at the end.
| 12 | Old server: point `lucisv.server.path` at `~/.cache/lucisv-baselines/lucisv-0.39.0`'s sibling server if kept, else skip. | Extension warns about the version mismatch and still works. Reset the setting. |
| 13 | The other VSIX shape: install the `lucisv-<v>-universal.vsix` (no bundled server) with the CLI on PATH. | Same behaviour as steps 1–5. |
| 14 | Restart the server (command palette: "lucisv: Restart Server"). | Diagnostics return within a few seconds; no duplicate status items. |
| 15 | Hierarchy pane: right-click `aes` → "Star as DUT". | Three sections: "DUT: aes" (open, `aes` and its five children), "Parents of aes" (open, `aes` above `aes_tb`, `aes_wrap`, `tb`), "Other modules" (closed, 297 roots — the 292 plain ones plus the five `aes_tb` held beside `aes`, re-rooted). Right-click `aes` again → "Unstar DUT" puts the plain tree back exactly as it was. |
| 16 | Star `aes`, then `hmac`. | Five sections in that order; "Other modules" has 297 roots; each section opens and closes on its own; a module under both keeps its own open state in each. Title bar "Clear DUTs" removes both. |
| 17 | Add `"lucisv.hierarchy.duts": ["aes"]` to the workspace `.vscode/settings.json`. | The section appears without starring; right-clicking `aes` offers only a greyed "DUT from settings" whose tooltip names the setting; "Clear DUTs" leaves it. Remove the setting again. |
## Runs
+10 -1
View File
@@ -73,8 +73,17 @@
</script></div></div></div></div></nav><div class="main-frame astro-gqpr5s5a"><script type="module">var e=document.getElementById(`starlight__sidebar`),t=e?.querySelector(`sl-sidebar-state-persist`),n=`sl-sidebar-state`,r=()=>{let r=[],i=t?.dataset.hash||``;try{let e=sessionStorage.getItem(n),t=JSON.parse(e||`{}`);Array.isArray(t.open)&&t.hash===i&&(r=t.open)}catch{}return{hash:i,open:r,scroll:e?.scrollTop||0}},i=e=>{try{sessionStorage.setItem(n,JSON.stringify(e))}catch{}},a=()=>i(r()),o=(e,t)=>{let n=r();n.open[t]=e,i(n)};t?.addEventListener(`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`summary`)?.closest(`details`);if(!t)return;let n=t.querySelector(`sl-sidebar-restore`),r=parseInt(n?.dataset.index||``);isNaN(r)||o(!t.open,r)}),addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&a()});</script><div class="lg:sl-flex astro-abfeecmu"><aside class="right-sidebar-container print:hidden astro-abfeecmu"><div class="right-sidebar astro-abfeecmu"><div class="lg:sl-hidden astro-q5mffni3"><mobile-starlight-toc data-min-h="2" data-max-h="3" class="astro-5ulgm6bh"><nav aria-labelledby="starlight__on-this-page--mobile" class="astro-5ulgm6bh"><details id="starlight__mobile-toc" class="astro-5ulgm6bh"><summary id="starlight__on-this-page--mobile" class="sl-flex astro-5ulgm6bh"><span class="toggle sl-flex astro-5ulgm6bh">On this page<svg aria-hidden="true" class="caret astro-5ulgm6bh astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1rem;"><path d="m14.83 11.29-4.24-4.24a1 1 0 1 0-1.42 1.41L12.71 12l-3.54 3.54a1 1 0 0 0 0 1.41 1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.24-4.24a1.002 1.002 0 0 0 0-1.42Z"/></svg></span><span class="display-current astro-5ulgm6bh"></span></summary><div class="dropdown astro-5ulgm6bh"><ul class="isMobile astro-cxyftcne" style="--depth: 0;"><li style="--depth: 0;" class="astro-cxyftcne"><a href="#_top" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">Overview</span></a></li><li style="--depth: 0;" class="astro-cxyftcne"><a href="#vs-code" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">VS Code</span></a></li><li style="--depth: 0;" class="astro-cxyftcne"><a href="#neovim-011" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">Neovim 0.11+</span></a></li><li style="--depth: 0;" class="astro-cxyftcne"><a href="#workspace-indexing" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">Workspace indexing</span></a></li><li style="--depth: 0;" class="astro-cxyftcne"><a href="#smoke-test" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">Smoke test</span></a></li></ul></div></details></nav></mobile-starlight-toc><script type="module" src="/_astro/MobileTableOfContents.astro_astro_type_script_index_0_lang.BcSo_yiZ.js"></script></div><div class="right-sidebar-panel sl-hidden lg:sl-block astro-q5mffni3"><div class="sl-container astro-q5mffni3"><starlight-toc data-min-h="2" data-max-h="3"><nav aria-labelledby="starlight__on-this-page"><h2 id="starlight__on-this-page">On this page</h2><ul class="astro-cxyftcne" style="--depth: 0;"><li style="--depth: 0;" class="astro-cxyftcne"><a href="#_top" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">Overview</span></a></li><li style="--depth: 0;" class="astro-cxyftcne"><a href="#vs-code" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">VS Code</span></a></li><li style="--depth: 0;" class="astro-cxyftcne"><a href="#neovim-011" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">Neovim 0.11+</span></a></li><li style="--depth: 0;" class="astro-cxyftcne"><a href="#workspace-indexing" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">Workspace indexing</span></a></li><li style="--depth: 0;" class="astro-cxyftcne"><a href="#smoke-test" style="--depth: 0;" class="astro-cxyftcne"><span style="--depth: 0;" class="astro-cxyftcne">Smoke test</span></a></li></ul></nav></starlight-toc><script type="module" src="/_astro/TableOfContents.astro_astro_type_script_index_0_lang.Csloo1VZ.js"></script></div></div></div></aside><div class="main-pane astro-abfeecmu"><main data-pagefind-body class="astro-vdxcvpsm" lang="en" dir="ltr"><div class="content-panel astro-oil7k7jf"><div class="sl-container astro-oil7k7jf"><h1 id="_top" class="astro-2sm4b3ln">Editors &amp; LSP</h1></div></div><div class="content-panel astro-oil7k7jf"><div class="sl-container astro-oil7k7jf"><div class="sl-markdown-content"><p><code dir="auto">lucisv-server</code> is a synchronous language server over stdio. It keeps open buffers as in-memory overlays, updates the workspace index incrementally, and returns the same formatting and lint behaviLine truncated
<div class="sl-heading-wrapper level-h2"><h2 id="vs-code">VS Code</h2><a class="sl-anchor-link" href="#vs-code"><span aria-hidden="true" class="sl-anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 1 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 0 0-1.42-1.42m8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 1 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l3.88-3.89a4.49 4.49 0 0 0 0-6.33M8.83 15.17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.92-4.92a1 1 0 1 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42"></path></svg></span><span class="sr-only" data-pagefind-ignore>Section titled “VS Code”</span></a></div>
<p>Install the <code dir="auto">.vsix</code> attached to a lucisv release:</p>
<div class="expressive-code"><link rel="stylesheet" href="/_astro/ec.w36nc.css"><script type="module" src="/_astro/ec.0vx5m.js"></script><figure class="frame is-terminal not-content"><figcaption class="header"><span class="title"></span><span class="sr-only">Terminal window</span></figcaption><pre data-language="bash"><code><div class="ec-line"><div class="code"><span style="--0:#82AAFF;--1:#3B61B0">code</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#82AAFF;--1:#3B61B0">--install-extension</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#ECC48D;--1:#3B61B0">lucisv-0.9.0.vsix</span></div></div></code></pre><div class="copy"><div aria-live="polite"></div><button title="Copy to clipboard" data-copied="Copied!" data-code="code --install-extension lucisv-0.9.0.vsix"><div></div></button></div></figure></div>
<div class="expressive-code"><link rel="stylesheet" href="/_astro/ec.w36nc.css"><script type="module" src="/_astro/ec.0vx5m.js"></script><figure class="frame is-terminal not-content"><figcaption class="header"><span class="title"></span><span class="sr-only">Terminal window</span></figcaption><pre data-language="bash"><code><div class="ec-line"><div class="code"><span style="--0:#82AAFF;--1:#3B61B0">code</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#82AAFF;--1:#3B61B0">--install-extension</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#ECC48D;--1:#3B61B0">lucisv-&lt;version&gt;-darwin-arm64.vsix</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#919F9F;--1:#5F636F"># or the linux/windows package for your machine</span></div></div></code></pre><div class="copy"><div aria-live="polite"></div><button title="Copy to clipboard" data-copied="Copied!" data-code="code --install-extension lucisv-<version>-darwin-arm64.vsix # or the linux/windows package for your machine"><div></div></button></div></figure></div>
<p>The extension registers Verilog/SystemVerilog file types, syntax highlighting, snippets, color settings, configuration, and starts <code dir="auto">lucisv-server</code> from <code dir="auto">PATH</code> by default.</p>
<p><strong>DUT-centred hierarchy.</strong> Right-click a module in the Hierarchy pane and
choose <strong>Star as DUT</strong>. The pane splits into sections: the DUT with its
children, the DUT’s parents (an upward tree through everything that
instantiates it — usually the testbench), and all other modules, re-rooted
where their only parents are the DUT’s ancestors. Star a second DUT and you
get five sections. Unstar from the same menu, or clear every DUT from the
pane’s title bar. Starred DUTs are remembered per workspace; a team can also
check them in with <code dir="auto">"lucisv.hierarchy.duts": ["aes", "hmac"]</code>, and DUTs that
come from the setting are shown locked.</p>
<div class="sl-heading-wrapper level-h2"><h2 id="neovim-011">Neovim 0.11+</h2><a class="sl-anchor-link" href="#neovim-011"><span aria-hidden="true" class="sl-anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 1 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 0 0-1.42-1.42m8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 1 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l3.88-3.89a4.49 4.49 0 0 0 0-6.33M8.83 15.17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.92-4.92a1 1 0 1 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42"></path></svg></span><span class="sr-only" data-pagefind-ignore>Section titled “Neovim 0.11+”</span></a></div>
<div class="expressive-code"><figure class="frame not-content"><figcaption class="header"></figcaption><pre data-language="lua"><code><div class="ec-line"><div class="code"><span style="--0:#C5E478;--1:#3B61B0">vim</span><span style="--0:#D6DEEB;--1:#403F53">.filetype.</span><span style="--0:#C5E478;--1:#3B61B0">add</span><span style="--0:#D6DEEB;--1:#403F53">({ </span><span style="--0:#C5E478;--1:#3B61B0">extension</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#7FDBCA;--1:#096E72">=</span><span style="--0:#D6DEEB;--1:#403F53"> {</span></div></div><div class="ec-line"><div class="code"><span class="indent"> </span><span style="--0:#C5E478;--1:#3B61B0">v</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#7FDBCA;--1:#096E72">=</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">verilog</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#D6DEEB;--1:#403F53">, </span><span style="--0:#C5E478;--1:#3B61B0">vh</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#7FDBCA;--1:#096E72">=</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">verilog</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#D6DEEB;--1:#403F53">,</span></div></div><div class="ec-line"><div class="code"><span class="indent"> </span><span style="--0:#C5E478;--1:#3B61B0">sv</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#7FDBCA;--1:#096E72">=</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">systemverilog</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#D6DEEB;--1:#403F53">, </span><span style="--0:#C5E478;--1:#3B61B0">svh</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#7FDBCA;--1:#096E72">=</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">systemverilog</span><span style="--0:#D9F5DD;--1:#111111">'</span></div></div><div class="ec-line"><div class="code"><span style="--0:#D6DEEB;--1:#403F53">} })</span></div></div><div class="ec-line"><div class="code">
</div></div><div class="ec-line"><div class="code"><span style="--0:#C5E478;--1:#3B61B0">vim</span><span style="--0:#D6DEEB;--1:#403F53">.lsp.</span><span style="--0:#C5E478;--1:#3B61B0">config</span><span style="--0:#D6DEEB;--1:#403F53">(</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">lucisv</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#D6DEEB;--1:#403F53">, {</span></div></div><div class="ec-line"><div class="code"><span class="indent"> </span><span style="--0:#C5E478;--1:#3B61B0">cmd</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#7FDBCA;--1:#096E72">=</span><span style="--0:#D6DEEB;--1:#403F53"> { </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">lucisv-server</span><span style="--0:#D9F5DD;--1:#111111">' </span><span style="--0:#D6DEEB;--1:#403F53">},</span></div></div><div class="ec-line"><div class="code"><span class="indent"> </span><span style="--0:#C5E478;--1:#3B61B0">filetypes</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#7FDBCA;--1:#096E72">=</span><span style="--0:#D6DEEB;--1:#403F53"> { </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">verilog</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#D6DEEB;--1:#403F53">, </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">systemverilog</span><span style="--0:#D9F5DD;--1:#111111">' </span><span style="--0:#D6DEEB;--1:#403F53">},</span></div></div><div class="ec-line"><div class="code"><span class="indent"> </span><span style="--0:#C5E478;--1:#3B61B0">root_markers</span><span style="--0:#D6DEEB;--1:#403F53"> </span><span style="--0:#7FDBCA;--1:#096E72">=</span><span style="--0:#D6DEEB;--1:#403F53"> { </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">lucisv.toml</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#D6DEEB;--1:#403F53">, </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">.lucisv.toml</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#D6DEEB;--1:#403F53">, </span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">.git</span><span style="--0:#D9F5DD;--1:#111111">' </span><span style="--0:#D6DEEB;--1:#403F53">},</span></div></div><div class="ec-line"><div class="code"><span style="--0:#D6DEEB;--1:#403F53">})</span></div></div><div class="ec-line"><div class="code"><span style="--0:#C5E478;--1:#3B61B0">vim</span><span style="--0:#D6DEEB;--1:#403F53">.lsp.</span><span style="--0:#C5E478;--1:#3B61B0">enable</span><span style="--0:#D6DEEB;--1:#403F53">(</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#ECC48D;--1:#984E4D">lucisv</span><span style="--0:#D9F5DD;--1:#111111">'</span><span style="--0:#D6DEEB;--1:#403F53">)</span></div></div></code></pre><div class="copy"><div aria-live="polite"></div><button title="Copy to clipboard" data-copied="Copied!" data-code="vim.filetype.add({ extension = { v = &#x27;verilog&#x27;, vh = &#x27;verilog&#x27;, sv = &#x27;systemverilog&#x27;, svh = &#x27;systemverilog&#x27;} })vim.lsp.config(&#x27;lucisv&#x27;, { cmd = { &#x27;lucisv-server&#x27; }, filetypes = { &#x27;verilog&#x27;, &#x27;systemverilog&#x27; }, root_markers = { &#x27;lucisv.toml&#x27;, &#x27;.lucisv.toml&#x27;, &#x27;.git&#x27; },})vim.lsp.enable(&#x27;lucisv&#x27;)"><div></div></button></div></figure></div>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"version":"1.5.2","languages":{"en":{"hash":"en_63f86fa784","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]}
{"version":"1.5.2","languages":{"en":{"hash":"en_ccc426eeeb","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]}
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -352,4 +352,4 @@ index scope when the defining module lives outside the default folder scope.</p>
</table>
<div class="sl-heading-wrapper level-h2"><h2 id="workspace-lifecycle">Workspace lifecycle</h2><a class="sl-anchor-link" href="#workspace-lifecycle"><span aria-hidden="true" class="sl-anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 1 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 0 0-1.42-1.42m8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 1 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l3.88-3.89a4.49 4.49 0 0 0 0-6.33M8.83 15.17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.92-4.92a1 1 0 1 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42"></path></svg></span><span class="sr-only" data-pagefind-ignore>Section titled “Workspace lifecycle”</span></a></div>
<p>The server handles <code dir="auto">didOpen</code>, incremental <code dir="auto">didChange</code>, <code dir="auto">didSave</code>, <code dir="auto">didClose</code>, watched-file changes, configuration changes, cancellation, shutdown, and exit. It dynamically registers file watchers, emits work-done progress while building large indexes, coalesces code-lens refreshes, and promotes open-buffer overlays into the workspace without waiting for disk writes.</p>
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/language-tools.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-06T01:00:31.000Z">Sep 6, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/rules/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Lint rules</span></span></a><a href="/reference/rust-api/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Rust API index</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/language-tools.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-06T04:04:14.000Z">Sep 6, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/reference/rules/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Lint rules</span></span></a><a href="/reference/rust-api/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Rust API index</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
+11 -1
View File
@@ -10,11 +10,21 @@ description: Set up lucisv-server in VS Code, Neovim, Vim, and other Language Se
Install the `.vsix` attached to a lucisv release:
```bash
code --install-extension lucisv-0.9.0.vsix
code --install-extension lucisv-<version>-darwin-arm64.vsix # or the linux/windows package for your machine
```
The extension registers Verilog/SystemVerilog file types, syntax highlighting, snippets, color settings, configuration, and starts `lucisv-server` from `PATH` by default.
**DUT-centred hierarchy.** Right-click a module in the Hierarchy pane and
choose **Star as DUT**. The pane splits into sections: the DUT with its
children, the DUT's parents (an upward tree through everything that
instantiates it — usually the testbench), and all other modules, re-rooted
where their only parents are the DUT's ancestors. Star a second DUT and you
get five sections. Unstar from the same menu, or clear every DUT from the
pane's title bar. Starred DUTs are remembered per workspace; a team can also
check them in with `"lucisv.hierarchy.duts": ["aes", "hmac"]`, and DUTs that
come from the setting are shown locked.
## Neovim 0.11+
```lua
+1
View File
@@ -533,6 +533,7 @@ promise:
| `vscode-hierarchy-sidebar ◀──▶ index-persistence / hover-line-index / incremental-index` | handshake | **`FACTS_FORMAT` 4 → 5**, one bump for three additions: `Def::decl_span`; `InstantiationEdge::instances` (a `Vec<InstanceOccurrence>` — the statement edge stays one-per-statement, so call hierarchy and code-lens counts are unchanged and the census is still the one `instantiations::sites` walk); and client positions — `DeclLines::positions: Option<DeclPositions>` on **file-scope declarations only**, plus `Utf16Range` on every instance occurrence. Members deliberately carry none: they outnumber units by two orders of magnitude, and the `U`/`M` groups are separate, so a member costs no field at all. `FileFacts::from_analysis` grew a `src: &str` parameter (a position cannot be read off a line table). Measured store cost of the positions: +1.69 % on the 820-file corpus, +1.86 % on opentitan. |
| `vscode-hierarchy-sidebar ──▶ vlog_parser` | depends | `LineIndex::utf16_position` — byte offset to (0-based line, UTF-16 column), moved down beside the line table so the semantic index and `lucisv_server::convert::Positions` cannot answer differently. `Positions::position` is now a wrapper over it; the cross-crate equality is test-pinned. |
| `vscode-hierarchy-sidebar ◀──▶ workspace-index` | handshake | `WorkspaceIndex::units_of(kind)` — file-scope declarations of one kind, in name order, walking the unit table alone. The cheap half of `workspace_symbols("")` for a caller that never wants members; 15 ms per snapshot on opentitan. |
| `dut-hierarchy ──▶ vscode-hierarchy-sidebar` | depends | TODO §56 (2026-09-06): `hierarchySections.js` consumes the sidebar's model (`rootNode`, the reverse instance index memoised on the model) and its webview renderer's row menu; no edge to any Rust crate — the server is untouched. |
| `hover-line-index ──▶ port-detail-spans / index-persistence` | depends + handshake | `DeclLines { name, detail }` rides each indexed `Decl`, so ordinary and split-port hover headings do not reread a file just to compute a line. The record grew again and **`FACTS_FORMAT` went 3 → 4**; the server's bounded `FileView` cache supplies the text/`LineIndex` only when a snippet or a non-indexed position still needs it. Its four invalidation points are `set_document`, `close_document`, `update_one`, and a whole rebuild. |
| `scan-interleave ◀──▶ workspace-index` | handshake | A scan is a stepped `Scan` value; staged `FileFacts` land through `WorkspaceIndex::absorb`, one whole-index merge per queue drain rather than per file. `Candidates::absorb` and `IncludeGraph::absorb` publish their tables in the same drain, so “the workspace as far as scanned” cannot mean three different prefixes. |
| `scan-interleave ──▶ hover-line-index` | depends | Delivers hover-line-index's measured startup-wait request: a startup scan above 64 files drains queued messages between files. A rescan deliberately still holds requests; what an answer sees never depends on elapsed wall time. |
+2
View File
@@ -1,8 +1,10 @@
# The two checks are pre-publish/developer checks, not part of the shipped
# extension. `restart.js` itself IS shipped — `extension.js` requires it.
smoke.js
extract_test.js
restart_test.js
hierarchyModel_test.js
hierarchySections_test.js
hierarchyView_test.js
.vscode/**
.gitignore
+14
View File
@@ -5,6 +5,20 @@ 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.2 — 2026-09-06
- The 0.48.0 package was built without the DUT-centred hierarchy view
and 0.48.1 never built; 0.48.2 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
pane shows the DUT with its children at the top, its parents (the DV
bench) as an upward tree, and everything else in a collapsible
section. Star several; unstar from the same menu; or pin DUTs for the
team with `lucisv.hierarchy.duts`.
## 0.47.0 — 2026-09-06
- **Organize imports** on save or from the lightbulb: unused
+16 -1
View File
@@ -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.47.0**. Its platform packages include both
The current release is **0.48.2**. Its platform packages include both
`lucisv-server` and the `lucisv` command-line tool:
| Package target | Machines |
@@ -63,6 +63,13 @@ Most features work as soon as a supported file opens:
- Open the **lucisv** Activity Bar icon for an instance-oriented design tree.
Every level starts collapsed; its fixed search field fuzzy-matches module and
instance names in memory, and click or the instance context menu navigates.
- Right-click the module you actually work on and choose **Star as DUT**. The
pane splits into three collapsible sections — the DUT with its children, the
DUT's parents (an upward tree through everything that instantiates it, which
is usually the testbench), and every other module — including whatever the
bench held beside the DUT, which that last section re-roots rather than hide.
A second DUT adds two more sections. **Unstar DUT** from the same menu, or
**Clear DUTs** from the pane's title bar, puts the plain tree back.
- Hover a symbol, press `F12`, find references, search workspace symbols, or
open the call/type hierarchy using VS Code's standard commands.
- Type a module name at module-item scope to insert a complete instance. Inside
@@ -136,6 +143,7 @@ enabling both paths formats twice.
| Code lenses | Shows the workspace-wide instantiation count above every module/interface; click to jump to a site |
| Call hierarchy | Incoming calls answer “who instantiates this?”; outgoing calls answer “what does this instantiate?” |
| Design hierarchy sidebar | Alphabetical instance paths from every top-level module, collapsed until you open them, in-memory fuzzy module/instance search, exact instance/definition jumps, path copy, bookmark highlighting, and split-right opening |
| DUT sections | Star a module as DUT and the pane splits into its own subtree, an upward tree of everything that instantiates it, and every module in neither — two sections per DUT plus one. Stars are remembered per workspace; `lucisv.hierarchy.duts` is the checked-in list a team shares |
| Type hierarchy | Walks class `extends` relationships to supertypes and workspace subtypes |
### Highlighting and presentation
@@ -274,6 +282,7 @@ Server-side templates add `if`, `if/else`, `else if`, `case`, `for`, `while`,
| `lucisv.indent` | unset | Indent width, 1–8; falls back to the editor tab size, then 2 |
| `lucisv.exclude` | `[]` | Extra index exclusions added to the project's own patterns |
| `lucisv.filelist` | `""` | EDA `.f` filelist to index instead of walking the folder |
| `lucisv.hierarchy.duts` | `[]` | Modules the Hierarchy pane treats as DUTs, by name — the checked-in list a team shares. Each one adds two sections ahead of "Other modules"; a DUT from this setting is shown locked and can only be removed here |
| `lucisv.index.scope` | `folder` | Index the folders your open files live in, or every workspace folder with `workspace`; answers stay scope-relative until the scope reaches a folder |
| `lucisv.index.scopeDepth` | `0` | How many folders above an open file the `folder` scope starts from; `1` lets a file in `rtl/` index `include/` beside it |
| `lucisv.index.maxFileSize` | `1 MiB` | Largest walked file the index reads, in bytes; `0` removes the cap, and a file you open is always indexed in full |
@@ -365,6 +374,12 @@ Every nesting color is a proper VS Code theme color:
}
```
## Release 0.48.0 highlights
Version 0.48.0 makes the hierarchy pane DUT-centred: star a module and
see it with its children, its parents, and everything else in their own
sections.
## Release 0.47.0 highlights
Version 0.47.0 adds organize imports (with organize-on-save) and extract
+18 -2
View File
@@ -406,6 +406,7 @@ function searchRow(entry) {
id: searchId(entry),
kind: entry.kind,
label: searchLabel(entry),
moduleName: entry.kind === 'module' ? entry.module.moduleName : entry.instance.moduleName,
// Where the row lives, since a flat hit has no one path to show.
detail: entry.kind === 'module' ? 'module' : `in ${entry.module.moduleName}`,
depth: 0,
@@ -457,6 +458,9 @@ function treeRows(model, expanded, bookmarkPath) {
kind: node.kind,
label: node.label,
detail: node.detail,
// The module the row is about — for an instance, its type. What the DUT
// sections decide a row's context menu from.
moduleName: node.moduleName,
depth: node.depth,
hasChildren: node.hasChildren,
expanded: expanded.has(node.id),
@@ -528,13 +532,24 @@ function instanceNode(model, parent, instance) {
///
/// Walked from the roots rather than looked up in a table of every path,
/// because that table is the thing this file stopped building.
///
/// A DUT section's rows carry a path relative to the DUT (`aes.u_ctrl`), whose
/// head is a module no root walk can reach, so a head that names no root is
/// retried over every module. The roots-first order keeps every path that
/// resolved before resolving to exactly the same chain.
function bookmarkChain(model, path) {
if (typeof path !== 'string' || path === '') return undefined;
const [head, ...rest] = path.split('.');
const fromRoots = uniqueChain(model, model.roots.map(({ module }) => module), head, rest);
if (fromRoots) return fromRoots;
return uniqueChain(model, model.modules, head, rest);
}
function uniqueChain(model, modules, head, rest) {
let found;
for (const { module, fallback } of model.roots) {
for (const module of modules) {
if (module.moduleName !== head) continue;
const chain = descend(model, rootNode(model, module, fallback), rest);
const chain = descend(model, rootNode(model, module, false), rest);
if (!chain) continue;
if (found) return undefined; // the path names more than one row
found = chain;
@@ -567,6 +582,7 @@ module.exports = {
fuzzyScore,
idForPath,
locationKey,
rootNode,
searchHierarchy,
searchTarget,
treeRows,
+5
View File
@@ -109,6 +109,11 @@ function bookmarksResolveByPathWithoutATableOfEveryPath() {
assert.equal(idForPath(model, 'TB.dut.inst1.inst2'), chain[3]);
assert.equal(idForPath(model, 'TB.dut.nope'), undefined);
assert.equal(idForPath(model, ''), undefined);
// A head that names no root is retried over every module, because a row in a
// DUT section carries a path relative to the DUT (§56). Roots still win: the
// chains above are the ones a root walk produced.
assert.equal(bookmarkChain(model, 'block.inst2').length, 2);
assert.equal(bookmarkChain(model, 'block.nope'), undefined);
// Expanding the chain's ancestors is what reveals the row.
const { rows } = treeRows(model, new Set(chain.slice(0, -1)), 'TB.dut.inst1.inst2');
assert.equal(rows.filter((row) => row.bookmarked).length, 1);
+460
View File
@@ -0,0 +1,460 @@
// DUT-centred sections over the flat hierarchy model. A design holds hundreds
// of modules and one — or a few — that matter: the DUT, usually with a
// testbench above it. Starring a module splits the pane into, per DUT, its
// forward subtree and an upward tree of everything that instantiates it, and
// then one section for every module that is in neither. No `vscode` dependency,
// so plain Node tests cover all of it. See
// docs/features/dut-hierarchy/README.md.
//
// **Nothing here materializes a tree.** Sections are composed out of the same
// lazily-expanded nodes `hierarchyModel.js` builds: a section holds one root
// node, and the level below a row is built when the user opens it. The one
// thing built per snapshot is the reverse index — module → the instances that
// name it — which is a single pass over the modules already resident.
//
// Ids are prefixed per section (`dut:aes/root:file#1:7`), and every descendant
// id is derived from its parent's, so one prefix moves a whole subtree into its
// own section. That is what lets a module that is below one DUT and above
// another appear in both sections and open independently in each.
const { childrenOf, idForPath, rootNode } = require('./hierarchyModel');
/** The menu items an instance row has always offered, in their fixed order. */
const INSTANCE_ACTIONS = [
{ action: 'copyPath', label: 'Copy Full Path' },
{ action: 'definition', label: 'Show Definition' },
{ action: 'instance', label: 'Show Instance' },
{ action: 'bookmark', label: 'Highlight / Bookmark' },
{ action: 'openRight', label: 'Open on the Right' },
];
const STAR = { action: 'starDut', label: 'Star as DUT' };
const UNSTAR = { action: 'unstarDut', label: 'Unstar DUT' };
/** A DUT the workspace settings name cannot be unstarred from the pane, because
* the pane will not edit a checked-in file on the user's behalf. */
const LOCKED = {
action: 'lockedDut',
label: 'DUT from settings',
disabled: true,
title: 'This DUT comes from the lucisv.hierarchy.duts setting. Remove it there to unstar it.',
};
function compareText(a, b) {
const foldedA = a.toLowerCase();
const foldedB = b.toLowerCase();
if (foldedA < foldedB) return -1;
if (foldedA > foldedB) return 1;
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
function compareEdges(a, b) {
return compareText(a.module.moduleName, b.module.moduleName)
|| compareText(a.instance.instanceName, b.instance.instanceName)
|| compareText(a.instance.site.uri, b.instance.site.uri)
|| a.instance.site.selectionRange.start.line - b.instance.site.selectionRange.start.line;
}
/// Module id → the `{ module, instance }` edges that instantiate it, in a
/// deterministic order. One pass per snapshot, memoized on the model, because
/// the upward tree asks this question once per opened row.
function parentIndex(model) {
if (model.parentsByTarget) return model.parentsByTarget;
const index = new Map();
for (const module of model.modules) {
for (const instance of module.instances) {
if (!instance.targetId) continue;
const found = index.get(instance.targetId) || [];
found.push({ module, instance });
index.set(instance.targetId, found);
}
}
for (const edges of index.values()) edges.sort(compareEdges);
model.parentsByTarget = index;
return index;
}
/// The declarations of a starred name: the first one is what the sections show,
/// and more than one makes the section ambiguous.
function declarationsNamed(model, name) {
return model.modules.filter((module) => module.moduleName === name);
}
/// The section list §56 specifies: per starred DUT, in starred order, its
/// forward subtree and its upward tree, then everything else.
function sections(model, duts) {
const list = [];
const excluded = new Set();
for (const name of duts) {
const found = declarationsNamed(model, name);
const [module] = found;
list.push(dutSection(model, name, module, found.length > 1));
list.push(parentsSection(model, name, module, found.length > 1));
if (!module) continue;
collectSubtree(model, module, excluded);
collectAncestors(model, module, excluded);
}
list.push({ kind: 'others', roots: othersRoots(model, excluded) });
return list;
}
/// The `others` section's roots. "All other modules" is **additive**: `others`
/// holds every module that is in no DUT's forward subtree and no DUT's ancestor
/// closure — not `model.roots` minus that set. A monitor the DV bench
/// instantiates beside the DUT is not a child of the DUT, so it belongs here;
/// the exclusion took away every parent it had, so it is re-rooted at the top
/// of the section rather than dropped out of the pane.
///
/// The roots are the members of that set with no parent left inside it. A
/// module that still has one is shown under that parent, so nothing appears
/// twice: reachable from one excluded and one ordinary parent, it stays where
/// it always was. Nothing appears twice the long way round either — a path from
/// one module of the set to another cannot leave it, because a module *above*
/// an ancestor of the DUT is itself an ancestor and a module *below* the DUT's
/// subtree is itself in it, and both are excluded. Roots come out in the
/// model's own order — alphabetically, then the ones only a cycle reaches,
/// which is what `model.roots` does.
///
/// A root's forward subtree is the plain one, **unfiltered**: a module that is
/// also below a DUT is still shown under its parent here, exactly as it is
/// today. A DUT itself can never turn up in it — everything that instantiates a
/// DUT is in that DUT's ancestor closure and is therefore excluded from the set
/// this walks.
function othersRoots(model, excluded) {
const plain = new Set();
const recursive = new Set();
const covered = new Set();
const take = (module, into) => {
into.add(module.id);
coverSubtree(model, module, covered);
};
// The pane's own roots, minus the excluded: with nothing starred this is the
// whole answer and it is byte-identical to `model.roots`.
for (const { module, fallback } of model.roots) {
if (!excluded.has(module.id)) take(module, fallback ? recursive : plain);
}
// Then what the exclusion orphaned: every parent it has is inside a DUT
// section, and no root reaches it, so this is the only place left to show it.
for (const module of model.modules) {
if (excluded.has(module.id) || covered.has(module.id)) continue;
if (hasParentInOthers(model, module, excluded)) continue;
take(module, plain);
}
// Whatever is still unreached is inside a recursive component that no root
// enters — the model's own fallback rule, marked the way it marks it.
for (const module of model.modules) {
if (excluded.has(module.id) || covered.has(module.id)) continue;
take(module, recursive);
}
const roots = model.modules.filter((module) => plain.has(module.id))
.map((module) => ({ module, fallback: false }));
for (const module of model.modules) {
if (recursive.has(module.id)) roots.push({ module, fallback: true });
}
return roots;
}
/// Does a module the `others` set still holds instantiate this one? Then it is
/// already on screen under that module and must not be re-rooted beside it.
function hasParentInOthers(model, module, excluded) {
return (parentIndex(model).get(module.id) || [])
.some((edge) => !excluded.has(edge.module.id));
}
/// Everything an `others` root puts on screen: its forward subtree over the
/// module graph, excluded modules included, because that subtree is not
/// filtered. A module already covered was descended through, so is everything
/// below it — which is what keeps the whole pass linear.
function coverSubtree(model, start, covered) {
const stack = [start];
while (stack.length > 0) {
const module = stack.pop();
if (covered.has(module.id)) continue;
covered.add(module.id);
for (const instance of module.instances) {
const target = instance.targetId && model.byId.get(instance.targetId);
if (target) stack.push(target);
}
}
}
function dutSection(model, name, module, ambiguous) {
if (!module) return { kind: 'dut', name, root: undefined, ambiguous };
// Exactly the node the plain view would show for this module, including its
// `recursive` marking when the module is only a root because of a cycle.
const plain = model.roots.find((root) => root.module.id === module.id);
const root = rootNode(model, module, Boolean(plain && plain.fallback));
root.id = `${prefixFor('dut', name)}${root.id}`;
return { kind: 'dut', name, root, ambiguous };
}
function parentsSection(model, name, module, ambiguous) {
if (!module) return { kind: 'parents', name, root: undefined, ambiguous };
return { kind: 'parents', name, root: upRootNode(model, name, module), ambiguous };
}
/// The DUT itself, as the root of the upward tree.
function upRootNode(model, name, module) {
return {
id: `${prefixFor('parents', name)}up:${module.id}`,
kind: 'module',
up: true,
moduleName: module.moduleName,
label: module.moduleName,
detail: '',
depth: 0,
parentId: null,
fullPath: undefined,
hasChildren: (parentIndex(model).get(module.id) || []).length > 0,
warning: false,
definition: module.definition,
definitions: [module.definition],
site: undefined,
moduleId: module.id,
seen: new Set([module.id]),
};
}
/// One module that instantiates `parent`'s module, named by the instance that
/// does it. A module already on the path upward closes a cycle: it is shown,
/// marked, and does not open again — the forward tree's rule, upside down.
function upNode(model, parent, { module, instance }) {
const repeated = parent.seen.has(module.id);
const seen = new Set(parent.seen);
seen.add(module.id);
return {
id: `${parent.id}>${instance.id}`,
kind: 'module',
up: true,
moduleName: module.moduleName,
instanceName: instance.instanceName,
label: module.moduleName,
detail: repeated ? 'recursive' : `via ${instance.instanceName}`,
depth: parent.depth + 1,
parentId: parent.id,
fullPath: undefined,
hasChildren: !repeated && (parentIndex(model).get(module.id) || []).length > 0,
warning: repeated,
definition: module.definition,
definitions: [module.definition],
site: instance.site,
moduleId: module.id,
seen,
};
}
/// The level below a row, whichever direction its section runs in.
function childrenIn(model, node) {
if (!node.up) return childrenOf(model, node);
return (parentIndex(model).get(node.moduleId) || [])
.map((edge) => upNode(model, node, edge));
}
/// Every module reachable downward from the DUT, over the module graph rather
/// than the expanded tree, so a diamond costs one visit and a cycle terminates.
///
/// The visited set is this walk's own, not the shared `into`: a module already
/// in `into` may have been put there as another DUT's *ancestor*, in which case
/// nothing below it has been collected yet and stopping there would leave the
/// exclusion short.
function collectSubtree(model, start, into) {
const stack = [start];
const seen = new Set();
while (stack.length > 0) {
const module = stack.pop();
if (seen.has(module.id)) continue;
seen.add(module.id);
into.add(module.id);
for (const instance of module.instances) {
const target = instance.targetId && model.byId.get(instance.targetId);
if (target) stack.push(target);
}
}
}
/// The same walk upward: every module that instantiates the DUT, transitively.
function collectAncestors(model, start, into) {
const index = parentIndex(model);
const stack = [start];
const seen = new Set();
while (stack.length > 0) {
const module = stack.pop();
if (seen.has(module.id)) continue;
seen.add(module.id);
into.add(module.id);
for (const edge of index.get(module.id) || []) stack.push(edge.module);
}
}
/// The id prefix a DUT's two sections stamp on their rows. The bookmark's
/// ancestor expansion needs them: the chain the model resolves is unprefixed,
/// and the copy of it inside a section is the same chain behind one of these.
function sectionPrefixes(duts) {
return duts.flatMap((name) => [prefixFor('dut', name), prefixFor('parents', name)]);
}
function prefixFor(kind, name) {
return `${kind}:${name}/`;
}
/** The `others` section's row id; it has no DUT name to be keyed by. */
const OTHERS_ID = 'sec:others';
function headerId(section) {
return section.kind === 'others' ? OTHERS_ID : `sec:${section.kind}:${section.name}`;
}
/// What a star opens on the user's behalf, once, when the DUT list changes: the
/// two new sections and the DUT row at the top of each. Starring is an explicit
/// act — the second exception to "nothing expands by itself", after a
/// bookmark's ancestor chain.
function defaultOpenIds(list) {
const ids = [];
for (const section of list) {
if (section.kind === 'others') continue;
ids.push(headerId(section));
if (section.root) ids.push(section.root.id);
}
return ids;
}
function headerLabel(section) {
if (section.kind === 'dut') return `DUT: ${section.name}`;
if (section.kind === 'parents') return `Parents of ${section.name}`;
return 'Other modules';
}
function headerIcon(section) {
if (section.kind === 'dut') return '★';
return section.kind === 'parents' ? '↑' : '▤';
}
function headerDetail(section) {
if (section.kind === 'others') return `${section.roots.length}`;
return section.ambiguous ? 'ambiguous' : '';
}
/// The rows the sectioned tree shows: every section header, and under an open
/// header the rows of its tree. Same shape as `treeRows`, one level deeper.
function sectionRows(model, list, expanded, bookmarkPath) {
const rows = [];
const nodes = new Map();
const bookmarkId = bookmarkPath ? idForPath(model, bookmarkPath) : undefined;
function push(node) {
nodes.set(node.id, node);
rows.push({
id: node.id,
kind: node.kind,
label: node.label,
detail: node.detail,
moduleName: node.moduleName,
depth: node.depth + 1,
hasChildren: node.hasChildren,
expanded: expanded.has(node.id),
warning: node.warning,
bookmarked: isBookmarked(node.id, bookmarkId),
});
if (!expanded.has(node.id) || !node.hasChildren) return;
for (const child of childrenIn(model, node)) push(child);
}
for (const section of list) {
const id = headerId(section);
rows.push({
id,
kind: 'section',
label: headerLabel(section),
detail: headerDetail(section),
icon: headerIcon(section),
depth: 0,
hasChildren: true,
expanded: expanded.has(id),
warning: false,
bookmarked: false,
});
if (!expanded.has(id)) continue;
if (section.kind === 'others') {
for (const root of section.roots) push(rootNode(model, root.module, root.fallback));
} else if (section.root) {
push(section.root);
} else {
rows.push(missingRow(section, id));
}
}
return { rows, nodes, bookmarkId };
}
/// A starred name the snapshot no longer holds keeps its sections rather than
/// vanishing silently: the user renamed or deleted the module and needs to see
/// that, not a pane that quietly forgot what they starred.
function missingRow(section, id) {
return {
id: `${id}/missing`,
kind: 'notice',
label: `${section.name} is not in the index`,
detail: '',
icon: '⚠',
depth: 1,
hasChildren: false,
expanded: false,
warning: true,
bookmarked: false,
};
}
/// A bookmark is a path from a root, and the same path exists once per section
/// that contains it — behind that section's prefix.
function isBookmarked(id, bookmarkId) {
if (!bookmarkId) return false;
return id === bookmarkId || id.endsWith(`/${bookmarkId}`);
}
/// What a row's menu is chosen by: its kind, whether its module is a DUT, and
/// whether that DUT came from the settings rather than from a star.
function decorate(rows, duts, locked) {
const starred = new Set(duts);
const fromSettings = new Set(locked);
return rows.map((row) => {
if (row.kind === 'section' || row.kind === 'notice') {
return { ...row, contextValue: row.kind };
}
if (!row.moduleName || !starred.has(row.moduleName)) {
return { ...row, contextValue: row.kind };
}
if (!fromSettings.has(row.moduleName)) {
return { ...row, contextValue: `${row.kind}.dut` };
}
return { ...row, contextValue: `${row.kind}.dut.locked`, title: LOCKED.title };
});
}
/// `contextValue` → the menu that row offers. Sent once per render, so the
/// renderer holds no rule of its own and this table is the whole contract.
function menuTable() {
return {
section: [],
notice: [],
module: [STAR],
'module.dut': [UNSTAR],
'module.dut.locked': [LOCKED],
instance: [...INSTANCE_ACTIONS, STAR],
'instance.dut': [...INSTANCE_ACTIONS, UNSTAR],
'instance.dut.locked': [...INSTANCE_ACTIONS, LOCKED],
};
}
module.exports = {
LOCKED,
OTHERS_ID,
decorate,
defaultOpenIds,
menuTable,
parentIndex,
sectionPrefixes,
sectionRows,
sections,
};
+622
View File
@@ -0,0 +1,622 @@
const assert = require('assert/strict');
const fs = require('fs');
const path = require('path');
const { buildHierarchy, treeRows } = require('./hierarchyModel');
const {
LOCKED,
decorate,
defaultOpenIds,
menuTable,
sectionPrefixes,
sectionRows,
sections,
} = require('./hierarchySections');
// The same schema-2 wire the model tests use: a file table, four-number ranges,
// no ids and no per-instance `definitions`.
function site(file, line, start, end) {
return { file, range: [line, 0, line, end + 3], selectionRange: [line, start, line, end] };
}
/** A DV bench above a DUT above three leaves, plus two unrelated modules. */
function fixture() {
const files = [
'file:///tb.sv', 'file:///dut.sv', 'file:///l1.sv', 'file:///l2.sv',
'file:///l3.sv', 'file:///lonely.sv', 'file:///other.sv',
];
return {
schemaVersion: 2,
revision: 7,
complete: true,
files,
modules: [
{ moduleName: 'tb', definition: site(0, 0, 7, 9), instances: [
{ instanceName: 'u_dut', moduleName: 'dut', site: site(0, 1, 4, 9) },
] },
{ moduleName: 'dut', definition: site(1, 0, 7, 10), instances: [
{ instanceName: 'u_l1', moduleName: 'leaf1', site: site(1, 1, 6, 10) },
{ instanceName: 'u_l2', moduleName: 'leaf2', site: site(1, 2, 6, 10) },
{ instanceName: 'u_l3', moduleName: 'leaf3', site: site(1, 3, 6, 10) },
] },
{ moduleName: 'leaf1', definition: site(2, 0, 7, 12), instances: [] },
{ moduleName: 'leaf2', definition: site(3, 0, 7, 12), instances: [] },
{ moduleName: 'leaf3', definition: site(4, 0, 7, 12), instances: [] },
{ moduleName: 'lonely', definition: site(5, 0, 7, 13), instances: [] },
{ moduleName: 'other_top', definition: site(6, 0, 7, 16), instances: [] },
],
};
}
/** A snapshot from `{ module: [instantiated type, …] }`: one file and one
* declaration per module, and one instance `u_<type>` per named type. */
function graph(spec) {
const names = Object.keys(spec);
return {
schemaVersion: 2,
revision: 1,
complete: true,
files: names.map((name) => `file:///${name}.sv`),
modules: names.map((name, at) => ({
moduleName: name,
definition: site(at, 0, 7, 7 + name.length),
instances: spec[name].map((type, index) => ({
instanceName: `u_${type}`,
moduleName: type,
site: site(at, index + 1, 4, 9),
})),
})),
};
}
/** Every id in a section list, opened all the way down. */
function openEverything(model, list) {
const expanded = new Set();
for (let pass = 0; pass < 12; pass += 1) {
const { rows } = sectionRows(model, list, expanded, '');
const before = expanded.size;
for (const row of rows) if (row.hasChildren) expanded.add(row.id);
if (expanded.size === before) break;
}
return sectionRows(model, list, expanded, '');
}
function shape(model, list) {
return openEverything(model, list).rows.map((row) => `${' '.repeat(row.depth)}${row.label}`);
}
function noDutIsOneSectionAndThePlainRoots() {
const model = buildHierarchy(fixture());
const list = sections(model, []);
assert.equal(list.length, 1, 'zero DUTs is the others section on its own');
assert.equal(list[0].kind, 'others');
assert.deepEqual(
list[0].roots.map(({ module }) => module.moduleName),
model.roots.map(({ module }) => module.moduleName),
'and it holds exactly today’s roots',
);
}
function oneDutIsThreeSectionsAndTwoAreFive() {
const model = buildHierarchy(fixture());
const one = sections(model, ['dut']);
assert.deepEqual(one.map((section) => section.kind), ['dut', 'parents', 'others']);
const two = sections(model, ['dut', 'other_top']);
assert.deepEqual(
two.map((section) => `${section.kind}:${section.name || ''}`),
['dut:dut', 'parents:dut', 'dut:other_top', 'parents:other_top', 'others:'],
'per DUT its own two sections, in starred order, then one others',
);
}
function theDutSectionIsTheForwardSubtreeAndTheParentsSectionIsTheUpwardTree() {
const model = buildHierarchy(fixture());
const list = sections(model, ['dut']);
assert.deepEqual(shape(model, list), [
'DUT: dut',
' dut',
' u_l1 (leaf1)',
' u_l2 (leaf2)',
' u_l3 (leaf3)',
'Parents of dut',
' dut',
' tb',
'Other modules',
' lonely',
' other_top',
]);
// The upward row says which instance reaches the DUT, and points at the
// instantiating module's own declaration.
const { rows, nodes } = openEverything(model, list);
const upward = rows.find((row) => row.label === 'tb' && row.depth === 2);
assert.equal(upward.detail, 'via u_dut');
const node = nodes.get(upward.id);
assert.equal(node.definition.uri, 'file:///tb.sv', 'the parent module’s declaration');
assert.equal(node.site.uri, 'file:///tb.sv');
assert.equal(node.kind, 'module');
// The DUT's own subtree is the node the plain view shows for it: same
// children, same order, same labels.
const plainDut = treeRows(model, new Set(), '').rows;
assert(!plainDut.some((row) => row.label === 'dut'), 'dut is not a root of the plain view');
const dutRows = rows.filter((row) => row.depth >= 2 && row.id.startsWith('dut:dut/'));
assert.deepEqual(dutRows.map((row) => row.label), ['u_l1 (leaf1)', 'u_l2 (leaf2)', 'u_l3 (leaf3)']);
}
function othersHoldsEveryModuleOutsideEveryDut() {
const model = buildHierarchy(fixture());
const [, , others] = sections(model, ['dut']);
assert.deepEqual(
others.roots.map(({ module }) => module.moduleName),
['lonely', 'other_top'],
'tb is above the DUT and is gone; the two unrelated roots stay',
);
// A leaf is below the DUT and was never a root, so nothing changed for it;
// what the exclusion actually removes is the ancestor root.
const plainRoots = model.roots.map(({ module }) => module.moduleName);
assert.deepEqual(plainRoots, ['lonely', 'other_top', 'tb']);
// Starring a leaf takes `tb` (an ancestor) and `dut` (an ancestor) out, which
// leaves the two *other* leaves with no parent on screen: they are not below
// the DUT, so others re-roots them, in the model's alphabetical order.
const [, , leafOthers] = sections(model, ['leaf2']);
assert.deepEqual(
leafOthers.roots.map(({ module }) => module.moduleName),
['leaf1', 'leaf3', 'lonely', 'other_top'],
);
}
/** The bench beside the DUT: `monitor` is not a child of the DUT, so it is in
* others — re-rooted, because the exclusion took its only parent. */
function aModuleUnderAnExcludedBenchIsReRootedInOthers() {
const model = buildHierarchy(graph({
bench: ['dut', 'monitor'], dut: ['leaf'], monitor: ['probe'], leaf: [], probe: [], spare: [],
}));
const list = sections(model, ['dut']);
const [, , others] = list;
assert.deepEqual(others.roots.map(({ module }) => module.moduleName), ['monitor', 'spare']);
assert.deepEqual(shape(model, list), [
'DUT: dut',
' dut',
' u_leaf (leaf)',
'Parents of dut',
' dut',
' bench',
'Other modules',
' monitor',
' u_probe (probe)',
' spare',
]);
// Nothing the snapshot holds is off screen while the DUT is starred.
const shown = new Set(shape(model, list).map((line) => line.trim().replace(/^.*\((.*)\)$/, '$1')));
for (const module of model.modules) {
assert(shown.has(module.moduleName), `${module.moduleName} is in no section`);
}
}
/** Two benches instantiate one module and both are excluded: it is re-rooted
* once, not once per bench. */
function aModuleUnderTwoExcludedBenchesIsReRootedOnce() {
const model = buildHierarchy(graph({
bench_a: ['dut', 'shared'], bench_b: ['dut', 'shared'], dut: [], shared: [],
}));
const [, , others] = sections(model, ['dut']);
assert.deepEqual(others.roots.map(({ module }) => module.moduleName), ['shared']);
assert.equal(others.roots.length, 1);
}
/** One excluded parent and one ordinary one: the module keeps its place under
* the ordinary parent and is not re-rooted beside it. */
function aModuleWithOneOrdinaryParentIsNotReRooted() {
const model = buildHierarchy(graph({
bench: ['dut', 'util'], top: ['util'], dut: [], util: [],
}));
const list = sections(model, ['dut']);
const [, , others] = list;
assert.deepEqual(others.roots.map(({ module }) => module.moduleName), ['top']);
assert.deepEqual(shape(model, list), [
'DUT: dut',
' dut',
'Parents of dut',
' dut',
' bench',
'Other modules',
' top',
' u_util (util)',
]);
const util = shape(model, list).filter((line) => line.includes('util'));
assert.equal(util.length, 1, 'shown once, under the parent it always had');
}
/** DUT2's bench is a sibling of DUT1 under one top bench: both are excluded,
* and the monitor beside DUT2 is the only thing others re-roots. */
function twoDutsSharingABenchLeaveOthersCorrect() {
const model = buildHierarchy(graph({
bench: ['dut1', 'sub_bench'], sub_bench: ['dut2', 'monitor'],
dut1: [], dut2: [], monitor: [], spare: [],
}));
const list = sections(model, ['dut1', 'dut2']);
assert.equal(list.length, 5);
assert.deepEqual(shape(model, list), [
'DUT: dut1',
' dut1',
'Parents of dut1',
' dut1',
' bench',
'DUT: dut2',
' dut2',
'Parents of dut2',
' dut2',
' sub_bench',
' bench',
'Other modules',
' monitor',
' spare',
]);
}
/** A cycle whose only way in is an excluded bench: no member has a parent
* outside it, so others opens it at the model's own fallback root. */
function aCycleReachableOnlyThroughAnExcludedBenchStillHasARoot() {
const model = buildHierarchy(graph({
bench: ['dut', 'a'], a: ['b'], b: ['a'], dut: [],
}));
const list = sections(model, ['dut']);
const [, , others] = list;
assert.deepEqual(others.roots.map(({ module }) => module.moduleName), ['a']);
assert.equal(others.roots[0].fallback, true, 'marked recursive, as the plain view marks it');
assert.deepEqual(shape(model, list), [
'DUT: dut',
' dut',
'Parents of dut',
' dut',
' bench',
'Other modules',
' a',
' u_b (b)',
' u_a (a)',
]);
}
/** `mid` is below DUT1 and above DUT2: it belongs to both DUT sections and to
* neither others. */
function aModuleBothBelowOneDutAndAboveAnotherIsInBothSections() {
const model = buildHierarchy({
schemaVersion: 2,
revision: 1,
complete: true,
files: ['file:///top.sv', 'file:///mid.sv', 'file:///low.sv', 'file:///spare.sv'],
modules: [
{ moduleName: 'top', definition: site(0, 0, 7, 10), instances: [
{ instanceName: 'u_mid', moduleName: 'mid', site: site(0, 1, 4, 9) },
] },
{ moduleName: 'mid', definition: site(1, 0, 7, 10), instances: [
{ instanceName: 'u_low', moduleName: 'low', site: site(1, 1, 4, 9) },
] },
{ moduleName: 'low', definition: site(2, 0, 7, 10), instances: [] },
{ moduleName: 'spare', definition: site(3, 0, 7, 12), instances: [] },
],
});
const list = sections(model, ['top', 'low']);
assert.deepEqual(shape(model, list), [
'DUT: top',
' top',
' u_mid (mid)',
' u_low (low)',
'Parents of top',
' top',
'DUT: low',
' low',
'Parents of low',
' low',
' mid',
' top',
'Other modules',
' spare',
]);
const [, , , , others] = list;
assert.deepEqual(others.roots.map(({ module }) => module.moduleName), ['spare']);
// The same module in two sections is two rows with two ids, so opening one
// never opens the other.
const { rows } = openEverything(model, list);
const midRows = rows.filter((row) => row.label.includes('mid'));
assert.equal(midRows.length, 2);
assert.equal(new Set(midRows.map((row) => row.id)).size, 2);
assert(midRows.some((row) => row.id.startsWith('dut:top/')));
assert(midRows.some((row) => row.id.startsWith('parents:low/')));
}
/** `a` instantiates `b` instantiates `a`: the upward walk cuts the cycle with
* its visited set, exactly as the forward walk does. */
function theParentsWalkCutsACycle() {
const model = buildHierarchy({
schemaVersion: 2,
revision: 1,
complete: true,
files: ['file:///a.sv', 'file:///b.sv'],
modules: [
{ moduleName: 'a', definition: site(0, 0, 7, 8), instances: [
{ instanceName: 'u_b', moduleName: 'b', site: site(0, 1, 4, 7) },
] },
{ moduleName: 'b', definition: site(1, 0, 7, 8), instances: [
{ instanceName: 'u_a', moduleName: 'a', site: site(1, 1, 4, 7) },
] },
],
});
const list = sections(model, ['a']);
assert.deepEqual(shape(model, list), [
'DUT: a',
' a',
' u_b (b)',
' u_a (a)',
'Parents of a',
' a',
' b',
' a',
'Other modules',
]);
const { rows } = openEverything(model, list);
const cut = rows.filter((row) => row.id.startsWith('parents:a/') && row.detail === 'recursive');
assert.equal(cut.length, 1, 'the edge that closes the cycle is marked once');
assert.equal(cut[0].label, 'a');
assert.equal(cut[0].hasChildren, false, 'and does not open again');
assert.equal(cut[0].warning, true);
}
function aStarredNameTheSnapshotLacksKeepsItsSections() {
const model = buildHierarchy(fixture());
const list = sections(model, ['renamed_away']);
assert.equal(list.length, 3, 'a missing DUT still costs three sections');
assert.equal(list[0].root, undefined);
assert.deepEqual(shape(model, list), [
'DUT: renamed_away',
' renamed_away is not in the index',
'Parents of renamed_away',
' renamed_away is not in the index',
'Other modules',
' lonely',
' other_top',
' tb',
' u_dut (dut)',
' u_l1 (leaf1)',
' u_l2 (leaf2)',
' u_l3 (leaf3)',
]);
const notice = openEverything(model, list).rows.find((row) => row.kind === 'notice');
assert.equal(notice.hasChildren, false);
assert.equal(notice.warning, true);
}
function twoDeclarationsOfOneNameAreMarkedAmbiguous() {
const raw = fixture();
raw.files.push('file:///dut-again.sv');
raw.modules.push({ moduleName: 'dut', definition: site(7, 0, 7, 10), instances: [] });
const model = buildHierarchy(raw);
const [dut, parents] = sections(model, ['dut']);
assert.equal(dut.ambiguous, true);
assert.equal(parents.ambiguous, true);
assert(dut.root, 'the first declaration in the model’s order is what is shown');
const header = sectionRows(model, [dut], new Set(), '').rows[0];
assert.equal(header.detail, 'ambiguous');
}
function sectionsAreCollapsedUntilOpenedAndOnlyTheDutOnesOpenByDefault() {
const model = buildHierarchy(fixture());
const list = sections(model, ['dut']);
const closed = sectionRows(model, list, new Set(), '');
assert.deepEqual(
closed.rows.map((row) => row.label),
['DUT: dut', 'Parents of dut', 'Other modules'],
'a closed section builds none of its tree',
);
assert(closed.rows.every((row) => row.kind === 'section' && row.hasChildren && !row.expanded));
const seeded = new Set(defaultOpenIds(list));
assert.deepEqual([...seeded], ['sec:dut:dut', 'dut:dut/root:file:///dut.sv#0:7',
'sec:parents:dut', 'parents:dut/up:file:///dut.sv#0:7']);
assert(!seeded.has('sec:others'), 'others is not opened for the user');
assert.deepEqual(
sectionRows(model, list, seeded, '').rows.map((row) => row.label),
['DUT: dut', 'dut', 'u_l1 (leaf1)', 'u_l2 (leaf2)', 'u_l3 (leaf3)',
'Parents of dut', 'dut', 'tb', 'Other modules'],
'starring opens the two sections and the DUT row inside each, one level',
);
}
function sectionRowsMatchTheShapeTheViewAlreadyRenders() {
const model = buildHierarchy(fixture());
const list = sections(model, ['dut']);
const { rows } = openEverything(model, list);
const keys = ['id', 'kind', 'label', 'detail', 'depth', 'hasChildren', 'expanded',
'warning', 'bookmarked'];
for (const row of rows) {
for (const key of keys) assert(key in row, `${key} is missing from ${row.label}`);
assert.equal(typeof row.depth, 'number');
}
// Depth 0 is the header; everything under it is one level deeper than the
// plain tree would put it.
assert.equal(rows.filter((row) => row.depth === 0).length, 3);
}
/** A bookmark is a path, and it is painted wherever that path is on screen —
* behind the section prefix as readily as at the top level. */
function aBookmarkIsPaintedWhereverItsPathIsShown() {
const model = buildHierarchy(fixture());
const openAll = (list) => {
const expanded = new Set();
for (let pass = 0; pass < 12; pass += 1) {
for (const row of sectionRows(model, list, expanded, '').rows) {
if (row.hasChildren) expanded.add(row.id);
}
}
return expanded;
};
// Bookmarked from inside the DUT section, the path is DUT-relative
// (`dut.u_l2`) — which resolves only because `bookmarkChain` retries over
// every module — and it is found behind the section's prefix.
const starred = sections(model, ['dut']);
const inDut = sectionRows(model, starred, openAll(starred), 'dut.u_l2').rows
.filter((row) => row.bookmarked);
assert.equal(inDut.length, 1);
assert.equal(inDut[0].label, 'u_l2 (leaf2)');
assert(inDut[0].id.startsWith('dut:dut/'));
assert.deepEqual(sectionPrefixes(['dut']), ['dut:dut/', 'parents:dut/']);
// Bookmarked from the others section, the path is the ordinary one and the
// ordinary id matches.
const elsewhere = sections(model, ['other_top']);
const inOthers = sectionRows(model, elsewhere, openAll(elsewhere), 'tb.u_dut.u_l2').rows
.filter((row) => row.bookmarked);
assert.equal(inOthers.length, 1);
assert.equal(inOthers[0].label, 'u_l2 (leaf2)');
// The documented consequence: a path whose root the exclusion removed is not
// on screen, so nothing is painted. The bookmark is not dropped — the model
// still resolves it — and unstarring brings it back.
const hidden = sectionRows(model, starred, openAll(starred), 'tb.u_dut.u_l2').rows
.filter((row) => row.bookmarked);
assert.equal(hidden.length, 0, 'tb is above the DUT, so that path has no rows');
assert(idForPathStillResolves(model, 'tb.u_dut.u_l2'), 'and the bookmark survives');
}
function idForPathStillResolves(model, path) {
return Boolean(require('./hierarchyModel').idForPath(model, path));
}
function contextValuesAndMenusSayWhatEachRowOffers() {
const model = buildHierarchy(fixture());
const list = sections(model, ['dut']);
const { rows } = openEverything(model, list);
const decorated = decorate(rows, ['dut'], []);
const byLabel = (label) => decorated.find((row) => row.label === label);
assert.equal(byLabel('DUT: dut').contextValue, 'section');
assert.equal(byLabel('dut').contextValue, 'module.dut', 'the starred module offers Unstar');
assert.equal(byLabel('tb').contextValue, 'module', 'any other module offers Star');
assert.equal(byLabel('u_l1 (leaf1)').contextValue, 'instance');
// An instance row is starred by its type, not by its instance name — checked
// on the plain rows, where `u_dut` is on screen (with `dut` starred its own
// root is above the DUT and excluded).
const plain = decorate(treeRows(model, new Set(openEverything(model, sections(model, []))
.rows.map((row) => row.id)), '').rows, ['dut'], []);
assert.equal(plain.find((row) => row.label === 'u_dut (dut)').contextValue, 'instance.dut');
assert.equal(plain.find((row) => row.label === 'tb').contextValue, 'module');
const table = menuTable();
assert.deepEqual(table.section, []);
assert.deepEqual(table.module.map((item) => item.action), ['starDut']);
assert.deepEqual(table['module.dut'].map((item) => item.action), ['unstarDut']);
assert.deepEqual(table.instance.map((item) => item.action),
['copyPath', 'definition', 'instance', 'bookmark', 'openRight', 'starDut']);
assert.deepEqual(table['instance.dut'].map((item) => item.action),
['copyPath', 'definition', 'instance', 'bookmark', 'openRight', 'unstarDut']);
// Every contextValue `decorate` can produce must have a menu, or a row would
// silently offer nothing.
for (const kind of ['section', 'notice', 'module', 'instance']) {
for (const suffix of ['', '.dut', '.dut.locked']) {
if ((kind === 'section' || kind === 'notice') && suffix !== '') continue;
assert(Array.isArray(table[`${kind}${suffix}`]), `no menu for ${kind}${suffix}`);
}
}
}
function aDutFromTheSettingsIsLockedAndSaysWhy() {
const model = buildHierarchy(fixture());
const list = sections(model, ['dut']);
const decorated = decorate(openEverything(model, list).rows, ['dut'], ['dut']);
const row = decorated.find((candidate) => candidate.label === 'dut');
assert.equal(row.contextValue, 'module.dut.locked');
assert.match(row.title, /lucisv\.hierarchy\.duts/, 'the tooltip names the setting');
const [item] = menuTable()['module.dut.locked'];
assert.equal(item.disabled, true);
assert.equal(item.action, 'lockedDut');
assert.equal(item.title, LOCKED.title);
}
/** The pane with no DUT starred is the pane as it was: `sections()` is not on
* the path at all, and the rows the view sends are `treeRows`' own. */
function thePlainViewIsUntouched() {
const model = buildHierarchy(fixture());
const open = new Set(treeRows(model, new Set(), '').rows.map((row) => row.id));
const plain = treeRows(model, open, '');
const decorated = decorate(plain.rows, [], []);
const visible = ['id', 'kind', 'label', 'detail', 'depth', 'hasChildren', 'expanded',
'warning', 'bookmarked'];
for (let at = 0; at < plain.rows.length; at += 1) {
for (const key of visible) {
assert.deepEqual(decorated[at][key], plain.rows[at][key], `${key} changed on ${plain.rows[at].label}`);
}
assert.equal(decorated[at].contextValue, plain.rows[at].kind, 'nothing is a DUT');
assert.equal(decorated[at].title, undefined);
}
assert.deepEqual(plain.rows.map((row) => row.label),
['lonely', 'other_top', 'tb', 'u_dut (dut)']);
}
/** The commands the menus and the pane's own rows fire have to exist, and the
* view's title entries have to be gated on this view. */
function packageJsonContributesTheCommandsMenusAndSetting() {
const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
const commands = manifest.contributes.commands.map((command) => command.command);
for (const name of ['lucisv.hierarchy.starDut', 'lucisv.hierarchy.unstarDut',
'lucisv.hierarchy.clearDuts']) {
assert(commands.includes(name), `${name} is not contributed`);
}
const title = manifest.contributes.menus['view/title'];
for (const name of ['lucisv.hierarchy.starDut', 'lucisv.hierarchy.unstarDut',
'lucisv.hierarchy.clearDuts', 'lucisv.hierarchy.refresh',
'lucisv.hierarchy.clearBookmark']) {
const entry = title.find((item) => item.command === name);
assert(entry, `${name} has no view/title entry`);
assert.equal(entry.when, 'view == lucisv.hierarchy', `${name}'s when clause`);
}
const setting = manifest.contributes.configuration.properties['lucisv.hierarchy.duts'];
assert.equal(setting.type, 'array');
assert.equal(setting.items.type, 'string');
assert.deepEqual(setting.default, []);
// Every action the menu table can post must be one the view answers; the
// view's own test covers the answering, this pins the vocabulary.
const actions = new Set(Object.values(menuTable()).flat().map((item) => item.action));
assert.deepEqual([...actions].sort(), ['bookmark', 'copyPath', 'definition', 'instance',
'lockedDut', 'openRight', 'starDut', 'unstarDut']);
}
/** The upward walk must not cost a pass over the design per opened row: the
* reverse index is built once and reused. */
function theReverseIndexIsBuiltOncePerSnapshot() {
const model = buildHierarchy(fixture());
const list = sections(model, ['dut']);
assert(model.parentsByTarget instanceof Map, 'memoized on the model');
const first = model.parentsByTarget;
openEverything(model, list);
sections(model, ['leaf1']);
assert.equal(model.parentsByTarget, first, 'and never rebuilt for the same snapshot');
}
for (const test of [
noDutIsOneSectionAndThePlainRoots,
oneDutIsThreeSectionsAndTwoAreFive,
theDutSectionIsTheForwardSubtreeAndTheParentsSectionIsTheUpwardTree,
othersHoldsEveryModuleOutsideEveryDut,
aModuleUnderAnExcludedBenchIsReRootedInOthers,
aModuleUnderTwoExcludedBenchesIsReRootedOnce,
aModuleWithOneOrdinaryParentIsNotReRooted,
twoDutsSharingABenchLeaveOthersCorrect,
aCycleReachableOnlyThroughAnExcludedBenchStillHasARoot,
aModuleBothBelowOneDutAndAboveAnotherIsInBothSections,
theParentsWalkCutsACycle,
aStarredNameTheSnapshotLacksKeepsItsSections,
twoDeclarationsOfOneNameAreMarkedAmbiguous,
sectionsAreCollapsedUntilOpenedAndOnlyTheDutOnesOpenByDefault,
sectionRowsMatchTheShapeTheViewAlreadyRenders,
aBookmarkIsPaintedWhereverItsPathIsShown,
contextValuesAndMenusSayWhatEachRowOffers,
aDutFromTheSettingsIsLockedAndSaysWhy,
thePlainViewIsUntouched,
packageJsonContributesTheCommandsMenusAndSetting,
theReverseIndexIsBuiltOncePerSnapshot,
]) test();
console.log('hierarchy sections: OK — three sections per DUT, five for two, the upward tree, cycles cut, missing names, others holding and re-rooting everything outside every DUT, menus, the setting lock, and the plain view untouched');
+166 -15
View File
@@ -8,11 +8,24 @@ const {
searchTarget,
treeRows,
} = require('./hierarchyModel');
const {
OTHERS_ID,
decorate,
defaultOpenIds,
menuTable,
sectionPrefixes,
sectionRows,
sections,
} = require('./hierarchySections');
const VIEW_ID = 'lucisv.hierarchy';
const SNAPSHOT_METHOD = 'lucisv/moduleHierarchy';
const CHANGED_METHOD = 'lucisv/moduleHierarchyChanged';
const BOOKMARK_KEY = 'lucisv.hierarchy.bookmark';
/** The starred DUTs of this workspace, in the order they were starred. */
const DUTS_KEY = 'lucisv.hierarchy.duts';
/** The same list as a setting, so a team can check theirs in. */
const DUTS_SETTING = 'hierarchy.duts';
const REFRESH_DEBOUNCE_MS = 100;
class HierarchyView {
@@ -24,13 +37,18 @@ class HierarchyView {
this.query = '';
// Which rows the user has opened. Row ids are composed from URIs and
// declaration positions, so they survive a refresh and what was open stays
// open — nothing is expanded on the user's behalf (owner, 2026-08-29).
// open — nothing is expanded on the user's behalf (owner, 2026-08-29)
// except what the user asked for by bookmarking or by starring a DUT.
this.expanded = new Set();
this.nodes = new Map();
this.request = 0;
this.refreshTimer = undefined;
this.bookmarkPath = context.workspaceState.get(BOOKMARK_KEY, '');
this.lostBookmarkReported = false;
// The DUTs this workspace starred, in starred order. The settings may name
// more; `duts()` is the union the pane actually shows.
this.starred = moduleNames(context.workspaceState.get(DUTS_KEY, []));
this.seededFor = undefined;
context.subscriptions.push(
vscode.window.registerWebviewViewProvider(VIEW_ID, this, {
@@ -38,11 +56,32 @@ class HierarchyView {
}),
vscode.commands.registerCommand('lucisv.hierarchy.refresh', () => this.refresh()),
vscode.commands.registerCommand('lucisv.hierarchy.clearBookmark', () => this.setBookmark('')),
vscode.commands.registerCommand('lucisv.hierarchy.starDut', (name) => this.starDut(name)),
vscode.commands.registerCommand('lucisv.hierarchy.unstarDut', (name) => this.unstarDut(name)),
vscode.commands.registerCommand('lucisv.hierarchy.clearDuts', () => this.clearDuts()),
vscode.workspace.onDidChangeConfiguration((event) => {
if (!event.affectsConfiguration('lucisv.hierarchy.duts')) return;
this.seededFor = undefined;
this.render();
}),
client.onNotification(CHANGED_METHOD, () => this.scheduleRefresh()),
{ dispose: () => clearTimeout(this.refreshTimer) },
);
}
/// The DUTs the settings name: a checked-in list the pane shows but will not
/// edit, so its entries are locked against unstarring.
lockedDuts() {
return moduleNames(vscode.workspace.getConfiguration('lucisv').get(DUTS_SETTING, []));
}
/// The effective list: the settings' DUTs first, then this workspace's own
/// stars in the order they were made.
duts() {
const locked = this.lockedDuts();
return [...locked, ...this.starred.filter((name) => !locked.includes(name))];
}
resolveWebviewView(view) {
this.view = view;
const media = vscode.Uri.joinPath(this.context.extensionUri, 'media');
@@ -108,21 +147,50 @@ class HierarchyView {
/// on every keystroke is what froze the UI.
render() {
if (!this.model) return;
const duts = this.duts();
const locked = this.lockedDuts();
const common = {
type: 'render',
revision: this.model.revision,
complete: this.model.complete,
query: this.query,
empty: this.model.roots.length === 0,
// One table per render rather than a rule per row: the renderer shows
// exactly the items a row's `contextValue` names and decides nothing.
menus: menuTable(),
};
if (this.query.trim() !== '') {
const found = searchHierarchy(this.model, this.query);
this.post({ ...common, mode: 'search', rows: found.rows, truncated: found.truncated, total: found.total });
const rows = decorate(found.rows, duts, locked);
this.post({ ...common, mode: 'search', rows, truncated: found.truncated, total: found.total });
return;
}
const tree = treeRows(this.model, this.expanded, this.bookmarkPath);
const tree = this.treeOrSections(duts);
this.nodes = tree.nodes;
this.post({ ...common, mode: 'tree', rows: tree.rows, truncated: 0, total: tree.rows.length });
const rows = decorate(tree.rows, duts, locked);
this.post({ ...common, mode: 'tree', rows, truncated: 0, total: rows.length });
}
/// With no DUT starred the pane is the plain tree, unchanged and untouched.
treeOrSections(duts) {
const key = duts.join('\n');
if (duts.length === 0) {
// Recorded even here, so re-starring after a clear seeds again.
this.seededFor = key;
return treeRows(this.model, this.expanded, this.bookmarkPath);
}
const list = sections(this.model, duts);
this.seedExpansion(list, key);
return sectionRows(this.model, list, this.expanded, this.bookmarkPath);
}
/// Open the new sections once, when the DUT list changes — not on every
/// render, so a section the user closes stays closed.
seedExpansion(list, key) {
if (this.seededFor === key) return;
this.seededFor = key;
for (const id of defaultOpenIds(list)) this.expanded.add(id);
this.expanded.delete(OTHERS_ID);
}
async message(message) {
@@ -153,15 +221,32 @@ class HierarchyView {
return;
}
if (message.type !== 'context' || typeof message.action !== 'string') return;
await this.contextAction(node, message.action);
}
/// One row's menu item, chosen by the host's own menu table — so an action a
/// row does not offer is one this never sees, and every one is re-checked
/// here anyway.
async contextAction(node, action) {
// Starring is about the row's module — for an instance row, its type — so
// it is the one action a module row offers as well.
if (action === 'starDut') {
await this.starDut(node.moduleName);
return;
}
if (action === 'unstarDut') {
await this.unstarDut(node.moduleName);
return;
}
const actions = new Set(['copyPath', 'definition', 'instance', 'bookmark', 'openRight']);
if (!actions.has(message.action) || node.kind !== 'instance') return;
if (!actions.has(action) || node.kind !== 'instance') return;
// A search hit is one row for an instance however many paths reach it, so
// it has no one full path to copy or bookmark.
if (!node.fullPath && (message.action === 'copyPath' || message.action === 'bookmark')) {
if (!node.fullPath && (action === 'copyPath' || action === 'bookmark')) {
vscode.window.showWarningMessage('Clear the search to copy or bookmark an instance path.');
return;
}
switch (message.action) {
switch (action) {
case 'copyPath':
await vscode.env.clipboard.writeText(node.fullPath);
break;
@@ -187,11 +272,73 @@ class HierarchyView {
await this.context.workspaceState.update(BOOKMARK_KEY, path || undefined);
// The one expansion the view performs for the user, and only because the
// user asked for it by bookmarking: the direct ancestors of the marked row.
// A section holds its own copy of that chain, behind the section's prefix.
const chain = path && bookmarkChain(this.model, path);
if (chain) for (const id of chain.slice(0, -1)) this.expanded.add(id);
const prefixes = ['', ...sectionPrefixes(this.duts())];
if (chain) {
for (const id of chain.slice(0, -1)) {
for (const prefix of prefixes) this.expanded.add(`${prefix}${id}`);
}
}
this.render();
}
/// Star a module as DUT. Called with a name from the pane's menu, and without
/// one from the command palette, where the module is picked from the index.
async starDut(name) {
const chosen = name || await this.pickModule('Star a module as DUT', this.moduleNamesInIndex());
if (!chosen) return;
if (this.duts().includes(chosen)) {
vscode.window.showInformationMessage(`${chosen} is already a DUT.`);
return;
}
this.starred = [...this.starred, chosen];
await this.context.workspaceState.update(DUTS_KEY, this.starred);
this.render();
}
async unstarDut(name) {
const chosen = name || await this.pickModule('Unstar a DUT', this.starred);
if (!chosen) return;
if (this.lockedDuts().includes(chosen)) {
vscode.window.showWarningMessage(
`${chosen} comes from the lucisv.hierarchy.duts setting. Remove it there to unstar it.`,
);
return;
}
if (!this.starred.includes(chosen)) return;
this.starred = this.starred.filter((starred) => starred !== chosen);
await this.context.workspaceState.update(DUTS_KEY, this.starred.length > 0 ? this.starred : undefined);
this.render();
}
/// Clear what this workspace starred. What the settings name stays, because
/// only the settings file can take it away.
async clearDuts() {
this.starred = [];
await this.context.workspaceState.update(DUTS_KEY, undefined);
const locked = this.lockedDuts();
if (locked.length > 0) {
vscode.window.showInformationMessage(
`Cleared the starred DUTs; ${locked.join(', ')} come from the lucisv.hierarchy.duts setting.`,
);
}
this.render();
}
moduleNamesInIndex() {
if (!this.model) return [];
return [...new Set(this.model.modules.map((module) => module.moduleName))].sort();
}
async pickModule(placeHolder, choices) {
if (choices.length === 0) {
vscode.window.showWarningMessage('There is no module to choose: the hierarchy index is empty.');
return undefined;
}
return vscode.window.showQuickPick(choices, { placeHolder });
}
async showDefinition(node, beside) {
let location;
if (node.definitions.length === 0) {
@@ -231,6 +378,13 @@ class HierarchyView {
}
}
/// A stored or configured DUT list, made safe: non-strings, blanks and repeats
/// are dropped, and the order the user chose is kept.
function moduleNames(value) {
if (!Array.isArray(value)) return [];
return [...new Set(value.filter((name) => typeof name === 'string' && name.trim() !== ''))];
}
function asRange(range) {
return new vscode.Range(
range.start.line,
@@ -261,13 +415,10 @@ function html(webview, media) {
<div id="tree" role="tree" aria-label="Module instance hierarchy"></div>
<div id="results" role="listbox" aria-label="Hierarchy search results" hidden></div>
<div id="more" hidden></div>
<div id="menu" role="menu" aria-label="Instance actions" hidden>
<button role="menuitem" data-action="copyPath">Copy Full Path</button>
<button role="menuitem" data-action="definition">Show Definition</button>
<button role="menuitem" data-action="instance">Show Instance</button>
<button role="menuitem" data-action="bookmark">Highlight / Bookmark</button>
<button role="menuitem" data-action="openRight">Open on the Right</button>
</div>
<!-- Filled per row from the menu table the host sends: which items a row
offers depends on whether its module is a DUT, and on where that DUT
came from. -->
<div id="menu" role="menu" aria-label="Row actions" hidden></div>
<script nonce="${nonce}" src="${script}"></script>
</body>
</html>`;
+146 -3
View File
@@ -7,10 +7,16 @@ const copied = [];
const opened = [];
const shown = [];
const warned = [];
const informed = [];
const commands = new Map();
/** What `lucisv.hierarchy.duts` is set to, as a checked-in setting would be. */
let configuredDuts = [];
let picked;
let requests = 0;
let provider;
let receive;
let changed;
let configurationChanged;
class Range {
constructor(startLine, startCharacter, endLine, endCharacter) {
@@ -30,9 +36,16 @@ const vscode = {
Range,
ViewColumn: { Active: 1, Beside: 2 },
env: { clipboard: { async writeText(value) { copied.push(value); } } },
commands: { registerCommand() { return disposables(); } },
commands: {
registerCommand(id, handler) { commands.set(id, handler); return disposables(); },
},
workspace: {
asRelativePath(uri) { return uri.fsPath; },
getConfiguration(section) {
assert.equal(section, 'lucisv');
return { get(key, fallback) { return key === 'hierarchy.duts' ? configuredDuts : fallback; } };
},
onDidChangeConfiguration(handler) { configurationChanged = handler; return disposables(); },
async openTextDocument(uri) {
opened.push(uri.value);
return {
@@ -45,8 +58,9 @@ const vscode = {
window: {
registerWebviewViewProvider(_id, value) { provider = value; return disposables(); },
async showTextDocument(document, options) { shown.push({ document, options }); },
async showQuickPick(items) { return items[0]; },
async showQuickPick(items) { picked = items; return items[0]; },
showWarningMessage(text) { warned.push(text); },
showInformationMessage(text) { informed.push(text); },
},
};
@@ -181,7 +195,136 @@ async function run() {
assert(!webview.html.includes('id="preview"'), 'and the popover is gone from the markup');
assert.equal(typeof changed, 'function');
console.log('hierarchy view: OK — collapsed rows, lazy opening, search list, navigation, menu, bookmark, and no preview');
// ---- DUT sections (TODO §56) -------------------------------------------
// What the pane looks like with nothing starred, kept to compare against
// after an unstar: starring must be perfectly reversible.
const plainRows = rendered().rows.map((row) => ({ ...row }));
assert(plainRows.every((row) => row.contextValue === row.kind), 'nothing is a DUT yet');
assert.deepEqual(Object.keys(rendered().menus).sort(), [
'instance', 'instance.dut', 'instance.dut.locked', 'module', 'module.dut',
'module.dut.locked', 'notice', 'section',
], 'the menu table travels with every render');
// Starring from the pane's own menu, on an instance row: the module starred
// is the row's type.
await receive({ type: 'context', action: 'starDut', id: instance.id });
assert.deepEqual(state.get('lucisv.hierarchy.duts'), ['sub'], 'persisted in starred order');
assert.deepEqual(rendered().rows.map((row) => [row.label, row.depth]), [
['DUT: sub', 0],
['sub', 1],
['Parents of sub', 0],
['sub', 1],
['top', 2],
['Other modules', 0],
], 'three sections, the DUT ones opened one level, others closed');
assert.equal(rendered().rows.find((row) => row.label === 'top').detail, 'via u');
assert.equal(rendered().rows[1].contextValue, 'module.dut', 'the DUT row offers Unstar');
assert.equal(rendered().rows.at(-1).contextValue, 'section');
// A section is an ordinary collapsible row: closing it builds none of its
// tree, opening `others` shows what the exclusion left.
await receive({ type: 'toggle', id: 'sec:dut:sub' });
assert(!rendered().rows.some((row) => row.label === 'sub' && row.depth === 1
&& row.id.startsWith('dut:')), 'a closed section shows nothing under it');
await receive({ type: 'toggle', id: 'sec:dut:sub' });
await receive({ type: 'toggle', id: 'sec:others' });
assert.deepEqual(
rendered().rows.filter((row) => row.depth === 1 && !row.id.startsWith('dut:')
&& !row.id.startsWith('parents:')).map((row) => row.label),
[], 'top is above the DUT, so the others section is empty',
);
// A second DUT is two more sections, in starred order.
await receive({ type: 'context', action: 'starDut', id: rendered().rows[1].id });
assert.deepEqual(state.get('lucisv.hierarchy.duts'), ['sub']);
assert.equal(informed.at(-1), 'sub is already a DUT.');
await commands.get('lucisv.hierarchy.starDut')('top');
assert.deepEqual(state.get('lucisv.hierarchy.duts'), ['sub', 'top']);
assert.deepEqual(
rendered().rows.filter((row) => row.kind === 'section').map((row) => row.label),
['DUT: sub', 'Parents of sub', 'DUT: top', 'Parents of top', 'Other modules'],
'two DUTs are five sections',
);
// Unstarring from the menu, and clearing the rest from the title bar, put
// the plain pane back exactly as it was.
await receive({ type: 'context', action: 'unstarDut', id: rendered().rows[1].id });
assert.deepEqual(state.get('lucisv.hierarchy.duts'), ['top']);
await commands.get('lucisv.hierarchy.clearDuts')();
assert.equal(state.get('lucisv.hierarchy.duts'), undefined);
assert.deepEqual(rendered().rows, plainRows, 'the pane is byte-identical to before the star');
// The command palette route picks from the index. Starring the same module
// again after a clear must open its sections again, not remember that it
// once seeded them.
await commands.get('lucisv.hierarchy.starDut')();
assert.deepEqual(picked, ['sub', 'top'], 'every module name, sorted');
assert.deepEqual(state.get('lucisv.hierarchy.duts'), ['sub']);
assert.deepEqual(rendered().rows.map((row) => row.label), [
'DUT: sub', 'sub', 'Parents of sub', 'sub', 'top', 'Other modules',
], 'the sections are open again');
await commands.get('lucisv.hierarchy.unstarDut')();
assert.deepEqual(picked, ['sub'], 'only what this workspace starred');
assert.equal(state.get('lucisv.hierarchy.duts'), undefined);
// The setting is the second way in: its DUTs come first, are locked, and the
// pane refuses to unstar them.
configuredDuts = ['top', ''];
await commands.get('lucisv.hierarchy.starDut')('sub');
configurationChanged({ affectsConfiguration: (key) => key === 'lucisv.hierarchy.duts' });
assert.deepEqual(
rendered().rows.filter((row) => row.kind === 'section').map((row) => row.label),
['DUT: top', 'Parents of top', 'DUT: sub', 'Parents of sub', 'Other modules'],
'the setting first, then the star; the blank entry is dropped',
);
const locked = rendered().rows.find((row) => row.label === 'top' && row.depth === 1);
assert.equal(locked.contextValue, 'module.dut.locked');
assert.match(locked.title, /lucisv\.hierarchy\.duts/);
await receive({ type: 'context', action: 'unstarDut', id: locked.id });
assert.match(warned.at(-1), /^top comes from the lucisv\.hierarchy\.duts setting/);
assert.deepEqual(state.get('lucisv.hierarchy.duts'), ['sub'], 'and nothing changed');
await commands.get('lucisv.hierarchy.clearDuts')();
assert.match(informed.at(-1), /come from the lucisv\.hierarchy\.duts setting/);
assert.deepEqual(
rendered().rows.filter((row) => row.kind === 'section').map((row) => row.label),
['DUT: top', 'Parents of top', 'Other modules'],
'clearing takes the stars, not the setting',
);
// A starred name the snapshot does not hold keeps its sections and says so.
configuredDuts = [];
await commands.get('lucisv.hierarchy.starDut')('renamed_away');
assert.deepEqual(rendered().rows.map((row) => row.label), [
'DUT: renamed_away',
'renamed_away is not in the index',
'Parents of renamed_away',
'renamed_away is not in the index',
'Other modules',
]);
await commands.get('lucisv.hierarchy.clearDuts')();
await persistenceSurvivesAReload();
console.log('hierarchy view: OK — collapsed rows, lazy opening, search list, navigation, menu, bookmark, no preview, and DUT sections (star, unstar, clear, persistence, the setting lock)');
}
/// A fresh view over the same `workspaceState`: what was starred is starred
/// again, in the order it was starred, and the sections are open on arrival.
async function persistenceSurvivesAReload() {
state.set('lucisv.hierarchy.duts', ['sub', 'nope', 7, '']);
new HierarchyView(context, client);
const reposted = [];
provider.resolveWebviewView({
webview: { ...webview, postMessage(message) { reposted.push(message); } },
onDidDispose() { return disposables(); },
});
await receive({ type: 'ready' });
const render = reposted.findLast((message) => message.type === 'render');
assert.deepEqual(render.rows.map((row) => row.label), [
'DUT: sub', 'sub', 'Parents of sub', 'sub', 'top',
'DUT: nope', 'nope is not in the index', 'Parents of nope', 'nope is not in the index',
'Other modules',
], 'both starred names come back, the number 7 and the blank do not');
}
run().catch((error) => {
+11
View File
@@ -52,6 +52,17 @@ body {
border-color: var(--vscode-charts-yellow, #cca700);
}
.row.warning .detail { color: var(--vscode-list-warningForeground, var(--vscode-editorWarning-foreground)); }
/* A DUT section header: the pane's one structural row, so it reads as a
heading rather than as another module. */
.row.section {
position: sticky;
top: 38px;
z-index: 2;
background: var(--vscode-sideBarSectionHeader-background, var(--vscode-sideBar-background));
font-weight: 700;
}
#menu button[disabled] { color: var(--vscode-disabledForeground, var(--vscode-descriptionForeground)); }
#menu button[disabled]:hover { background: transparent; color: var(--vscode-disabledForeground, var(--vscode-descriptionForeground)); }
.twisty { width: 12px; flex: 0 0 12px; text-align: center; }
.icon { width: 14px; flex: 0 0 14px; color: var(--vscode-symbolIcon-moduleForeground, var(--vscode-foreground)); }
.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+34 -9
View File
@@ -15,7 +15,7 @@ const menu = document.getElementById('menu');
/** Long enough that a fast typist sends one query, short enough to feel live. */
const SEARCH_DEBOUNCE_MS = 60;
let payload = { mode: 'tree', rows: [], truncated: 0, query: '' };
let payload = { mode: 'tree', rows: [], truncated: 0, query: '', menus: {} };
let menuNode;
let searchTimer;
@@ -87,6 +87,8 @@ function renderRow(row, searching) {
const button = document.createElement('button');
button.className = 'row';
button.type = 'button';
if (row.kind === 'section') button.classList.add('section');
if (row.title) button.title = row.title;
button.setAttribute('role', searching ? 'option' : 'treeitem');
button.setAttribute('aria-level', String(row.depth + 1));
button.style.setProperty('--depth', row.depth);
@@ -101,7 +103,10 @@ function renderRow(row, searching) {
twisty.setAttribute('aria-hidden', 'true');
const icon = document.createElement('span');
icon.className = 'icon';
icon.textContent = row.kind === 'module' ? '▣' : (row.detail === 'recursive' ? '↻' : '◇');
// A section header and a "not in the index" notice bring their own glyph;
// everything else is a module box or an instance diamond.
icon.textContent = row.icon
|| (row.kind === 'module' ? '▣' : (row.detail === 'recursive' ? '↻' : '◇'));
icon.setAttribute('aria-hidden', 'true');
const label = document.createElement('span');
label.className = 'label';
@@ -112,7 +117,10 @@ function renderRow(row, searching) {
button.append(twisty, icon, label, detail);
button.addEventListener('click', (event) => {
if (row.hasChildren && event.detail === 1 && event.offsetX < 28 + row.depth * 12) {
// A section header has nothing to navigate to, so the whole row opens it.
if (row.kind === 'section') {
vscode.postMessage({ type: 'toggle', id: row.id });
} else if (row.hasChildren && event.detail === 1 && event.offsetX < 28 + row.depth * 12) {
vscode.postMessage({ type: 'toggle', id: row.id });
} else {
vscode.postMessage({ type: 'activate', id: row.id });
@@ -160,16 +168,32 @@ function firstVisibleRow() { return rows()[0]; }
function nextRow(row) { const all = rows(); return all[all.indexOf(row) + 1]; }
function previousRow(row) { const all = rows(); return all[all.indexOf(row) - 1]; }
// Which items a row offers is the host's decision, sent once per render as a
// table keyed by `contextValue`: an instance row has the five it always had, a
// module row has "Star as DUT", a starred one "Unstar DUT", and one the
// settings name a single disabled item that says where it came from.
function openMenu(event, row) {
event.preventDefault();
if (row.kind !== 'instance') return;
const items = (payload.menus && payload.menus[row.contextValue]) || [];
if (items.length === 0) return;
menuNode = row;
menu.replaceChildren(...items.map((item) => menuItem(item, row)));
menu.hidden = false;
menu.style.left = `${Math.min(event.clientX, innerWidth - 190)}px`;
menu.style.top = `${Math.min(event.clientY, innerHeight - 180)}px`;
menu.querySelector('[data-action="bookmark"]').textContent = row.bookmarked
? 'Remove Highlight / Bookmark' : 'Highlight / Bookmark';
menu.querySelector('button').focus();
menu.style.top = `${Math.min(event.clientY, innerHeight - 180 - items.length * 4)}px`;
const first = menu.querySelector('button:not([disabled])');
if (first) first.focus();
}
function menuItem(item, row) {
const button = document.createElement('button');
button.setAttribute('role', 'menuitem');
button.dataset.action = item.action;
button.textContent = item.action === 'bookmark' && row.bookmarked
? 'Remove Highlight / Bookmark' : item.label;
if (item.disabled) button.disabled = true;
if (item.title) button.title = item.title;
return button;
}
menu.addEventListener('click', (event) => {
@@ -178,9 +202,10 @@ menu.addEventListener('click', (event) => {
closeMenu();
});
menu.addEventListener('keydown', (event) => {
const items = [...menu.querySelectorAll('button')];
const items = [...menu.querySelectorAll('button:not([disabled])')];
const at = items.indexOf(document.activeElement);
if (event.key === 'Escape') closeMenu();
if (items.length === 0) return;
if (event.key === 'ArrowDown') items[(at + 1) % items.length].focus();
if (event.key === 'ArrowUp') items[(at - 1 + items.length) % items.length].focus();
});
+43 -1
View File
@@ -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.47.0",
"version": "0.48.2",
"publisher": "guoliangchen",
"author": "Guoliang Chen",
"license": "MIT",
@@ -82,6 +82,24 @@
"command": "lucisv.hierarchy.clearBookmark",
"title": "Clear Hierarchy Bookmark",
"icon": "$(clear-all)"
},
{
"command": "lucisv.hierarchy.starDut",
"title": "Star Module as DUT",
"category": "lucisv",
"icon": "$(star-full)"
},
{
"command": "lucisv.hierarchy.unstarDut",
"title": "Unstar DUT",
"category": "lucisv",
"icon": "$(star-empty)"
},
{
"command": "lucisv.hierarchy.clearDuts",
"title": "Clear DUTs",
"category": "lucisv",
"icon": "$(star-empty)"
}
],
"menus": {
@@ -95,6 +113,21 @@
"command": "lucisv.hierarchy.clearBookmark",
"when": "view == lucisv.hierarchy",
"group": "navigation@2"
},
{
"command": "lucisv.hierarchy.clearDuts",
"when": "view == lucisv.hierarchy",
"group": "navigation@3"
},
{
"command": "lucisv.hierarchy.starDut",
"when": "view == lucisv.hierarchy",
"group": "1_duts@1"
},
{
"command": "lucisv.hierarchy.unstarDut",
"when": "view == lucisv.hierarchy",
"group": "1_duts@2"
}
]
},
@@ -242,6 +275,15 @@
"default": true,
"markdownDescription": "Colour each nesting level of `begin`/`end` and `fork`/`join` a different colour, and a keyword whose counterpart is missing in an error colour. Every colour is a `lucisv.rainbow*` theme colour you can override in `workbench.colorCustomizations`. Takes effect immediately."
},
"lucisv.hierarchy.duts": {
"type": "array",
"items": {
"type": "string"
},
"default": [],
"scope": "window",
"markdownDescription": "Modules the Hierarchy pane treats as DUTs, by name. Each one splits the pane into two more sections — the DUT with its children, and an upward tree of everything that instantiates it — ahead of the \"Other modules\" section. This is the checked-in list a team shares (`.vscode/settings.json`); starring from the pane's own menu is the per-workspace way and the two are shown together. A DUT that comes from this setting is shown locked and cannot be unstarred from the pane."
},
"lucisv.inlineTemplates": {
"type": "boolean",
"default": true,