feat(server): add TCL signature help support
Adds a signature help system for TCL commands. The LSP server now exposes signature help for custom and built-in MOM procedures, enabling parameter hints while editing. Tests and documentation were added to cover common usage. - Adds signature_help module to parse and present signatures - Integrates with LSP server to provide signature help on the client - Adds tests for custom and built-in procedures
This commit is contained in:
@@ -46,6 +46,7 @@ from tools.folding_ranges import build_folding_ranges
|
||||
from tools.semantic_tokens import _Highlighter, TOKEN_TYPES, TokenModifier
|
||||
from tools.completion_items import completion, remove_existing_items, remove_shared_keys
|
||||
from tools.inlay_hint import InlayHintGenerator
|
||||
from tools.signature_help import build_signature_help
|
||||
from tools.file_sourcing import get_all_psc_files, read_psc_file
|
||||
from lsp_tclserver import TclLanguageServer
|
||||
|
||||
@@ -182,6 +183,43 @@ def on_completion(params: lsp.CompletionParams) -> lsp.CompletionList:
|
||||
return lsp.CompletionList(is_incomplete=False, items=merged)
|
||||
|
||||
|
||||
@LSP_SERVER.feature(
|
||||
lsp.TEXT_DOCUMENT_SIGNATURE_HELP,
|
||||
lsp.SignatureHelpOptions(
|
||||
trigger_characters=[" "],
|
||||
retrigger_characters=[" "],
|
||||
),
|
||||
)
|
||||
def signature_help(params: lsp.SignatureHelpParams) -> lsp.SignatureHelp | None:
|
||||
document = LSP_SERVER.workspace.get_text_document(params.text_document.uri)
|
||||
tree = LSP_SERVER.get_tree(document)
|
||||
|
||||
filepath = str(pathlib.Path(uris.to_fs_path(document.uri)))
|
||||
custom_signatures: dict[str, list[str]] = {}
|
||||
custom_docs: dict[str, str] = {}
|
||||
|
||||
# Prefer declarations from the current document if duplicate proc names
|
||||
# exist in the workspace.
|
||||
for indexed_path, signatures in LSP_SERVER.proc_signatures.items():
|
||||
if indexed_path != filepath:
|
||||
custom_signatures.update(signatures)
|
||||
custom_signatures.update(LSP_SERVER.proc_signatures.get(filepath, {}))
|
||||
|
||||
for indexed_path, docs in LSP_SERVER.proc_docs.items():
|
||||
if indexed_path != filepath:
|
||||
custom_docs.update(docs)
|
||||
custom_docs.update(LSP_SERVER.proc_docs.get(filepath, {}))
|
||||
|
||||
return build_signature_help(
|
||||
document.source,
|
||||
tree,
|
||||
params.position,
|
||||
custom_signatures,
|
||||
custom_docs,
|
||||
standard_items.json_data.get("MOM_procs", []),
|
||||
)
|
||||
|
||||
|
||||
# @LSP_SERVER.feature(lsp.TEXT_DOCUMENT_DOCUMENT_SYMBOL)
|
||||
# def document_symbols(params: lsp.DocumentSymbolParams):
|
||||
# doc = LSP_SERVER.workspace.get_text_document(params.text_document.uri)
|
||||
|
||||
Reference in New Issue
Block a user