feat(tools): recognize procedures stored in COMMANDBLOCK properties
Add a new module that parses PostConfigurator COMMANDBLOCK values (CONF_* set ...) to extract the first word of braced list elements as procedure names with precise line/column spans. - server/src/tools/stored_procs.py: implement stored_command_names(command) which returns (name, line, column) for static/braced list elements. - Integrate into navigation (build_file_symbol_index) to index these names as non-definitions so Go To Definition / Find References can resolve them. - Integrate into semantic highlighting to mark known stored procedures as functions when appropriate. - Add tests (server/tests/python_tests/test_stored_procs.py) covering parsing, goto-definition, references, and highlighting behavior. - Update CHANGELOG to note the new capability. Notes/constraints: - Only static/braced COMMANDBLOCK values (BracedWord) are considered. - Names must match the command-name pattern and are taken from the first word of each list element.
This commit is contained in:
@@ -5,6 +5,7 @@ import attrs
|
||||
from common.load_data import standard_items
|
||||
from tclint.commands.plugins import PluginManager
|
||||
from tclint.syntax_tree import BareWord, BracedWord, Command, QuotedWord, Visitor
|
||||
from tools.stored_procs import stored_command_names
|
||||
from tools.variable_names import variable_name
|
||||
from tools.tcloo_symbols import class_symbols
|
||||
from tools.tcloo_completion import _analyze
|
||||
@@ -182,6 +183,11 @@ class _Highlighter(Visitor):
|
||||
line, col = argument.contents_pos
|
||||
self._append_token((line - 1, col - 1), len(argument.contents), "function", [])
|
||||
|
||||
# Procedures stored in COMMANDBLOCK properties (CONF_x set prop {proc}).
|
||||
for stored_name, line, col in stored_command_names(command):
|
||||
if stored_name in self._custom_function_names or stored_name in _STANDARD_PROC_NAMES:
|
||||
self._append_token((line - 1, col - 1), len(stored_name), "function", [])
|
||||
|
||||
# Highlight functions (custom or standard) when used as the routine
|
||||
name = getattr(routine, "contents", None)
|
||||
if name:
|
||||
|
||||
Reference in New Issue
Block a user