update completion items

This commit is contained in:
Christoph Brandau
2025-07-30 17:28:18 +02:00
parent 8da61abfce
commit ed045aa459
6 changed files with 208 additions and 166 deletions
+7 -42
View File
@@ -1,49 +1,14 @@
import textwrap
from tclint.parser import Parser
from tclint.parser import Parser, _strip_ws
from tclint.lexer import (
STATE_BRACEDWORD,
TOK_LBRACE,
TOK_WS,
TOK_BACKSLASH_NEWLINE,
TOK_EOF,
TOK_RBRACE,
TOK_RPAREN,
TOK_NEWLINE,
TclSyntaxError,
)
from tclint.syntax_tree import BracedWord
from tclint.syntax_tree import BareWord, TernaryOp, BinaryOp
class CustomParser(Parser):
def parse_braced_word(self, ts):
"""
Ersetzt BracedWord durch echtes Script, wenn mehrzeilig.
"""
pos = ts.pos()
ts.lexer.push_state(STATE_BRACEDWORD)
ts.assert_(TOK_LBRACE)
content = ""
expected = [pos]
while True:
t = ts.type()
if t == TOK_EOF:
raise TclSyntaxError(
"reached EOF without finding match for brace",
expected[-1],
ts.pos(),
)
if t == TOK_LBRACE:
expected.append(ts.pos())
elif t == TOK_RBRACE:
expected.pop()
if not expected:
ts.lexer.pop_state()
ts.next()
break
content += ts.value()
ts.next()
end_pos = ts.pos()
# Mehrzeilig? Dann als Script parsen:
if "\n" in content.strip():
self.parse_script(content)
# Einzeilig: unverändert als Literal
return BracedWord(content, pos=pos, end_pos=end_pos)
pass