Compare commits

...
Author SHA1 Message Date
Christoph Brandau 579847b56d fix formatter
/ build_and_publish (release) Successful in 33s
2025-08-12 11:35:54 +02:00
Christoph Brandau 618d6b478b fix: formatter when \ was deleting 2025-08-12 11:28:10 +02:00
Christoph cf62044d3e Update version to 2025.8.201 2025-08-11 19:37:32 +00:00
Christoph aeebb5c964 fix: some highlight error
/ build_and_publish (release) Successful in 38s
2025-08-11 21:35:14 +02:00
Christoph f659db1147 Update package.json 2025-08-11 15:12:55 +00:00
Christoph b059a75205 Update version to 2025.9.001 2025-08-11 14:24:17 +00:00
4 changed files with 94 additions and 217 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
"name": "nx-post-support", "name": "nx-post-support",
"displayName": "NX Postprocessor Support", "displayName": "NX Postprocessor Support",
"description": "", "description": "",
"version": "2025.8.200", "version": "2025.8.201",
"publisher": "Christoph", "publisher": "Christoph",
"icon": "images/nx-1.png", "icon": "images/nx-1.png",
"serverInfo": { "serverInfo": {
@@ -129,4 +129,4 @@
"prettier": "^3.4.2", "prettier": "^3.4.2",
"typescript": "^5.7.2" "typescript": "^5.7.2"
} }
} }
+2 -1
View File
@@ -4,7 +4,8 @@ from typing import List, Optional, Tuple
import lsprotocol.types as lsp import lsprotocol.types as lsp
from pygls.workspace.text_document import TextDocument from pygls.workspace.text_document import TextDocument
from tclint.lexer import TclSyntaxError from tclint.lexer import TclSyntaxError
from tclint.format import Formatter, FormatterOpts from tclint.format import FormatterOpts
from tools.formatter import NxFormatter as Formatter
from tclint.violations import Violation from tclint.violations import Violation
from plugins.poco_plugin import commands from plugins.poco_plugin import commands
from tools import checks, parser from tools import checks, parser
+31
View File
@@ -0,0 +1,31 @@
from tclint.format import Formatter as BaseFormatter
from typing import List
class NxFormatter(BaseFormatter):
"""
Custom formatter that inherits from tclint's Formatter but preserves explicit
line continuations (\\) inside braced expressions when they span multiple lines.
This avoids generating syntax errors in environments that require a trailing
backslash for multi-line expressions (e.g., certain NX Post interpreters),
while leaving all other formatting behavior unchanged.
"""
def format_braced_expression(self, expr) -> List[str]: # type: ignore[override]
# This method mirrors BaseFormatter.format_braced_expression but inserts
# a line continuation (" \") between continuation lines similar to
# BaseFormatter.format_expression.
formatted = [""]
for child in expr.children:
lines = self.format(child)
formatted[-1] += lines[0]
for line in lines[1:]:
# add continuation on the previous line; keep next line at the same level
formatted[-1] += " \\" # keep explicit continuation
formatted += [line]
if expr.pos[0] == expr.end_pos[0]:
return self._brace(formatted)
return ["{"] + self._indent(formatted, self.opts.indent) + ["}"]
+59 -214
View File
@@ -1,30 +1,19 @@
{ {
"fileTypes": [ "fileTypes": [ "tcl" ],
"tcl"
],
"name": "tcl", "name": "tcl",
"patterns": [ "patterns": [
{ { "include": "#main" }
"include": "#main"
}
], ],
"scopeName": "source.tcl", "scopeName": "source.tcl",
"uuid": "c7017136-2ff2-48e9-bdb0-570cf238b4a2",
"repository": { "repository": {
"main": { "main": {
"patterns": [ "patterns": [ { "include": "#command" } ]
{
"include": "#command"
}
]
}, },
"args": { "args": {
"patterns": [ "patterns": [
{ { "include": "#quoted_args" },
"include": "#quoted_args" { "include": "#numeric" },
},
{
"include": "#numeric"
},
{ {
"match": "((?<=;)\\s*#.*$)", "match": "((?<=;)\\s*#.*$)",
"name": "comment.tcl", "name": "comment.tcl",
@@ -36,22 +25,10 @@
"patterns": [ "patterns": [
{ {
"begin": "((?<!\\\\)\\{)", "begin": "((?<!\\\\)\\{)",
"beginCaptures": { "beginCaptures": { "1": { "name": "punctuation.tcl" } },
"1": { "patterns": [ { "include": "#braced__1" } ],
"name": "punctuation.tcl" "end": "(\\}([^\\s\\]\\x{0022}]*))",
} "endCaptures": { "1": { "name": "punctuation.tcl" } }
},
"patterns": [
{
"include": "#braced__1"
}
],
"end": "(\\}([^\\s\\]]*))",
"endCaptures": {
"1": {
"name": "punctuation.tcl"
}
}
} }
] ]
}, },
@@ -61,42 +38,24 @@
"match": "(\\\\(?:\\d{1,3}|x[a-fA-F0-9]{1,2}|u[a-fA-F0-9]{1,4}|U[a-fA-F0-9]{1,8}|.))", "match": "(\\\\(?:\\d{1,3}|x[a-fA-F0-9]{1,2}|u[a-fA-F0-9]{1,4}|U[a-fA-F0-9]{1,8}|.))",
"name": "constant.character.escape.tcl" "name": "constant.character.escape.tcl"
}, },
{ { "include": "#keywords" },
"include": "#keywords"
},
{ {
"match": "((?<={)\\s*(?:after|append|apply|array|auto_execok|auto_import|auto_load|auto_mkindex|auto_qualify|auto_reset|bgerror|binary|break|catch|cd|chan|clock|close|concat|continue|coroutine|dde|dict|encoding|eof|error|eval|exec|exit|expr|fblocked|fconfigure|fcopy|fileevent|file|flush|foreach|for|format|gets|global|glob|history|http|if|incr|info|interp|join|lappend|lassign|lindex|linsert|list|llength|lmap|load|lrange|lrepeat|lreplace|lreverse|lsearch|lset|lsort|memory|my|namespace|nextto|next|oo::class|oo::copy|oo::define|oo::objdefine|oo::object|open|package|parray|pid|pkg::create|pkg_mkIndex|platform::shell|proc|puts|pwd|read|regexp|registry|regsub|rename|return|scan|seek|self|set|socket|source|split|string|subst|switch|tailcall|tcl::prefix|tcl_endOfWord|tcl_findLibrary|tcl_startOfNextWord|tcl_startOfPreviousWord|tcl_wordBreakAfter|tcl_wordBreakBefore|tell|throw|time|trace|try|unknown|unload|unset|update|uplevel|upvar|variable|vwait|while|yieldto|yield)\\s+)", "match": "((?<={)\\s*(?:after|append|apply|array|auto_execok|auto_import|auto_load|auto_mkindex|auto_qualify|auto_reset|bgerror|binary|break|catch|cd|chan|clock|close|concat|continue|coroutine|dde|dict|encoding|eof|error|eval|exec|exit|expr|fblocked|fconfigure|fcopy|fileevent|file|flush|foreach|for|format|gets|global|glob|history|http|if|incr|info|interp|join|lappend|lassign|lindex|linsert|list|llength|lmap|load|lrange|lrepeat|lreplace|lreverse|lsearch|lset|lsort|memory|my|namespace|nextto|next|oo::class|oo::copy|oo::define|oo::objdefine|oo::object|open|package|parray|pid|pkg::create|pkg_mkIndex|platform::shell|proc|puts|pwd|read|regexp|registry|regsub|rename|return|scan|seek|self|set|socket|source|split|string|subst|switch|tailcall|tcl::prefix|tcl_endOfWord|tcl_findLibrary|tcl_startOfNextWord|tcl_startOfPreviousWord|tcl_wordBreakAfter|tcl_wordBreakBefore|tell|throw|time|trace|try|unknown|unload|unset|update|uplevel|upvar|variable|vwait|while|yieldto|yield)\\s+)",
"name": "keyword.tcl", "name": "keyword.tcl",
"comment": "Special handling for known commands." "comment": "Special handling for known commands."
}, },
{ { "include": "#braced_inner" },
"include": "#braced_inner" { "include": "#args" }
},
{
"include": "#args"
}
] ]
}, },
"braced_inner": { "braced_inner": {
"patterns": [ "patterns": [
{ {
"begin": "(\\{)", "begin": "(\\{)",
"beginCaptures": { "beginCaptures": { "1": { "name": "punctuation.tcl" } },
"1": { "patterns": [ { "include": "#braced_inner__1" } ],
"name": "punctuation.tcl"
}
},
"patterns": [
{
"include": "#braced_inner__1"
}
],
"end": "(\\})", "end": "(\\})",
"endCaptures": { "endCaptures": { "1": { "name": "punctuation.tcl" } }
"1": {
"name": "punctuation.tcl"
}
}
} }
] ]
}, },
@@ -106,15 +65,9 @@
"match": "(\\\\[\\x{007b}\\x{007d}])", "match": "(\\\\[\\x{007b}\\x{007d}])",
"name": "constant.character.escape.tcl" "name": "constant.character.escape.tcl"
}, },
{ { "include": "#numeric" },
"include": "#numeric" { "include": "#braced_inner" },
}, { "include": "#args" }
{
"include": "#braced_inner"
},
{
"include": "#args"
}
] ]
}, },
"braced_lit": { "braced_lit": {
@@ -139,22 +92,10 @@
"patterns": [ "patterns": [
{ {
"begin": "(\\\\\\s*$)", "begin": "(\\\\\\s*$)",
"beginCaptures": { "beginCaptures": { "1": { "name": "constant.character.escape.tcl" } },
"1": { "patterns": [ { "include": "#command__1" } ],
"name": "constant.character.escape.tcl"
}
},
"patterns": [
{
"include": "#command__1"
}
],
"end": "((?<!\\\\\\s)$)", "end": "((?<!\\\\\\s)$)",
"endCaptures": { "endCaptures": { "1": { "name": "none.tcl" } }
"1": {
"name": "none.tcl"
}
}
}, },
{ {
"match": "(^\\s*#.*)", "match": "(^\\s*#.*)",
@@ -169,73 +110,41 @@
{ {
"match": "(?<=^|{)(\\s*proc\\s+)(\\S+\\s+)((?:(?<!\\\\){)(?:[^\\x{007b}\\x{007d}\\n]*(?:\\g<1>(?:\\\\{|\\\\}|[^\\x{007b}\\x{007d}])*)*)})", "match": "(?<=^|{)(\\s*proc\\s+)(\\S+\\s+)((?:(?<!\\\\){)(?:[^\\x{007b}\\x{007d}\\n]*(?:\\g<1>(?:\\\\{|\\\\}|[^\\x{007b}\\x{007d}])*)*)})",
"captures": { "captures": {
"1": { "1": { "name": "keyword.tcl" },
"name": "keyword.tcl" "2": { "name": "entity.name.function.tcl" },
}, "3": { "name": "none.tcl" }
"2": {
"name": "entity.name.function.tcl"
},
"3": {
"name": "none.tcl"
}
}, },
"comment": "Proc command." "comment": "Proc command."
}, },
{ "include": "#regexp" },
{ "include": "#keywords" },
{ {
"include": "#regexp" "match": "(^\\s*[^\\s\\x{0022}]+|(?:(?<=[^\\x{005c}]\\[)[^\\s\\]]+))",
},
{
"include": "#keywords"
},
{
"match": "(^\\s*\\S+|(?:(?<=[^\\x{005c}]\\[)[^\\s\\]]++(?!\\])))",
"name": "keyword.tcl", "name": "keyword.tcl",
"comment": "All other commands. (NOTE: Iro doesn't support possessive quantifiers, but the grammar does; be sure to replace the second + with ++ after regenerating!)" "comment": "All other commands. (NOTE: Iro doesn't support possessive quantifiers, but the grammar does; be sure to replace the second + with ++ after regenerating!)"
}, },
{ { "include": "#args" }
"include": "#args"
}
] ]
}, },
"command__1": { "command__1": {
"patterns": [ "patterns": [
{ { "include": "#keywords" },
"include": "#keywords" { "include": "#args" }
},
{
"include": "#args"
}
] ]
}, },
"embedded": { "embedded": {
"patterns": [ "patterns": [
{ {
"begin": "((?<!\\\\)\\[)", "begin": "((?<!\\\\)\\[)",
"beginCaptures": { "beginCaptures": { "1": { "name": "punctuation.tcl" } },
"1": { "patterns": [ { "include": "#embedded__1" } ],
"name": "punctuation.tcl"
}
},
"patterns": [
{
"include": "#embedded__1"
}
],
"end": "((?<!\\\\)\\])", "end": "((?<!\\\\)\\])",
"endCaptures": { "endCaptures": { "1": { "name": "punctuation.tcl" } }
"1": {
"name": "punctuation.tcl"
}
}
} }
] ]
}, },
"embedded__1": { "embedded__1": {
"patterns": [ "patterns": [ { "include": "#command" } ]
{
"include": "#command"
}
]
}, },
"keywords": { "keywords": {
"patterns": [ "patterns": [
@@ -263,30 +172,16 @@
"patterns": [ "patterns": [
{ {
"begin": "((?<!\\\\)\")", "begin": "((?<!\\\\)\")",
"beginCaptures": { "beginCaptures": { "1": { "name": "string.tcl" } },
"1": { "patterns": [ { "include": "#quoted__1" } ],
"name": "string.tcl"
}
},
"patterns": [
{
"include": "#quoted__1"
}
],
"end": "(\")", "end": "(\")",
"endCaptures": { "endCaptures": { "1": { "name": "string.tcl" } }
"1": {
"name": "string.tcl"
}
}
} }
] ]
}, },
"quoted__1": { "quoted__1": {
"patterns": [ "patterns": [
{ { "include": "#quoted_args" },
"include": "#quoted_args"
},
{ {
"match": "([^\\x{0024}\\x{005b}\\x{0022}\\x{005c}]+)", "match": "([^\\x{0024}\\x{005b}\\x{0022}\\x{005c}]+)",
"name": "string.tcl" "name": "string.tcl"
@@ -295,22 +190,14 @@
}, },
"quoted_args": { "quoted_args": {
"patterns": [ "patterns": [
{ { "include": "#braced" },
"include": "#braced" { "include": "#quoted" },
}, { "include": "#embedded" },
{
"include": "#quoted"
},
{
"include": "#embedded"
},
{ {
"match": "(\\\\(?:\\d{1,3}|x[a-fA-F0-9]{1,2}|u[a-fA-F0-9]{1,4}|U[a-fA-F0-9]{1,8}|.))", "match": "(\\\\(?:\\d{1,3}|x[a-fA-F0-9]{1,2}|u[a-fA-F0-9]{1,4}|U[a-fA-F0-9]{1,8}|.))",
"name": "constant.character.escape.tcl" "name": "constant.character.escape.tcl"
}, },
{ { "include": "#variable" }
"include": "#variable"
}
] ]
}, },
"regexp": { "regexp": {
@@ -318,57 +205,27 @@
{ {
"begin": "((?<=^|[\\[\\x{007b}\\x{003b}])\\s*(?:regexp|regsub)\\s+)((?:(?:(?:-about|-all|-expanded|-indices|-inline|-lineanchor|-linestop|-line|-nocase|(?:-index\\s+(?:end|\\d+)(?:[\\+\\-]-?\\d+)?))\\s+)*(?:--\\s+)?)?)", "begin": "((?<=^|[\\[\\x{007b}\\x{003b}])\\s*(?:regexp|regsub)\\s+)((?:(?:(?:-about|-all|-expanded|-indices|-inline|-lineanchor|-linestop|-line|-nocase|(?:-index\\s+(?:end|\\d+)(?:[\\+\\-]-?\\d+)?))\\s+)*(?:--\\s+)?)?)",
"beginCaptures": { "beginCaptures": {
"1": { "1": { "name": "keyword.tcl" },
"name": "keyword.tcl" "2": { "name": "none.tcl" }
},
"2": {
"name": "none.tcl"
}
}, },
"patterns": [ "patterns": [ { "include": "#regexp__1" } ],
{
"include": "#regexp__1"
}
],
"end": "(\\s+)", "end": "(\\s+)",
"endCaptures": { "endCaptures": { "1": { "name": "none.tcl" } }
"1": {
"name": "none.tcl"
}
}
}, },
{ { "include": "#args" }
"include": "#args"
}
] ]
}, },
"regexp__1": { "regexp__1": {
"patterns": [ "patterns": [
{ { "include": "#braced_lit_re" },
"include": "#braced_lit_re"
},
{ {
"begin": "((?:(?<!\\\\)\"))", "begin": "((?:(?<!\\\\)\"))",
"beginCaptures": { "beginCaptures": { "1": { "name": "string.regexp.tcl" } },
"1": { "patterns": [ { "include": "#regexp__2" } ],
"name": "string.regexp.tcl"
}
},
"patterns": [
{
"include": "#regexp__2"
}
],
"end": "((?:(?<!\\\\)\"))", "end": "((?:(?<!\\\\)\"))",
"endCaptures": { "endCaptures": { "1": { "name": "string.regexp.tcl" } }
"1": {
"name": "string.regexp.tcl"
}
}
},
{
"include": "#variable"
}, },
{ "include": "#variable" },
{ {
"match": "(\\S+)", "match": "(\\S+)",
"name": "string.regexp.tcl", "name": "string.regexp.tcl",
@@ -378,15 +235,9 @@
}, },
"regexp__2": { "regexp__2": {
"patterns": [ "patterns": [
{ { "include": "#braced_lit_re" },
"include": "#braced_lit_re" { "include": "#embedded" },
}, { "include": "#variable" },
{
"include": "#embedded"
},
{
"include": "#variable"
},
{ {
"match": "(\\\\\"|[^\\x{0022}])", "match": "(\\\\\"|[^\\x{0022}])",
"name": "string.regexp.tcl", "name": "string.regexp.tcl",
@@ -404,15 +255,9 @@
}, },
"word_lit__1": { "word_lit__1": {
"patterns": [ "patterns": [
{ { "include": "#braced_lit" },
"include": "#braced_lit" { "include": "#embedded" },
}, { "include": "#variable" },
{
"include": "#embedded"
},
{
"include": "#variable"
},
{ {
"match": "(\\\\\"|[^\\x{0022}])", "match": "(\\\\\"|[^\\x{0022}])",
"name": "string.tcl", "name": "string.tcl",