Highlight braced stored-proc names in lappend arguments #42

Merged
Christoph merged 0 commits from refs/pull/42/head into main 2026-09-21 19:13:31 +00:00
Christoph commented 2026-09-21 19:13:24 +00:00 (Migrated from git.cbsk-tech.de)

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.
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!42
No description provided.