Support optional once for MOM_enable/disable_address; update extension icon #56

Merged
Christoph merged 2 commits from newIcon into main 2026-10-02 11:16:30 +00:00
Owner

This change adds support for an optional once keyword as the first argument to MOM_enable_address and MOM_disable_address, updates completion/inlay hint logic to recognise and skip that optional keyword, and replaces the extension icon with images/dc-1.png.

Summary of changes

  • Completion signatures and metadata

    • server/src/common/completion_list.json: the format and parameters for MOM_enable_address and MOM_disable_address were updated to document an optional once keyword (format -> MOM_*_address [once] <address_1 ... address_n> and a once parameter entry added).
  • Argument-kind detection

    • server/src/tools/def_flow.py: introduced _OPTIONAL_ONCE_COMMANDS and modified def_argument_kinds so that when the first argument is the literal once (case-insensitive) it is not treated as an address argument. This ensures downstream logic that determines argument kinds ignores the optional keyword.
  • Inlay hint handling

    • server/src/tools/inlay_hint.py: InlayHintParameter now has a keyword field. Signature building reads the keyword from completion metadata. The inlay hint generator skips optional keyword parameters when the actual call does not use them and adjusts parameter indexing so variadic/remaining parameters align correctly.
  • Command completion behavior

    • server/src/tools/tcl_command_completion.py: added once as a suggested value for position 1 of MOM_enable_address and MOM_disable_address. The dynamic completion rules for these commands now use the repeated-argument rule (_REPEATED_ARGUMENTS), allowing multiple addresses after the optional keyword.
  • Tests

    • server/tests/python_tests/test_tcloo_arguments.py: added test_optional_keyword_parameter_is_skipped_when_absent() which constructs signatures and asserts the produced inlay hints include once: when present and skip it when absent.
  • Icon update

    • images/dc-1.png: new file added.
    • package.json: icon field changed from images/nx-1.png to images/dc-1.png.

Why this matters (concrete behavior)

Before this change, the code and completion metadata treated the first argument of MOM_enable_address / MOM_disable_address as an address unconditionally. Calls using the once keyword (for example MOM_enable_address once A3 B4) could have produced incorrect argument-kind classification and inlay hints. After the change:

  • MOM_enable_address once A3 B4 is treated as: optional keyword once, followed by address arguments.
  • MOM_enable_address A3 B4 is treated as: only address arguments (the optional once parameter is skipped).

The completion suggestions and inlay hints now reflect this optional keyword and will not misclassify the once token as an address.

Tests

  • Tests added/changed: server/tests/python_tests/test_tcloo_arguments.py (new test function test_optional_keyword_parameter_is_skipped_when_absent).
  • No test execution results were provided.

Recommended checks for reviewers:

  1. Run the Python unit tests (or at least the new test):
    • pytest -k test_optional_keyword_parameter_is_skipped_when_absent
  2. Manually validate language-server behavior in an editor for these examples:
    • MOM_enable_address A3 B4 (no once: inlay hint; address hints for A3/B4)
    • MOM_enable_address once A3 B4 (once: inlay hint followed by address hints)
    • Confirm completions suggest once in the first argument position and address completions thereafter.
  3. Confirm the package includes images/dc-1.png and that package.json points to the correct icon.

Compatibility and reviewer notes

  • This is intended to be backward-compatible: existing calls without once continue to work; code now recognises once as an explicit optional keyword.
  • Reviewer action: ensure the new icon file is packaged/published with the extension if releasing, and verify there are no other code paths that assume the first argument is always an address for the affected commands (the change alters argument-kind detection for those commands and could affect any consumer relying on the old assumption).
