feat(tcl): add static variable name extraction and array key completion

This adds tooling to statically extract Tcl variable names from syntax
trees without evaluating substitutions, enabling better completions
for array elements and plain variables. The new helpers are wired
into the completion and navigation flows and are supported by tests
covering array keys and substitutions.

- Introduce variable_names.py with variable_name() and array_key_parts()
- Wire static name extraction into completion and symbol indexing
- Add tests for array key completion with substitutions
This commit is contained in:
Christoph Brandau
2026-09-10 09:07:18 +02:00
parent 7e9a4359cd
commit d8611d7aea
7 changed files with 300 additions and 8 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ from dataclasses import dataclass
from tclint.syntax_tree import Command, Node, Script
from tclint.syntax_tree import List as TclList
from tools.variable_names import variable_name
@dataclass
@@ -81,7 +82,7 @@ def build_variable_index(
return
if routine == "set" and node.args:
raw_name = getattr(node.args[0], "contents", None)
raw_name = variable_name(node.args[0])
base = _normalize_var_name(raw_name)
if base is not None:
if raw_name and raw_name.startswith("::"):