Add member/port/package auto-completion (#82)#280
Merged
Conversation
Implements context-aware completion: typing a trigger character suggests the relevant members. - `var.` -> fields of the struct/union type of `var` (the eirikpre#82 request) - `obj.` -> properties/methods of the class type of `obj` - `.` -> ports of the module being instantiated (in a port-connection slot) - `pkg::` -> members declared in package `pkg` All four share one mechanism: detect the context, resolve a container symbol name, then list the symbols whose `container` is that name. Members are found by re-parsing the container's defining file on demand at a high maxDepth, because the default index depth (1) does not capture members of types nested in a package/module. Reuses DefinitionProvider.moduleFromPort for the port context and the `¤` exact-match workspace query to locate defining files. New SystemVerilogCompletionItemProvider (registered with '.'/':' triggers), replacing the unused src/wip/CompletionItemProvider.ts. Adds unit tests for the pure context/type-name helpers and provider tests via executeCompletionItemProvider, plus verilog-examples/member_completion.sv. Closes eirikpre#82 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add the new member/port/package auto-completion (eirikpre#82) to the README feature list and Examples section, and bump the version to 0.15.0 for this feature release (moving the eirikpre#82 entry to a new [0.15.0] CHANGELOG section). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Completion latency came from re-parsing files on every invocation. Add a
per-file parse cache keyed by `fsPath|maxDepth` and invalidated by the
document version, so repeat completions (and same-file struct/package
lookups) reuse the parse instead of round-tripping to the indexer worker.
Also show a transient status-bar spinner ("$(sync~spin) SystemVerilog:
resolving members…") while the lookup runs, so the user gets feedback during
the (now rarer) slow path. The message clears automatically when the work
settles.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extend member completion to enum values: typing `fsm_state ==`/`!=` or a case-item label inside `case (fsm_state)` now suggests the enum's values. - parser-core: index enum values as members of the enum type (getEnumValues), so they flow through the same container-based lookup as struct fields. - symbol-kinds: map `enum_value` to SymbolKind.EnumMember. - CompletionItemProvider: detect `expr ==`/`!=`/`===`/`!==` (a new `value` context) and case-item label positions (enclosingCaseExpr scans back to the enclosing `case (expr)` selector), then list that type's members. Note: this is the enum idiom; for packed structs the fields are reached with `.` (already supported), not via `==`/case. Updates the fixture to a typedef enum and adds parser + provider tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Completion looked up a type/container by name across the whole workspace and merged the members of every same-named definition, so a type name reused in several local-scoped files (e.g. a per-file `state_e`) produced a union of all their members. Resolve with SystemVerilog scope instead: 1. a definition in the current file wins (local scope); 2. otherwise, when the name is defined in multiple files, prefer the definition whose package is imported by the current file (via the file's `import pkg::*` statements), falling back to a single match rather than the union of every same-named definition. Adds scope_a.sv / scope_b.sv (same type name, different values) and a test asserting the other file's values are not offered. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extend scope resolution to respect an explicit package qualifier on the declared type: `pkg_x::kind_e v` now completes pkg_x's members even when a same-named type exists in another package or locally. resolveType now returns the type name plus any explicit package scope (typeScope helper), and completeMembers takes a preferScope: when present it skips the local-definition shortcut and narrows the workspace matches to that package (in addition to wildcard-imported packages). Adds pkg_x.sv/pkg_y.sv (same enum type name in different packages) and scope_explicit.sv with a test asserting only the referenced package's values are offered. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…re#82) A self-contained example exercising every completion context with "TRY:" cursor hints: struct fields (pkt.), package members (demo_pkg::), class members (tr.), module ports (fifo instantiation), and enum values in `==` and case labels. Points to the scope_*/pkg_* fixtures for cross-file scope. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
joecrop
force-pushed
the
feature/82-member-completion
branch
from
June 3, 2026 22:56
593fe1a to
007de58
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements context-aware completion: typing a trigger character suggests the relevant members.
var.-> fields of the struct/union type ofvar(the [Suggestion] Member Auto Suggestion for Struct or Union. #82 request)obj.-> properties/methods of the class type ofobj.-> ports of the module being instantiated (in a port-connection slot)pkg::-> members declared in packagepkgAll four share one mechanism: detect the context, resolve a container symbol name, then list the symbols whose
containeris that name. Members are found by re-parsing the container's defining file on demand at a high maxDepth, because the default index depth (1) does not capture members of types nested in a package/module. Reuses DefinitionProvider.moduleFromPort for the port context and the¤exact-match workspace query to locate defining files.New SystemVerilogCompletionItemProvider (registered with '.'/':' triggers), replacing the unused src/wip/CompletionItemProvider.ts. Adds unit tests for the pure context/type-name helpers and provider tests via executeCompletionItemProvider, plus verilog-examples/member_completion.sv.
Closes #82