summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-08 17:24:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-08 17:24:56 +0800
commit06f85eeb557afe156de65449d250d36ec413c719 (patch)
tree355fbf5461666ec23d719900e0cf691906e96d37 /server
parent9b764835aa002f533575b8cd0d0b270a437ef954 (diff)
downloadlua-language-server-06f85eeb557afe156de65449d250d36ec413c719.zip
支持语法检查的关联
Diffstat (limited to 'server')
-rw-r--r--server/src/method/textDocument/publishDiagnostics.lua24
1 files changed, 22 insertions, 2 deletions
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