feat(def-navigation): surface last-loaded .def declaration for hover/GoTo

When a block template or address is declared in multiple PSC layers, hover and
Go to Definition now resolve to the effective declaration (the one from the
last-loaded .def file). Find References and Rename still include all
declarations.

- add effective_def_locations(documents, target, uris) helper (returns the last declaration)
- use effective_def_locations in lsp_server for goto/definition endpoints
- change def_hover_markdown to show the effective declaration and append a short
  "_Overrides ..._" note listing overridden declarations
- update changelog and add a test that verifies hover/GoTo reference the last
  loaded declaration while references include all declarations
This commit is contained in:
2026-09-25 21:38:06 +02:00
parent 525a08c289
commit c8466d2e32
4 changed files with 74 additions and 13 deletions
+4 -4
View File
@@ -55,8 +55,8 @@ from tools.completion_items import (
from tools.def_navigation import (
all_def_target_locations,
def_declarations,
def_definition_locations,
def_hover_markdown,
effective_def_locations,
def_rename_edits,
def_symbol_at,
)
@@ -848,12 +848,12 @@ def goto_definition(params: lsp.DefinitionParams):
context = _navigation_context(params.text_document.uri, params.position)
if context is None:
symbol = _tcl_def_symbol(params.text_document.uri, params.position, _word_at(params.text_document.uri, params.position))
return symbol and _sorted_locations(def_definition_locations(symbol[0], symbol[1])) or None
return symbol and effective_def_locations(symbol[0], symbol[1]) or None
indexes, definitions, _, identity = context
target = _def_target(identity)
if target is not None:
return _sorted_locations(def_definition_locations(LSP_SERVER.def_documents_snapshot(), target)) or None
return effective_def_locations(LSP_SERVER.def_documents_snapshot(), target) or None
locations = [lsp.Location(uri=index.uri, range=occurrence.range) for index, occurrence in matching_occurrences(identity, indexes, definitions) if occurrence.is_definition]
return _sorted_locations(locations) or None
@@ -1033,7 +1033,7 @@ def def_definition(params) -> list[lsp.Location] | None:
if context is None:
return None
documents, def_uris, target, _ = context
return _sorted_locations(def_definition_locations(documents, target, def_uris)) or None
return effective_def_locations(documents, target, def_uris) or None
@LSP_SERVER.feature(DEF_REQUEST_HOVER)