Index PSC scripts and add TclOO cross-file navigation/completions; handle CDL TOGGLE Off #40

Merged
Christoph merged 0 commits from refs/pull/40/head into main 2026-09-21 18:53:52 +00:00
Christoph commented 2026-09-21 18:53:38 +00:00 (Migrated from git.cbsk-tech.de)

This change set adds cross-file TclOO/PSC indexing and navigation/completion support, plus a small CDL event-handler improvement and a few editor/test-path updates.

Summary

  • Server: index PSC scripts and share TclOO class metadata across files

    • The language server now watches *.psc alongside *.tcl (createFileSystemWatcher("**/*.{tcl,psc}")) and refreshes the PSC index when .psc files change (did_change_watched_files -> _refresh_psc_index).
    • A new refresh helper walks workspace folders and calls LSP_SERVER.refresh_psc_scripts(roots, report=log_warning) to rebuild PSC script metadata.
    • TclOO completions/signatures/inlay hints/semantic highlighting use a per-document class snapshot: class_snapshot(document.path) is passed into tcloo_completions, method_signature_help, InlayHintGenerator, and hl (highlighter) calls. This enables completions, signature help, and go-to-definition to resolve classes/methods defined in indexed PSC/Tcl files across the workspace.
    • goto_definition first attempts to resolve TclOO declarations via tcloo_definition(document.source, document.uri, params.position, LSP_SERVER.class_snapshot(document.path)) and returns that location when found before falling back to the symbol index.
    • Many completion and ranking paths were adjusted to include class/completion items from the file-index snapshots and to combine command/variable candidates appropriately.
  • CDL event handler: detect "TOGGLE Off" and emit *_defined globals

    • The CDL event parser (cdlEventHandlerAtLine) now tokenizes event body braces and tracks PARAM entries and their TOGGLE tokens. When a TOGGLE Off appears for a parameter, that parameter name is recorded in toggleOffParameterNames.
    • createCdlEventHandlerSnippet uses that information to include both the MOM variable and an additional <var>_defined global when a parameter had TOGGLE Off.
    • Trigger example (before/after): previously a PARAM that included TOGGLE Off produced only the MOM variable in the generated snippet; now the snippet also supplies <variable>_defined.
  • Minor editor/test-path and docs updates

    • .vscode/launch.json and .gitignore were updated to reference test/postprocessor instead of test/test.tcl and to ignore /test/postprocessor/.
    • README.md and CHANGELOG.md were updated to mention the PSC/TclOO indexing and Go-to-definition support.
    • CDL completion categories now include INVALID for TYPE completions (categories = ["MILL", "LATHE", "DRILL", "INVALID"]).

Notes about scope and why it matters

  • The core behavior change is that class metadata extracted from indexed PSC/Tcl files is now available across files for completion, signature help, inlay hints, highlighting, and go-to-definition. This is enabled by adding .psc indexing, a refresh path for PSC changes, and plumbing class_snapshot(document.path) through the completion/signature/highlight/definition code.
  • The CDL change is narrowly scoped to event handler snippet generation: it only affects which globals are emitted when TOGGLE Off is present for a PARAM.
  • Other edits are formatting and small refactors in Python/TypeScript call sites to pass the new arguments or to keep style consistent; they do not add additional user-visible features beyond those summarized above.

Testing

No test execution results were provided.

Recommended focused checks for a reviewer or QA:

  • PSC/TclOO cross-file checks

    1. Open or add a PSC script (or a .tcl file referenced by a PSC layer) in a workspace folder different from the current file.
    2. Ensure the server indexes PSC scripts (watch the server output channel/logs for indexing or missing-script warnings).
    3. In a separate Tcl file, verify class/method completions, signature help, and parameter inlay hints for methods or constructors that are defined in the indexed PSC/Tcl files.
    4. Use "Go to Definition" on a class constructor or resolved method call and confirm it navigates to the indexed PSC/Tcl definition.
    5. Modify a .psc file and confirm the server refreshes the PSC index (file watcher should trigger _refresh_psc_index).
  • CDL event handler checks

    1. In a CDL file, create an event with a PARAM and include TOGGLE Off for that parameter.
    2. Use the snippet generation helper or trigger the generated snippet and confirm that both the MOM variable and <var>_defined globals are produced.
  • Misc checks

    • Verify completion for TYPE suggests INVALID.
    • Run the extension in the VS Code dev host (the updated launch.json now points to test/postprocessor).

Compatibility / reviewer notes

  • The server now treats .psc as an indexed script type; repository watchers and index refresh logic were added to handle .psc changes. Reviewers should confirm this is expected for any workspace that uses PSC layer scripts.
  • No tests were executed with this diff; the changes are primarily additive (indexing and additional completion/definition resolution) and local to the language server and client completion/snippet generation.

