Recognize stored COMMANDBLOCK procs and warn on unknown .def names #49
Loading…
Reference in a new issue
No description provided.
Delete branch "refs/pull/49/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 recognition of procedure names stored in PostConfigurator COMMANDBLOCK properties and introduces diagnostics that warn when literal NX command arguments name a block template or address that no loaded
.deffile declares.Summary of changes and observable behavior
Stored procedures in COMMANDBLOCK properties are now treated as callable procedures:
server/src/tools/stored_procs.pyparses braced COMMANDBLOCK values and extracts the first word of each top-level braced list element as a candidate command name (with 1-based line/column positions).server/src/tools/navigation.pyadds those names into the file symbol index so they participate in Go to Definition, Find References and rename flows.server/src/tools/semantic_tokens.pyhighlights recognized stored names as functions (only when they are known/custom or standard).server/tests/python_tests/test_stored_procs.py.Warnings for undeclared block templates and addresses:
unknown_def_namesinserver/src/tools/def_flow.pywalks literal command arguments and returns (kind, name, range) tuples for literal NX command arguments naming aBLOCK_TEMPLATEorADDRESSthat are not declared in the currently-loaded.defdocuments. It only checks kinds for which declarations are available in the provideddeclaredmapping.TclLanguageServer._def_diagnosticsinserver/src/lsp_tclserver.py. Diagnostic entries use codesunknown-block-templateandunknown-addressand messages like "Block template 'name' is not declared in any loaded .def file"..defdocuments changes,refresh_def_symbolsclears cached diagnostics and requests a client-side diagnostic refresh (via workspace diagnostic refresh support) to ensure warnings update when.deffiles are added/removed/changed.$varor"CYCLE_$x") are not analyzed or warned about.server/tests/python_tests/test_def_flow.pywere extended to assert these warnings and that they are suppressed when.deffiles are not loaded or when names are dynamic.Files changed (high level)
server/src/tools/stored_procs.py(parsing of stored command names)server/src/tools/navigation.py(index stored names),server/src/tools/semantic_tokens.py(highlight stored names),server/src/tools/def_flow.py(unknown_def_names),server/src/lsp_tclserver.py(produce diagnostics and request refresh),CHANGELOG.mdupdatedserver/tests/python_tests/test_stored_procs.py, extendedserver/tests/python_tests/test_def_flow.pyTesting
Tests added or changed:
server/tests/python_tests/test_stored_procs.py(new): unit tests for stored command extraction; LSP goto-definition and references for stored names; highlighting expectations.server/tests/python_tests/test_def_flow.py(updated): tests that unknown block template and address names produce warnings, that dynamic names do not, and that changing.deffiles invalidates cached diagnostics.No test execution results were provided.
Recommended checks for the reviewer
.deffiles and a Tcl file containing:unknown-block-template,unknown-address) and ranges.setproperties with braced lists containing procedure names (e.g.CONF_CTRL_tool set auto_preselect_last_template {custom_header}) and verify Go to Definition, Find References and highlighting work for those stored names.workspace.diagnostics.refreshcapability is advertised; confirm behavior on clients that do and do not advertise this capability.Compatibility and notes
.deffiles are loaded intoself.def_documents. If no.deffiles are loaded, no warnings are emitted (this is deliberate and covered by tests)..defdocuments change, but this request is conditional on client capability. Reviewers should confirm LSP clients used in development/tests advertiseworkspace.diagnostics.refreshif they expect immediate refresh behavior.If you want, I can provide a minimal repro workspace and exact commands to run the server and exercise these behaviors locally.