Add FORMAT/address completions and format/block previews for .def files #68
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
state: Done
state: New
type: Bug
type: Feature
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Christoph/nx_post_support!68
Loading…
Reference in a new issue
No description provided.
Delete branch "def_nav"
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 editor support for DEF-format previews and context-aware completions in .def files and integrates them into the LSP server and client.
Summary
FORMAT/ZERO_FORMATinside anADDRESS, showing the format specification and an example output preview. AfterZERO_FORMAT, names containingzeroare ranked first.BLOCK_TEMPLATE, inserting a new element asN[]with the cursor between brackets (or replacing only the name when an element with brackets already exists). The completion details show format and output preview.FORMATdeclaration or afterFORMAT/ZERO_FORMATin an address) shows the specification, a description, and example values formatted as the address would output them (including known leader/trailer). Supports NX-style specifications (eg.&__5.3_) and printf-style formats (eg.%s,%d).FORMATandZERO_FORMATinclude an output preview (e.g.Coordinate → "&__4.3_"previewsSPOS=1.5).BLOCK_TEMPLATE(in .def or referenced from Tcl) previews the whole NC block (literal values formatted as NX, variable-derived values shown as…), and lists all its addresses, expressions, formats, and preview outputs.Key implementation notes (evidence from diff)
DEF_SELECTORwas registered to call the new LSP endpointnxPostSupport/def/completion(file:client/src/common/defProviders.ts).DEF_REQUEST_COMPLETIONand handlerdef_completionadded.def_hovernow first tries a format-specific hover before falling back to existing behavior (file:server/src/lsp_server.py).server/src/tools/def_format.pyadded. It parses NX and printf-style format specifications, produces example values, and renders markdown tables of example inputs → outputs.server/src/tools/def_navigation.pyextended to produce format and address completions, compute previews (leader/trailer handling and sample formatting), and include format previews in address/property tables.package.jsonadds atokenTypesmapping forstring.unquoted.deftootherso bare words in .def are not treated as strings by VS Code (this prevents suppression of quick suggestions while typing).Tests
Recommended checks for reviewers / QA
Manual editor checks in VS Code with the extension built/loaded:
.deffile, type afterFORMAT/ZERO_FORMATin anADDRESSand verify completion suggestions include format spec and preview, and thatZero*-like formats rank higher afterZERO_FORMAT.BLOCK_TEMPLATEbody, start a new line and confirm address completions insertN[]with cursor inside the brackets; if the element already has brackets, confirm only the name is replaced.FORMAT/ZERO_FORMAT) to confirm markdown shows specification, description, and example outputs including leader/trailer.MOM_do_templatecall) and confirm the NC block preview and the per-address table appear with formatted outputs or…for variables.tokenTypeschange).Run the repository test suite (unit/integration tests) to confirm updated/added tests pass locally.
Compatibility / Risk notes
package.jsongrammar token type mapping changes how unquoted words are tokenized by VS Code; this is intentional to allow quick suggestions while typing in .def files.No test execution results were provided.