Compare commits
6
Commits
2026.9.600
...
2026.9.701
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5c1ba1908 | ||
|
|
81fe58e023 | ||
|
|
4c1837c557 | ||
|
|
a1eccf90f4 | ||
|
|
da9091fa38 | ||
|
|
439c700226 |
+288
-38
@@ -1,56 +1,306 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to NX Postprocessor Support are listed here, newest release first.
|
||||
Versions correspond to the Git tags of this repository.
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Reparse only the top-level TCL commands touched by an edit instead of the whole file
|
||||
- Cache the workspace index in the extension storage so restarts skip reparsing unchanged files; the cache is discarded automatically when the server or bundled tclint changes
|
||||
### Documentation
|
||||
|
||||
- Document DEF block templates, addresses, `BLOCK_LIST`/`ADDR_LIST`, and the formatting changes in the README
|
||||
|
||||
## [2026.9.700] - 2026-09-24
|
||||
|
||||
### Added
|
||||
|
||||
- `BLOCK_LIST` and `ADDR_LIST` completion keywords that list all loaded block templates or addresses; the keyword is replaced by the selected quoted name
|
||||
|
||||
### Changed
|
||||
|
||||
- Format comments with a space after `#` (`#Comment` becomes `# Comment`); `##` separators, `#!`, and comments that already start with whitespace stay unchanged
|
||||
|
||||
## [2026.9.600] - 2026-09-24
|
||||
|
||||
### Added
|
||||
|
||||
- Read `BLOCK_TEMPLATE` and `ADDRESS` names from the `.def` files listed under `<DefinedEvents>` in PSC layers; changes to PSC and DEF files are picked up automatically
|
||||
- Suggest block templates for `MOM_do_template` and addresses for `MOM_ask_address_value`, `MOM_force`, and `MOM_suppress`, each followed by variables
|
||||
- Suggest `Always`, `Once`, and `Off` for the first argument of `MOM_force` and `MOM_suppress`
|
||||
- Insert block templates, addresses, and modes in quotes without doubling typed or auto-closed quotes; insert variables with a leading `$`
|
||||
- Persistent workspace index in the extension storage, so restarts skip reparsing unchanged files; the cache is discarded automatically when the server or bundled tclint changes
|
||||
|
||||
### Changed
|
||||
|
||||
- Reparse only the top-level Tcl commands touched by an edit instead of the whole file
|
||||
- Speed up TclOO completion, signature help, inlay hints, and Go to Definition by reusing the cached syntax tree and skipping files without classes
|
||||
- Speed up references, document highlights, and call hierarchy with cached definition lookups
|
||||
- Keep background indexing from blocking requests that need a fresh syntax tree
|
||||
- Add Go to Definition for TclOO classes, constructors, and resolved methods, including PSC library definitions
|
||||
- Index PSC layer scripts (including external paths and legacy Windows encoding) and share TclOO class metadata across files for completion, signatures, inlay hints, and highlighting
|
||||
- Add document-local TclOO method completion for `new`/`create` instances, `my`, and statically inferred return chains
|
||||
|
||||
### Fixed
|
||||
|
||||
- Format and lint `uplevel` bodies as Tcl scripts instead of leaving them untouched
|
||||
- Stop the Python debug bootstrap with a clear error instead of hanging when no debugpy listener or only a stale one is available
|
||||
|
||||
## [2026.9.501] - 2026-09-21
|
||||
|
||||
### Fixed
|
||||
|
||||
- Highlight braced stored-procedure names in `lappend` arguments
|
||||
|
||||
## [2026.9.500] - 2026-09-21
|
||||
|
||||
### Added
|
||||
|
||||
- Index Tcl scripts referenced by PSC layers, including external folders, environment-variable folders, and legacy Windows encoding
|
||||
- Share TclOO class metadata across files for completion, signature help, inlay hints, and highlighting
|
||||
- Go to Definition for TclOO classes, constructors, and resolved methods, including PSC library definitions
|
||||
- CDL event handler snippets declare an extra `<var>_defined` global for parameters marked `TOGGLE Off`
|
||||
- Allow `INVALID` in the CDL `CATEGORY` grammar
|
||||
|
||||
## [2026.9.400] - 2026-09-11
|
||||
|
||||
### Added
|
||||
|
||||
- Document-local TclOO method completion for `new`/`create` instances, `my`, and statically inferred return chains
|
||||
- Signature help and parameter inlay hints for resolved TclOO methods and constructors, including optional and variadic arguments
|
||||
- Suggest TclOO class names as classes and semantically highlight their declarations and calls
|
||||
- Show signature help and parameter inlay hints for resolved TclOO methods and constructors, including optional and variadic arguments
|
||||
- Add incoming and outgoing call hierarchy for custom TCL procedures and MOM event handlers
|
||||
- Add document highlights for procedure and variable occurrences
|
||||
- Make completion context-aware and prioritize local, current-file, workspace, and built-in symbols
|
||||
- Add command-aware completion for Tcl subcommands, fixed arguments, and valid options
|
||||
- Add semantic argument completion for variables, procedures, namespaces, and local file paths
|
||||
- Add placeholder-based snippets for common Tcl structures and `dict for`
|
||||
- Integrate the NX Tcl Remote Debugger directly into NX Postprocessor Support
|
||||
- Add `nx-tcl` attach configurations and breakpoint support for TCL and DEF files
|
||||
- Support breakpoints, stepping, stack frames, variables, watches, evaluation, logpoints, hit conditions, and Tcl error stops
|
||||
- Add generation-safe stack and variable references so delayed VS Code requests cannot address stale NX frames
|
||||
- Add command-buffer breakpoint handling for `LIB_GE_command_buffer_edit_*` source bodies
|
||||
- Extend the README with launch configuration, path mapping, and debugger usage
|
||||
- Prevent truncated TCL inlay hints and add configurable parameter hint modes
|
||||
- Add inlay hints for built-in NX procedures, variadic arguments, and visible ranges
|
||||
- Add inlay hint documentation and navigation to custom procedure definitions
|
||||
- Add signature help for custom TCL procedures and built-in NX/MOM procedures
|
||||
- Clean stale TCL indexes on close, delete, and rename operations
|
||||
- Make background parsing and index updates thread-safe
|
||||
- Improve TCL response times with debounced edits and cached semantic, inlay, hover, completion, and variable indexes
|
||||
- Debounce CDL/DEF diagnostics and remove per-line diagnostic logging
|
||||
- Keep completion working while the file has syntax errors
|
||||
|
||||
## [0.0.1]
|
||||
## [2026.9.300] - 2026-09-10
|
||||
|
||||
- Initial release
|
||||
### Added
|
||||
|
||||
## [0.0.2]
|
||||
- Array key completion, including keys built with substitutions
|
||||
- Generated CDL event handler snippets declare `args`
|
||||
|
||||
- Add Autocomp for TYPE
|
||||
## [2026.9.220] - 2026-09-08
|
||||
|
||||
## [0.1.0]
|
||||
### Fixed
|
||||
|
||||
- Add Hover Feature
|
||||
- Completion inside unfinished braced arguments now recognizes nested commands
|
||||
|
||||
## [0.2.0]
|
||||
## [2026.9.210] - 2026-09-04
|
||||
|
||||
- Add DEF File Support
|
||||
### Added
|
||||
|
||||
## [2026.6.100]
|
||||
- Highlight escaped quoted strings and embedded variables in DEF files
|
||||
|
||||
- Fix several bugs
|
||||
## [2026.9.200] - 2026-09-03
|
||||
|
||||
## [2026.6.200]
|
||||
### Added
|
||||
|
||||
- Fix foramtting bug
|
||||
- Command-aware completion for Tcl subcommands, fixed argument values, and options such as `string compare -nocase`
|
||||
- Semantic argument completion for variables, procedures, namespaces, and local file paths
|
||||
- Placeholder-based snippets for `if`, `foreach`, `proc`, `switch`, `try`, and `dict for`
|
||||
|
||||
## [2026.9.100] - 2026-09-03
|
||||
|
||||
### Added
|
||||
|
||||
- Incoming and outgoing call hierarchy for custom Tcl procedures and MOM event handlers
|
||||
- Document highlights for procedure and variable occurrences
|
||||
- Context-aware completion that ranks local, current-file, workspace, and built-in symbols in that order
|
||||
|
||||
### Changed
|
||||
|
||||
- Update lsprotocol to 2025.0.0
|
||||
|
||||
## [2026.8.300] - 2026-08-28
|
||||
|
||||
### Added
|
||||
|
||||
- Integrate the NX Tcl Remote Debugger; the separate `local-nx.nx-tcl-debug` extension is no longer needed
|
||||
- `nx-tcl` attach configurations and breakpoints in Tcl and DEF files
|
||||
- Stepping, call stack, scopes, variables, watches, evaluation, logpoints, hit conditions, and Tcl error stops
|
||||
- Breakpoints in `LIB_GE_command_buffer_edit_*` bodies, mapped back to their source and owning procedure
|
||||
|
||||
## [2026.8.200] - 2026-08-19
|
||||
|
||||
### Added
|
||||
|
||||
- Configurable parameter-name inlay hints (`inlayHints.parameterNames`, `inlayHints.suppressWhenArgumentMatchesName`) for custom and built-in NX procedures, including variadic arguments
|
||||
- Unlimited inlay hint length for Tcl files, so later parameter names are not truncated
|
||||
|
||||
### Changed
|
||||
|
||||
- Cache semantic tokens, inlay hints, hover, completion, and variable indexes and debounce edits and diagnostics for faster responses
|
||||
|
||||
## [2026.8.100] - 2026-08-19
|
||||
|
||||
### Added
|
||||
|
||||
- Workspace symbol index with Go to Definition, references, and rename
|
||||
- Signature help for custom Tcl procedures and built-in NX/MOM procedures
|
||||
- CDL event handler snippets and hover with generated handler and `mom_` parameter hints
|
||||
- Keep indexes in sync when Tcl files are changed, deleted, or renamed on disk
|
||||
|
||||
## [2026.6.201] - 2026-06-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- Preserve whitespace inside single-line braced expressions when formatting
|
||||
|
||||
## [2026.6.200] - 2026-06-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- Tcl formatting bug caused by the formatter options
|
||||
|
||||
## [2026.6.100] - 2026-06-18
|
||||
|
||||
### Changed
|
||||
|
||||
- Folding ranges for Tcl are computed by the language server, avoiding duplicate regions
|
||||
- Language server restarts are serialized so only one server runs at a time
|
||||
- Pin the Python dependencies of the server and update the bundled libraries
|
||||
|
||||
### Fixed
|
||||
|
||||
- Several stability fixes
|
||||
|
||||
## [2025.9.200] - 2025-09-01
|
||||
|
||||
### Changed
|
||||
|
||||
- Install server dependencies with uv instead of pip
|
||||
- Relicense to AGPL-3.0-or-later
|
||||
|
||||
## [2025.9.101] - 2025-08-16
|
||||
|
||||
### Added
|
||||
|
||||
- Signature help
|
||||
- Variable checks and additional semantic tokens
|
||||
|
||||
### Fixed
|
||||
|
||||
- `incr` on variables that already exist and `foreach` loop variables
|
||||
|
||||
## [2025.8.400] - 2025-08-15
|
||||
|
||||
### Added
|
||||
|
||||
- Outline for DEF and CDL files
|
||||
|
||||
### Fixed
|
||||
|
||||
- Duplicate `MOM_add_to_block_buffer` entry renamed to `MOM_add_to_line_buffer`
|
||||
|
||||
## [2025.8.300] - 2025-08-12
|
||||
|
||||
### Added
|
||||
|
||||
- Go to Definition and document outline for Tcl
|
||||
- Variable index with positions
|
||||
- Procedure documentation in hover
|
||||
|
||||
### Fixed
|
||||
|
||||
- Formatter deleting line continuations (`\`)
|
||||
- Wrong semantic highlighting in several cases
|
||||
|
||||
## [2025.8.202] - 2025-08-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- Formatter deleting line continuations (`\`)
|
||||
|
||||
## [2025.8.201] - 2025-08-11
|
||||
|
||||
### Fixed
|
||||
|
||||
- Highlighting errors
|
||||
|
||||
## [2025.8.200] - 2025-08-09
|
||||
|
||||
- Version change only
|
||||
|
||||
## [2025.8.2] - 2025-08-09
|
||||
|
||||
- Version change only
|
||||
|
||||
## [2025.08.1] - 2025-08-09
|
||||
|
||||
### Added
|
||||
|
||||
- Load procedures from all workspace files and PSC-referenced scripts for completion
|
||||
- Extension icon
|
||||
|
||||
## [0.4.14] - 2025-08-04
|
||||
|
||||
### Added
|
||||
|
||||
- `LIB_GE_command_buffer_edit_*` support in the parser
|
||||
|
||||
### Fixed
|
||||
|
||||
- Namespace calls in POCO code
|
||||
- Semantic highlighting of variables in arrays
|
||||
|
||||
## [0.4.12] - 2025-08-03
|
||||
|
||||
### Added
|
||||
|
||||
- More semantic tokens and completion items
|
||||
|
||||
## [0.4.10] - 2025-07-28
|
||||
|
||||
### Added
|
||||
|
||||
- Linter based on tclint
|
||||
|
||||
### Changed
|
||||
|
||||
- Use tclint as parser and formatter
|
||||
|
||||
## [0.4.9] - 2025-07-22
|
||||
|
||||
### Added
|
||||
|
||||
- More completion items
|
||||
|
||||
## [0.4.8] - 2025-07-21
|
||||
|
||||
### Added
|
||||
|
||||
- More NX functions and hover documentation
|
||||
|
||||
## [0.4.7] - 2025-07-21
|
||||
|
||||
### Added
|
||||
|
||||
- Formatter settings
|
||||
|
||||
### Fixed
|
||||
|
||||
- Formatter fixes
|
||||
|
||||
## [0.4.6] - 2025-07-21
|
||||
|
||||
### Fixed
|
||||
|
||||
- `@` in buffers when formatting
|
||||
|
||||
## [0.4.5] - 2025-07-21
|
||||
|
||||
### Fixed
|
||||
|
||||
- Formatting of buffers
|
||||
|
||||
## [0.4.4] - 2025-07-21
|
||||
|
||||
### Fixed
|
||||
|
||||
- Formatter fixes
|
||||
|
||||
## [0.4.3] - 2025-07-21
|
||||
|
||||
### Fixed
|
||||
|
||||
- Formatting fixes
|
||||
|
||||
## [0.4.2] - 2025-07-20
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release with syntax highlighting, formatting, auto-completion (including `TYPE`), hover, and DEF file support
|
||||
|
||||
@@ -14,6 +14,7 @@ A comprehensive VS Code extension providing language support and remote debuggin
|
||||
- **Document Highlights** - Highlights all reads, writes, and calls of the symbol under the cursor
|
||||
- **Context-aware Completion** - Prioritizes local symbols and suggests variables, procedures, namespaces, paths, Tcl subcommands, valid argument values, and options based on cursor context
|
||||
- **PSC and TclOO Classes** - Indexes Tcl scripts referenced by PSC layers, including external folders. Classes from indexed files provide method completion, signature help, parameter hints, and class highlighting in other files. PSC script names may omit `.tcl`; relative folders resolve from the PSC directory, and environment-variable folders are supported. Missing scripts are reported in the output channel; encrypted libraries cannot supply static class metadata.
|
||||
- **DEF Block Templates and Addresses** - Reads the `.def` files listed under `<DefinedEvents>` in PSC layers and suggests their `BLOCK_TEMPLATE` and `ADDRESS` names, see [DEF block templates and addresses](#def-block-templates-and-addresses)
|
||||
- **Tcl Snippets** - Inserts placeholder-based structures for `if`, `foreach`, `proc`, `switch`, `try`, and `dict for`
|
||||
- **NX Tcl Remote Debugger** - Breakpoints, stepping, call stack, scopes, variables, watches, evaluation, logpoints, hit conditions, and Tcl error stops directly in a running NX Post process
|
||||
|
||||
@@ -48,6 +49,32 @@ TCL files default to unlimited inlay hint length so that VS Code does not
|
||||
truncate later parameter names on a line. An explicit user setting for
|
||||
`editor.inlayHints.maximumLength` still takes precedence.
|
||||
|
||||
## DEF Block Templates and Addresses
|
||||
|
||||
The language server resolves the `.def` files of every PSC layer's `<DefinedEvents>` section the
|
||||
same way as layer scripts (relative to the PSC, `SubFolder`, environment variables, missing `.def`
|
||||
extension) and collects all `BLOCK_TEMPLATE` and `ADDRESS` declarations. Changes to PSC or DEF files
|
||||
are picked up automatically.
|
||||
|
||||
| Command | Suggestions |
|
||||
|---|---|
|
||||
| `MOM_do_template` | Block templates, then variables |
|
||||
| `MOM_ask_address_value` | Addresses, then variables |
|
||||
| `MOM_force`, `MOM_suppress` | 1st argument: `Always`, `Once`, `Off`, then variables; further arguments: addresses, then variables |
|
||||
|
||||
Block templates, addresses, and `Always|Once|Off` are inserted in quotes (`"steady_rest"`); a quote
|
||||
that is already typed or auto-closed is replaced instead of doubled. Variables are inserted with a
|
||||
leading `$`. Typing `$` yourself still shows variables only.
|
||||
|
||||
Two keywords list all loaded names anywhere in a Tcl file:
|
||||
|
||||
- `BLOCK_LIST` - shows all block templates
|
||||
- `ADDR_LIST` - shows all addresses
|
||||
|
||||
Select the keyword from the completion list (or type it completely) to open the list; text typed
|
||||
directly after the keyword, such as `ADDR_LISTSP`, narrows it. The keyword is replaced by the
|
||||
selected quoted name.
|
||||
|
||||
## NX Tcl Remote Debugger
|
||||
|
||||
### Add a VS Code attach configuration
|
||||
@@ -98,13 +125,14 @@ Simply open any supported file type and enjoy:
|
||||
- Syntax highlighting
|
||||
- Error detection and linting
|
||||
- Code completion
|
||||
- Code formatting (Format Document command)
|
||||
- Code formatting (Format Document command), including `uplevel` bodies and a space after `#` in comments
|
||||
- Hover information
|
||||
- Signature help while entering procedure arguments
|
||||
- Incoming and outgoing call hierarchy for custom procedures and MOM event handlers
|
||||
- Document-wide highlights for procedure and variable occurrences
|
||||
- Context-aware completion with local symbols ranked before workspace and built-in symbols, plus semantic arguments, local paths, Tcl subcommands, and options such as `string compare -nocase`
|
||||
- Placeholder-based snippets for common Tcl control structures and procedures
|
||||
- Block template and address suggestions from PSC DEF files, including `BLOCK_LIST` and `ADDR_LIST`
|
||||
- Remote NX Tcl debugging with breakpoints and full stepping
|
||||
|
||||
## Contributing
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "nx-post-support",
|
||||
"displayName": "NX Postprocessor Support",
|
||||
"description": "VS Code extension for NX CAM postprocessor development with language support and remote Tcl debugging for CDL, TCL, and DEF files",
|
||||
"version": "2026.9.501",
|
||||
"version": "2026.9.700",
|
||||
"publisher": "Christoph",
|
||||
"icon": "images/nx-1.png",
|
||||
"activationEvents": [
|
||||
|
||||
@@ -85,6 +85,7 @@ from tools.tcl_command_completion import (
|
||||
TCL_COMMAND_ITEMS,
|
||||
TCL_COMMAND_NAMES,
|
||||
DynamicCompletionKind,
|
||||
line_prefix_at_position,
|
||||
path_completion_items,
|
||||
tcl_argument_completion,
|
||||
)
|
||||
@@ -279,6 +280,66 @@ def document_diagnostic(params: lsp.DocumentDiagnosticParams):
|
||||
lsp.CompletionOptions(trigger_characters=["$", " ", "-", "(", ","]),
|
||||
)
|
||||
def on_completion(params: lsp.CompletionParams) -> lsp.CompletionList:
|
||||
result = _on_completion(params)
|
||||
doc = LSP_SERVER.workspace.get_text_document(params.text_document.uri)
|
||||
symbol_list = _symbol_list_completion(LSP_SERVER.get_lines(doc), params.position)
|
||||
if symbol_list is not None and symbol_list.is_incomplete:
|
||||
# Re-request while typing so the full list appears at BLOCK_LIST/ADDR_LIST.
|
||||
result.items = [*symbol_list.items, *result.items]
|
||||
result.is_incomplete = True
|
||||
return result
|
||||
|
||||
|
||||
# Keywords that expand to all loaded .def names: keyword -> (items, description).
|
||||
SYMBOL_LIST_KEYWORDS = {
|
||||
"BLOCK_LIST": (lambda: LSP_SERVER.block_template_items(), "block templates"),
|
||||
"ADDR_LIST": (lambda: LSP_SERVER.address_items(), "addresses"),
|
||||
}
|
||||
_WORD_BEFORE_CURSOR_RE = re.compile(r"(?<![$\w])[A-Za-z_]+$")
|
||||
|
||||
|
||||
def _symbol_list_completion(source_lines, position: lsp.Position) -> lsp.CompletionList | None:
|
||||
"""Complete BLOCK_LIST/ADDR_LIST to all loaded block templates/addresses.
|
||||
|
||||
While the typed word is a prefix of a keyword, an incomplete list with the
|
||||
keyword itself is returned. Once the keyword is typed, the complete list of
|
||||
quoted names replaces it.
|
||||
"""
|
||||
line_prefix = line_prefix_at_position(source_lines, position)
|
||||
match = _WORD_BEFORE_CURSOR_RE.search(line_prefix or "")
|
||||
if match is None:
|
||||
return None
|
||||
word = match.group()
|
||||
for keyword, (symbol_items, _) in SYMBOL_LIST_KEYWORDS.items():
|
||||
if not word.startswith(keyword):
|
||||
continue
|
||||
items = []
|
||||
ranked = ranked_completion_items(((0, item) for item in symbol_items()), CompletionContext.GENERAL)
|
||||
for item in ranked:
|
||||
item = _quoted_item(item, source_lines, position, word)
|
||||
# Keep every name visible for the typed keyword; text after it narrows.
|
||||
item.filter_text = f"{keyword}{item.label}"
|
||||
items.append(item)
|
||||
return lsp.CompletionList(is_incomplete=False, items=items)
|
||||
|
||||
keywords = [
|
||||
lsp.CompletionItem(
|
||||
label=keyword,
|
||||
kind=lsp.CompletionItemKind.Snippet,
|
||||
detail=f"Show all loaded {description}",
|
||||
insert_text=keyword,
|
||||
sort_text=f"000:{keyword.casefold()}",
|
||||
command=lsp.Command(title=f"Show {description}", command="editor.action.triggerSuggest"),
|
||||
)
|
||||
for keyword, (_, description) in SYMBOL_LIST_KEYWORDS.items()
|
||||
if keyword.startswith(word)
|
||||
]
|
||||
if keywords:
|
||||
return lsp.CompletionList(is_incomplete=True, items=keywords)
|
||||
return None
|
||||
|
||||
|
||||
def _on_completion(params: lsp.CompletionParams) -> lsp.CompletionList:
|
||||
doc = LSP_SERVER.workspace.get_text_document(params.text_document.uri)
|
||||
position = params.position
|
||||
source_lines = LSP_SERVER.get_lines(doc)
|
||||
@@ -302,6 +363,10 @@ def on_completion(params: lsp.CompletionParams) -> lsp.CompletionList:
|
||||
return lsp.CompletionList(is_incomplete=False, items=array_items)
|
||||
context = completion_context(source_lines, position)
|
||||
|
||||
symbol_list = _symbol_list_completion(source_lines, position)
|
||||
if symbol_list is not None and symbol_list.is_incomplete is False:
|
||||
return symbol_list
|
||||
|
||||
# Variable completion wins inside command arguments. Otherwise prefer the
|
||||
# narrow command grammar when the cursor is at a known subcommand/option.
|
||||
argument_completion = None
|
||||
|
||||
@@ -12,6 +12,14 @@ class NxFormatter(BaseFormatter):
|
||||
while leaving all other formatting behavior unchanged.
|
||||
"""
|
||||
|
||||
def format_comment(self, comment) -> List[str]: # type: ignore[override]
|
||||
# "#Comment" -> "# Comment". Leave "#", "##..." separators, "#!" and
|
||||
# comments that already start with whitespace untouched.
|
||||
value = comment.value
|
||||
if value and not value[0].isspace() and value[0] not in "#!":
|
||||
value = " " + value
|
||||
return [f"#{value}"]
|
||||
|
||||
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
|
||||
|
||||
@@ -198,3 +198,63 @@ def test_typed_quotes_are_replaced_not_doubled(tmp_path, monkeypatch):
|
||||
)
|
||||
).items
|
||||
assert _edit(items, "SPOS") == ('"SPOS"', (22, 26))
|
||||
|
||||
|
||||
def test_block_list_prefix_offers_keyword_and_stays_incomplete(tmp_path, monkeypatch):
|
||||
server, _ = _project(tmp_path, monkeypatch)
|
||||
uri = (tmp_path / "caller.tcl").as_uri()
|
||||
source = "MOM_do_template BLOCK_L"
|
||||
server.workspace.put_text_document(
|
||||
lsp.TextDocumentItem(uri=uri, language_id="tcl", version=next(_versions), text=source)
|
||||
)
|
||||
result = lsp_server.on_completion(
|
||||
lsp.CompletionParams(
|
||||
text_document=lsp.TextDocumentIdentifier(uri=uri),
|
||||
position=lsp.Position(line=0, character=len(source)),
|
||||
)
|
||||
)
|
||||
assert result.is_incomplete
|
||||
keyword = result.items[0]
|
||||
assert keyword.label == "BLOCK_LIST"
|
||||
assert keyword.command.command == "editor.action.triggerSuggest"
|
||||
|
||||
|
||||
def test_block_list_shows_all_templates_quoted(tmp_path, monkeypatch):
|
||||
server, _ = _project(tmp_path, monkeypatch)
|
||||
items = _complete(server, tmp_path, "set a 1\n BLOCK_LIST")
|
||||
assert [item.label for item in items] == ["external_subprogram", "steady_rest"]
|
||||
assert _edit(items, "steady_rest") == ('"steady_rest"', (4, 14))
|
||||
assert all(item.filter_text.startswith("BLOCK_LIST") for item in items)
|
||||
|
||||
|
||||
def test_block_list_ignores_variables_and_other_words(tmp_path, monkeypatch):
|
||||
server, _ = _project(tmp_path, monkeypatch)
|
||||
for source in ("set x $BLOCK_LIST", "set x MY_BLOCK_LIST", "set x steady"):
|
||||
labels = [item.label for item in _complete(server, tmp_path, source)]
|
||||
assert "BLOCK_LIST" not in labels
|
||||
|
||||
|
||||
def test_addr_list_shows_all_addresses_quoted(tmp_path, monkeypatch):
|
||||
server, _ = _project(tmp_path, monkeypatch)
|
||||
items = _complete(server, tmp_path, "MOM_force Once ADDR_LIST")
|
||||
assert [item.label for item in items] == ["SPOS", "X"]
|
||||
assert _edit(items, "SPOS") == ('"SPOS"', (15, 24))
|
||||
assert all(item.filter_text.startswith("ADDR_LIST") for item in items)
|
||||
|
||||
|
||||
def test_addr_list_prefix_offers_keyword(tmp_path, monkeypatch):
|
||||
server, _ = _project(tmp_path, monkeypatch)
|
||||
uri = (tmp_path / "caller.tcl").as_uri()
|
||||
source = "ADDR"
|
||||
server.workspace.put_text_document(
|
||||
lsp.TextDocumentItem(uri=uri, language_id="tcl", version=next(_versions), text=source)
|
||||
)
|
||||
result = lsp_server.on_completion(
|
||||
lsp.CompletionParams(
|
||||
text_document=lsp.TextDocumentIdentifier(uri=uri),
|
||||
position=lsp.Position(line=0, character=len(source)),
|
||||
)
|
||||
)
|
||||
assert result.is_incomplete
|
||||
assert result.items[0].label == "ADDR_LIST"
|
||||
assert "BLOCK_LIST" not in {item.label for item in result.items}
|
||||
|
||||
+26
-1
@@ -1,4 +1,4 @@
|
||||
"""Formatting of uplevel bodies."""
|
||||
"""Formatting with NxFormatter."""
|
||||
|
||||
from tclint.format import FormatterOpts
|
||||
from tools.formatter import NxFormatter
|
||||
@@ -31,3 +31,28 @@ def test_uplevel_without_level_and_with_variable_level():
|
||||
assert _format(source) == (
|
||||
"uplevel {\n\tset x 1\n}\nuplevel $lvl {\n\tset y 2\n}\nuplevel set z 3\n"
|
||||
)
|
||||
|
||||
|
||||
def test_comment_gets_space_after_hash():
|
||||
source = (
|
||||
"#Comment\n"
|
||||
"# already spaced\n"
|
||||
"#\tTabbed\n"
|
||||
"#\n"
|
||||
"##########\n"
|
||||
"set x 1 ;#inline\n"
|
||||
"proc a {} {\n"
|
||||
"\t#nested\n"
|
||||
"}\n"
|
||||
)
|
||||
assert _format(source) == (
|
||||
"# Comment\n"
|
||||
"# already spaced\n"
|
||||
"#\tTabbed\n"
|
||||
"#\n"
|
||||
"##########\n"
|
||||
"set x 1 ;# inline\n"
|
||||
"proc a {} {\n"
|
||||
"\t# nested\n"
|
||||
"}\n"
|
||||
)
|
||||
Reference in New Issue
Block a user