Skip to content

Fix inlay hint port targets#133

Closed
roife wants to merge 2 commits into
masterfrom
fix/seman-token-underline
Closed

Fix inlay hint port targets#133
roife wants to merge 2 commits into
masterfrom
fix/seman-token-underline

Conversation

@roife

@roife roife commented May 25, 2026

Copy link
Copy Markdown
Member

Summary

  • resolve ANSI port hint targets through declarator ids
  • keep named/ordered port hint target locations aligned with the displayed port
  • tighten inlay hint collection for named and ordered connections

Verification

  • cargo fmt && cargo clippy --all-targets --all-features

Copilot AI review requested due to automatic review settings May 25, 2026 04:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines SystemVerilog port-related IDE features so inlay hints, semantic tokens, and go-to-definition resolve and anchor to the correct port “name” locations (especially for named/ordered connections and ANSI vs non-ANSI ports), and adds targeted regression tests.

Changes:

  • Update semantic token collection to use name_range() for named port connections and add a regression test.
  • Rework inlay hint port-connection resolution to align hint targets/positions with the displayed port (including direction indicators) and add extensive tests.
  • Add scope/query helpers to resolve non-ANSI port declaration IDs by name, plus a new check_or_throw! utility macro used in the refactor.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/utils/src/utry.rs Adds check_or_throw! macro to simplify early-exit control flow in Option-returning try {} blocks.
crates/ide/src/semantic_tokens.rs Switches named port-connection token ranges to name_range() and adds a regression test.
crates/ide/src/inlay_hint.rs Refactors port hint collection/resolution and adds many new port-hint behavior tests.
crates/ide/src/definitions.rs Adds a go-to-definition regression test for named port connection names resolving to the target port.
crates/hir/src/scope.rs Adds ModuleScope::non_ansi_port_decl_id_by_name helper for resolving non-ANSI port decl IDs by name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +317 to +324
let label = if should_skip(module.get(*expr), name) {
arrow.to_string()
} else {
format!("{name} {arrow}")
};
let edit = edits_for_conn(name, conn_src);
let position = src_map.get(*expr).map_or_else(|| conn_start, |src| src.range().start());
collector.collect_hint(conn_src, Some(target_src), Some(position), label, edit);
Comment thread crates/hir/src/scope.rs
Comment on lines +284 to +288
pub fn non_ansi_port_decl_id_by_name(
&self,
module: &Module,
name: &SmolStr,
) -> Option<PortDeclId> {
Comment on lines +311 to +315
PortConn::Empty => {
let label = format!("{name} {arrow}");
let edit = edits_for_conn(name, conn_src);
collector.collect_hint(conn_src, Some(target_src), None, label, edit);
}
#[test]
fn named_port_hint_is_clickable() {
let text = "module child(output out); endmodule\n\
module top; logic instr_addr_o; child u(instr_addr_o); endmodule\n";
@roife roife closed this May 25, 2026
@roife roife deleted the fix/seman-token-underline branch May 31, 2026 20:00
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.

2 participants