lsp: Add compile command

Add a custom command to the language server to get the compiled XML from
an open blueprint file.

Fixes #52.
This commit is contained in:
James Westman 2022-03-25 13:59:28 -05:00
parent e3a37893a8
commit 0984e6ecbc
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6

View file

@ -218,6 +218,15 @@ class LanguageServer:
completions = complete(open_file.ast, open_file.tokens, idx) completions = complete(open_file.ast, open_file.tokens, idx)
self._send_response(id, [completion.to_json(True) for completion in completions]) self._send_response(id, [completion.to_json(True) for completion in completions])
@command("textDocument/x-blueprintcompiler-compile")
def compile(self, id, params):
open_file = self._open_files[params["textDocument"]["uri"]]
if open_file.ast is None or len(open_file.ast.errors):
self._send_response(id, {"xml": None})
return
self._send_response(id, { "xml": open_file.ast.generate() })
@command("textDocument/semanticTokens/full") @command("textDocument/semanticTokens/full")
def semantic_tokens(self, id, params): def semantic_tokens(self, id, params):