From 06f85eeb557afe156de65449d250d36ec413c719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 8 Jan 2019 17:24:56 +0800 Subject: =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AF=AD=E6=B3=95=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/method/textDocument/publishDiagnostics.lua | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua index 7af652fb..fffd7f9d 100644 --- a/server/src/method/textDocument/publishDiagnostics.lua +++ b/server/src/method/textDocument/publishDiagnostics.lua @@ -76,7 +76,7 @@ local function createInfo(data, lines) return diagnostic end -local function buildError(err, lines) +local function buildError(err, lines, uri) local diagnostic = { source = lang.script.DIAG_SYNTAX_CHECK, message = lang.script('PARSER_'..err.type, err.info) @@ -103,6 +103,26 @@ local function buildError(err, lines) }, } diagnostic.range = range + + local related = err.info and err.info.related + if related then + local start_line = lines:rowcol(related[1]) + local finish_line = lines:rowcol(related[2]) + local chars = {} + for n = start_line, finish_line do + chars[#chars+1] = lines:line(n) + end + local message = table.concat(chars, '\n') + diagnostic.relatedInformation = { + { + message = message, + location = { + uri = uri, + range = getRange(related[1], related[2], lines), + } + } + } + end return diagnostic end @@ -121,7 +141,7 @@ return function (lsp, params) end if errs then for _, err in ipairs(errs) do - diagnostics[#diagnostics+1] = buildError(err, lines) + diagnostics[#diagnostics+1] = buildError(err, lines, uri) end end -- cgit v1.2.3