Cross-file navigation and rename for PSC .def templates and addresses #46
Loading…
Reference in a new issue
No description provided.
Delete branch "refs/pull/46/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This change adds language-server and client support for navigating, hovering, finding references, and renaming PSC .def block templates and addresses across Tcl and .def files.
The combined change implements these behaviors:
Recognize .def symbols in the server:
server/src/tools/def_symbols.pynow parses.defsources into a structuredDefDocumentwith declarations (block templates, addresses, formats) and references (addresses used inside block templates). It also exposes helpers to read.defsource and produce the previous name-only view..deffiles.Indexing and navigation integration:
server/src/tools/navigation.pyis extended withDEF_BLOCK_TEMPLATE/DEF_ADDRESSkinds, a mapping of Tcl commands that accept.defnames, and logic to add symbol occurrences for.defusages in Tcl commands (so Go to Definition / Find References work from Tcl code).server/src/lsp_server.py) uses these new symbol kinds and adds handlers to resolve.def-specific requests and to return definition/hover/reference/rename results for.defsymbols. The server exposes request namesnxPostSupport/def/definition,.../hover,.../references,.../prepareRename, and.../renameto accept the current.deftext from the client (since.deffiles are not synchronized)..defsymbols; the server validates identifier syntax usingDEF_NAME_RE.Client-side providers and activation:
client/src/common/defProviders.tsregisters Definition, Hover, Reference and Rename providers for.deffiles. Each provider forwards the current document text and cursor position to the language server via the newnxPostSupport/def/*requests and converts protocol results back to editor types.client/src/extension.tsregisters these providers during activation.Completion and service updates:
server/src/lsp_tclserver.pyandserver/src/tools/tcl_command_completion.pyare updated to use the richer.defdocument representation (addresses/block template completion, and completion for commands that accept.defnames).Documentation and changelog updates:
README.mdandCHANGELOG.mdupdated to document Go to Definition, hover, references, and Rename across Tcl and.deffiles and list the recognized Tcl commands.Why this matters (supported by diff evidence):
.deffiles were only partially handled (previous code exposed only name lists), and Tcl-side occurrences referencing.defnames were not indexed for cross-file navigation..defsources, indexes declarations and references, recognizes Tcl commands that take.defnames, and exposes cross-file language features through new LSP request routes. The client registers corresponding.deflanguage providers and forwards the current.deftext with each request.Files and implementation notes (only where helpful to assess correctness):
client/src/common/defProviders.ts(registers providers and forwards doc text).client/src/extension.tscallsregisterDefProviders(() => client).server/src/tools/def_symbols.pyintroducesDefDeclaration,DefReference,DefDocumentandparse_def_document, plusread_def_source.server/src/lsp_server.pyadds helper functions and LSP features for thenxPostSupport/def/*requests and calls intotools.def_navigationhelpers.server/src/tools/navigation.pyadds recognition for command argument positions that name block templates/addresses and createsSymbolOccurrenceentries for those arguments.Testing
No test execution results were provided.
Recommended manual checks for a reviewer (focused, reproducible):
.deffile and a Tcl file that calls a recognized command (e.g.MOM_do_template "steady_rest").BLOCK_TEMPLATEdeclaration in the.deffile..deffile..defdeclaration: it should list the declaration, usages in Tcl, and block-template usages inside.defbodies..deffile is loaded by the server): the declaration and all usages in Tcl and.deffiles should be updated together..deffile without saving; confirm that Go to Definition / Hover / References still work (the client sends current unsaved text to the server).Compatibility / reviewer notes
.deffiles are not synchronized in the server; the client sends the current document text with each specializednxPostSupport/def/*request. The server providesdef_documents_snapshot(current_path, current_source)to replace the current file content during requests..deffile (the server returns prepareRename only for declarations present in the parsed.defdocuments).DEF_NAME_REwhen renaming.If you want, I can list focused unit or integration tests to add for the server/parser and for the client providers to make the behavior repeatable under CI.