This change adds support for an optional `once` keyword as the first argument to `MOM_enable_address` and `MOM_disable_address`, updates completion/inlay hint logic to recognise and skip that optional keyword, and replaces the extension icon with `images/dc-1.png`. ## Summary of changes - Completion signatures and metadata - `server/src/common/completion_list.json`: the `format` and `parameters` for `MOM_enable_address` and `MOM_disable_address` were updated to document an optional `once` keyword (`format` -> `MOM_*_address [once] <address_1 ... address_n>` and a `once` parameter entry added). - Argument-kind detection - `server/src/tools/def_flow.py`: introduced `_OPTIONAL_ONCE_COMMANDS` and modified `def_argument_kinds` so that when the first argument is the literal `once` (case-insensitive) it is not treated as an address argument. This ensures downstream logic that determines argument kinds ignores the optional keyword. - Inlay hint handling - `server/src/tools/inlay_hint.py`: `InlayHintParameter` now has a `keyword` field. Signature building reads the `keyword` from completion metadata. The inlay hint generator skips optional keyword parameters when the actual call does not use them and adjusts parameter indexing so variadic/remaining parameters align correctly. - Command completion behavior - `server/src/tools/tcl_command_completion.py`: added `once` as a suggested value for position 1 of `MOM_enable_address` and `MOM_disable_address`. The dynamic completion rules for these commands now use the repeated-argument rule (`_REPEATED_ARGUMENTS`), allowing multiple addresses after the optional keyword. - Tests - `server/tests/python_tests/test_tcloo_arguments.py`: added `test_optional_keyword_parameter_is_skipped_when_absent()` which constructs signatures and asserts the produced inlay hints include `once:` when present and skip it when absent. - Icon update - `images/dc-1.png`: new file added. - `package.json`: `icon` field changed from `images/nx-1.png` to `images/dc-1.png`. ## Why this matters (concrete behavior) Before this change, the code and completion metadata treated the first argument of `MOM_enable_address` / `MOM_disable_address` as an address unconditionally. Calls using the `once` keyword (for example `MOM_enable_address once A3 B4`) could have produced incorrect argument-kind classification and inlay hints. After the change: - `MOM_enable_address once A3 B4` is treated as: optional keyword `once`, followed by address arguments. - `MOM_enable_address A3 B4` is treated as: only address arguments (the optional `once` parameter is skipped). The completion suggestions and inlay hints now reflect this optional keyword and will not misclassify the `once` token as an address. ## Tests - Tests added/changed: `server/tests/python_tests/test_tcloo_arguments.py` (new test function `test_optional_keyword_parameter_is_skipped_when_absent`). - No test execution results were provided. Recommended checks for reviewers: 1. Run the Python unit tests (or at least the new test): - pytest -k test_optional_keyword_parameter_is_skipped_when_absent 2. Manually validate language-server behavior in an editor for these examples: - `MOM_enable_address A3 B4` (no `once:` inlay hint; address hints for A3/B4) - `MOM_enable_address once A3 B4` (`once:` inlay hint followed by address hints) - Confirm completions suggest `once` in the first argument position and address completions thereafter. 3. Confirm the package includes `images/dc-1.png` and that `package.json` points to the correct icon. ## Compatibility and reviewer notes - This is intended to be backward-compatible: existing calls without `once` continue to work; code now recognises `once` as an explicit optional keyword. - Reviewer action: ensure the new icon file is packaged/published with the extension if releasing, and verify there are no other code paths that assume the first argument is always an address for the affected commands (the change alters argument-kind detection for those commands and could affect any consumer relying on the old assumption).
Replace the icon reference in package.json from images/nx-1.png to
images/dc-1.png and add the new image asset. This only changes the
extension's display icon; there are no behavioral changes.
feat(completion): support optional 'once' keyword for MOM_enable/disable_address
All checks were successful
Tests / node (pull_request) Successful in 24s
Tests / python (pull_request) Successful in 36s
5244911667
Recognize the literal keyword "once" as an optional first parameter for
MOM_enable_address and MOM_disable_address. This:

- Adds keyword metadata to the built-in completions so the parameter is
  represented as an optional literal in signatures.
- Makes def_flow ignore "once" when determining which arguments are
  address names.
- Extends the inlay-hint logic to store/skip optional keyword parameters
  so displayed parameter labels line up with actual arguments.
- Updates command completion rules to suggest "once" and treat address
  arguments as repeatable.

Adds a unit test that verifies inlay hints include "once:" when the
keyword is present and skip that parameter when it is absent.
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!56
No description provided.