From 6576e0283757a58f92227811874406e025dbd98a Mon Sep 17 00:00:00 2001 From: James Westman Date: Tue, 15 Mar 2022 23:06:45 -0500 Subject: [PATCH] lsp: Report warnings correctly Previously all diagnostics had the "error" severity, now warnings are correctly reported as such --- blueprintcompiler/lsp.py | 7 ++++++- blueprintcompiler/lsp_utils.py | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/blueprintcompiler/lsp.py b/blueprintcompiler/lsp.py index 60f7412..fbc45ea 100644 --- a/blueprintcompiler/lsp.py +++ b/blueprintcompiler/lsp.py @@ -264,10 +264,15 @@ class LanguageServer: }) def _create_diagnostic(self, text, err): + if isinstance(err, CompileWarning): + severity = DiagnosticSeverity.Warning + else: + severity = DiagnosticSeverity.Error + return { "range": utils.idxs_to_range(err.start, err.end, text), "message": err.message, - "severity": 1, + "severity": severity, } diff --git a/blueprintcompiler/lsp_utils.py b/blueprintcompiler/lsp_utils.py index 062b7e4..5664ab6 100644 --- a/blueprintcompiler/lsp_utils.py +++ b/blueprintcompiler/lsp_utils.py @@ -103,6 +103,14 @@ class SemanticTokenType(enum.IntEnum): EnumMember = 0 +class DiagnosticSeverity(enum.IntEnum): + Error = 1 + Warning = 2 + Information = 3 + Hint = 4 + + + @dataclass class SemanticToken: start: int