If you want, I can list the exact code paths where class_snapshot is passed through (completion, signature help, inlay hints, semantic highlighting, goto-definition) or point to the specific files changed for a quick scan.

This change set adds cross-file TclOO/PSC indexing and navigation/completion support, plus a small CDL event-handler improvement and a few editor/test-path updates. Summary - Server: index PSC scripts and share TclOO class metadata across files - The language server now watches `*.psc` alongside `*.tcl` (`createFileSystemWatcher("**/*.{tcl,psc}")`) and refreshes the PSC index when `.psc` files change (`did_change_watched_files` -> `_refresh_psc_index`). - A new refresh helper walks workspace folders and calls `LSP_SERVER.refresh_psc_scripts(roots, report=log_warning)` to rebuild PSC script metadata. - TclOO completions/signatures/inlay hints/semantic highlighting use a per-document class snapshot: `class_snapshot(document.path)` is passed into `tcloo_completions`, `method_signature_help`, `InlayHintGenerator`, and `hl` (highlighter) calls. This enables completions, signature help, and go-to-definition to resolve classes/methods defined in indexed PSC/Tcl files across the workspace. - `goto_definition` first attempts to resolve TclOO declarations via `tcloo_definition(document.source, document.uri, params.position, LSP_SERVER.class_snapshot(document.path))` and returns that location when found before falling back to the symbol index. - Many completion and ranking paths were adjusted to include class/completion items from the file-index snapshots and to combine command/variable candidates appropriately. - CDL event handler: detect "TOGGLE Off" and emit *_defined globals - The CDL event parser (`cdlEventHandlerAtLine`) now tokenizes event body braces and tracks PARAM entries and their TOGGLE tokens. When a `TOGGLE Off` appears for a parameter, that parameter name is recorded in `toggleOffParameterNames`. - `createCdlEventHandlerSnippet` uses that information to include both the MOM variable and an additional `<var>_defined` global when a parameter had `TOGGLE Off`. - Trigger example (before/after): previously a PARAM that included `TOGGLE Off` produced only the MOM variable in the generated snippet; now the snippet also supplies `<variable>_defined`. - Minor editor/test-path and docs updates - `.vscode/launch.json` and `.gitignore` were updated to reference `test/postprocessor` instead of `test/test.tcl` and to ignore `/test/postprocessor/`. - `README.md` and `CHANGELOG.md` were updated to mention the PSC/TclOO indexing and Go-to-definition support. - CDL completion categories now include `INVALID` for `TYPE` completions (`categories = ["MILL", "LATHE", "DRILL", "INVALID"]`). Notes about scope and why it matters - The core behavior change is that class metadata extracted from indexed PSC/Tcl files is now available across files for completion, signature help, inlay hints, highlighting, and go-to-definition. This is enabled by adding `.psc` indexing, a refresh path for PSC changes, and plumbing `class_snapshot(document.path)` through the completion/signature/highlight/definition code. - The CDL change is narrowly scoped to event handler snippet generation: it only affects which globals are emitted when `TOGGLE Off` is present for a PARAM. - Other edits are formatting and small refactors in Python/TypeScript call sites to pass the new arguments or to keep style consistent; they do not add additional user-visible features beyond those summarized above. Testing No test execution results were provided. Recommended focused checks for a reviewer or QA: - PSC/TclOO cross-file checks 1. Open or add a PSC script (or a `.tcl` file referenced by a PSC layer) in a workspace folder different from the current file. 2. Ensure the server indexes PSC scripts (watch the server output channel/logs for indexing or missing-script warnings). 3. In a separate Tcl file, verify class/method completions, signature help, and parameter inlay hints for methods or constructors that are defined in the indexed PSC/Tcl files. 4. Use "Go to Definition" on a class constructor or resolved method call and confirm it navigates to the indexed PSC/Tcl definition. 5. Modify a `.psc` file and confirm the server refreshes the PSC index (file watcher should trigger `_refresh_psc_index`). - CDL event handler checks 1. In a CDL file, create an event with a `PARAM` and include `TOGGLE Off` for that parameter. 2. Use the snippet generation helper or trigger the generated snippet and confirm that both the MOM variable and `<var>_defined` globals are produced. - Misc checks - Verify completion for `TYPE ` suggests `INVALID`. - Run the extension in the VS Code dev host (the updated `launch.json` now points to `test/postprocessor`). Compatibility / reviewer notes - The server now treats `.psc` as an indexed script type; repository watchers and index refresh logic were added to handle `.psc` changes. Reviewers should confirm this is expected for any workspace that uses PSC layer scripts. - No tests were executed with this diff; the changes are primarily additive (indexing and additional completion/definition resolution) and local to the language server and client completion/snippet generation. If you want, I can list the exact code paths where `class_snapshot` is passed through (completion, signature help, inlay hints, semantic highlighting, goto-definition) or point to the specific files changed for a quick scan.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Christoph/nx_post_support!40
No description provided.