From 0984e6ecbc5ac85382871d5f2f994bf49599f2d5 Mon Sep 17 00:00:00 2001 From: James Westman Date: Fri, 25 Mar 2022 13:59:28 -0500 Subject: [PATCH] lsp: Add compile command Add a custom command to the language server to get the compiled XML from an open blueprint file. Fixes #52. --- blueprintcompiler/lsp.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/blueprintcompiler/lsp.py b/blueprintcompiler/lsp.py index fbc45ea..68990ef 100644 --- a/blueprintcompiler/lsp.py +++ b/blueprintcompiler/lsp.py @@ -218,6 +218,15 @@ class LanguageServer: completions = complete(open_file.ast, open_file.tokens, idx) 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") def semantic_tokens(self, id, params):