Skip to content

Add design instantiation hierarchy view#111

Open
nohous wants to merge 1 commit into
VHDL-LS:masterfrom
nohous:design-hierarchy
Open

Add design instantiation hierarchy view#111
nohous wants to merge 1 commit into
VHDL-LS:masterfrom
nohous:design-hierarchy

Conversation

@nohous

@nohous nohous commented May 1, 2026

Copy link
Copy Markdown

Summary

Adds a VHDL Hierarchy activity-bar view that renders the project's design instantiation tree. Picking a top entity opens a quick-pick pre-populated from the language server with real top candidates first (deepest subtree first), so the intended top of the design typically sits at the top of the list. The chosen top is persisted to vhdlls.topEntity and reloaded on the next session.

Depends on the companion language-server PR: VHDL-LS/rust_hdl#461. Until a vhdl_ls release ships with that PR, the auto-downloaded server will return method-not-found and the view will display a notice instead of failing silently.

Why

Hierarchy overview is one of the most-requested features for any HDL editor. Standard LSP doesn't have a notion of design hierarchy, so the server PR adds two custom requests; this PR consumes them.

What's added

Contributions (package.json)

  • Commands: vhdlls.showHierarchy, vhdlls.setHierarchyTop, vhdlls.refreshHierarchy
  • View container vhdlHierarchyContainer in the activity bar
  • vhdlHierarchy view inside it, with refresh and edit-top buttons in the title bar
  • Setting vhdlls.topEntity (string, e.g. work.top)

UX

  • Top-entity picker. Calls vhdl/designHierarchyCandidates, splits results into "Top candidates (no incoming instantiations)" and "Other entities", sorts deepest-first within each section, and shows each entry with depth + instance count + file path. Free-text input is supported as a fallback (last item: "Type a custom entity name...").
  • Tree. Each node shows instance_label : library.entity(architecture) with an icon per kind (top, bound component, unbound component, configuration, unresolved). Clicking opens the file at the instantiation site; for the top node, at the entity declaration. Notes (multi-architecture warning, cycle, unbound) appear in the tooltip.
  • Persistence. Picking a top writes vhdlls.topEntity to Workspace settings (or User if no workspace is open). On next session the view auto-loads.
  • Graceful degradation. If the active vhdl_ls doesn't implement the requests (LSP MethodNotFound, -32601), the view shows a notice telling the user to update or point vhdlls.languageServerUserPath at a newer build, rather than just failing.

Implementation notes

  • Tree data provider uses a discriminated TreeElement union to keep status-message rows separate from real instantiation nodes (no overloaded constructor).
  • Response types use a local LspLocation interface that matches the on-the-wire JSON shape (server sends uri as a string, not a deserialised Uri).
  • The LanguageClient is injected through the provider; no module-level globals.

Version bumped to 0.8.0; CHANGELOG and README updated with a new "Design Hierarchy" section.

Test plan

  • npm run compile clean
  • Extension Development Host on a ~20-entity, 4-level-deep VHDL project: picker correctly ranks the real top first; tree renders with expected children at every level; clicking nodes navigates correctly
  • Older server case: with the auto-downloaded vhdl_ls (no hierarchy support) the view shows the "method not found" notice and the picker shows the warning toast instead of erroring

Adds a VHDL Hierarchy activity-bar view that renders the project's
design instantiation tree by calling two custom requests on the language
server, vhdl/designHierarchy and vhdl/designHierarchyCandidates.

Picking a top entity opens a quick-pick pre-populated from the server:
real top candidates (entities with no incoming instantiations) come
first, deepest subtree first, so the intended top of the design
typically sits at the top of the list. Each candidate shows the depth
and instance count plus the entity declaration's file path. Free-text
input is supported as a fallback. The chosen top is persisted to
`vhdlls.topEntity` (workspace scope when available; user scope
otherwise) and reloaded on the next session.

Tree nodes show `instance_label : library.entity(architecture)` with an
icon per node kind (top, bound component, unbound component,
configuration, unresolved). Clicking a node opens the file at the
instantiation site (or, for the top node, at the entity declaration).

If the active vhdl_ls does not implement the new requests
(method-not-found, -32601), the view shows a notice and the picker
displays a one-shot warning instead of failing silently.

Contributions
  - Commands: vhdlls.showHierarchy, vhdlls.setHierarchyTop,
    vhdlls.refreshHierarchy.
  - View container `vhdlHierarchyContainer` with the `vhdlHierarchy`
    view; refresh and edit-top buttons in the title bar.
  - Setting `vhdlls.topEntity` (string, e.g. `work.top`).

Version bumped to 0.8.0; CHANGELOG and README updated. Requires a
vhdl_ls build that implements the corresponding LSP requests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant