Highlight braced stored-proc names in lappend arguments #42

Merged
Christoph merged 1 commits from #41 into main 2026-09-21 19:13:31 +00:00
Owner

This change updates the semantic token highlighter so that stored-procedure names appearing as braced arguments to lappend (and ::lappend) are emitted with the function token type.

Before: braced literal arguments to lappend that matched known custom or standard procedure names were not highlighted as functions.
After: when the command routine is lappend or ::lappend, any BracedWord argument whose contents matches self._custom_function_names | _STANDARD_PROC_NAMES is recorded as a function token at the argument's contents_pos with length len(argument.contents).

Key changes

  • Import BracedWord from tclint.syntax_tree.
  • In _Highlighter.visit_command, detect lappend / ::lappend and iterate command.args:
    • If an argument is a BracedWord and its contents is in the union of custom and standard proc names, append a function semantic token using argument.contents_pos and len(argument.contents).
  • No other command handling was changed; routine-name highlighting remains as before.

Testing

No test execution results were provided.

Recommended checks for reviewers:

  • Create a small Tcl snippet such as lappend mylist {stored_proc} where stored_proc is present in the project's custom function set, and run the semantic token generation to confirm a function token is emitted for the braced name at the expected position and length.
  • Verify that unrelated braced literals (not matching known proc names) are not highlighted as functions.

Notes / Risk

  • The change only affects highlighting of braced arguments to lappend/::lappend and only when the braced literal matches known custom or standard procedure names.
  • Implementation uses argument.contents_pos for token placement; reviewers may want to confirm that position computation matches other token emission code paths.
This change updates the semantic token highlighter so that stored-procedure names appearing as braced arguments to `lappend` (and `::lappend`) are emitted with the `function` token type. Before: braced literal arguments to `lappend` that matched known custom or standard procedure names were not highlighted as functions. After: when the command routine is `lappend` or `::lappend`, any `BracedWord` argument whose `contents` matches `self._custom_function_names | _STANDARD_PROC_NAMES` is recorded as a `function` token at the argument's `contents_pos` with length `len(argument.contents)`. ## Key changes - Import `BracedWord` from `tclint.syntax_tree`. - In `_Highlighter.visit_command`, detect `lappend` / `::lappend` and iterate `command.args`: - If an argument is a `BracedWord` and its `contents` is in the union of custom and standard proc names, append a `function` semantic token using `argument.contents_pos` and `len(argument.contents)`. - No other command handling was changed; routine-name highlighting remains as before. ## Testing No test execution results were provided. Recommended checks for reviewers: - Create a small Tcl snippet such as `lappend mylist {stored_proc}` where `stored_proc` is present in the project's custom function set, and run the semantic token generation to confirm a `function` token is emitted for the braced name at the expected position and length. - Verify that unrelated braced literals (not matching known proc names) are not highlighted as functions. ## Notes / Risk - The change only affects highlighting of braced arguments to `lappend`/`::lappend` and only when the braced literal matches known custom or standard procedure names. - Implementation uses `argument.contents_pos` for token placement; reviewers may want to confirm that position computation matches other token emission code paths.
Christoph added 1 commit 2026-09-21 19:13:24 +00:00
Treat braced lappend arguments that match custom or standard procedure names as
function tokens for semantic highlighting. This applies the same visual
highlighting as calls but does not treat the literal as executable Tcl. Previously
such braced stored-proc names were not highlighted.
Christoph merged commit b6228503fc into main 2026-09-21 19:13:31 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Christoph/nx_post_support#42