diff options
author | sumneko <sumneko@hotmail.com> | 2019-05-07 14:28:50 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-05-07 14:28:50 +0800 |
commit | 717729c33ce10067aac8afddd2fc2a5da9d801b5 (patch) | |
tree | 9abcc4b9f809372aa9c031f4f9f0087a2c567d91 /server/src/method | |
parent | a2c3b5915949daf39ddf6f044dbc1a5a64ae9847 (diff) | |
download | lua-language-server-717729c33ce10067aac8afddd2fc2a5da9d801b5.zip |
外部判空
Diffstat (limited to 'server/src/method')
-rw-r--r-- | server/src/method/textDocument/publishDiagnostics.lua | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua index 3a4e4658..0698baea 100644 --- a/server/src/method/textDocument/publishDiagnostics.lua +++ b/server/src/method/textDocument/publishDiagnostics.lua @@ -53,25 +53,27 @@ local function createInfo(lsp, data, lines) } if data.related then local related = {} - for i, info in ipairs(data.related) do + for _, info in ipairs(data.related) do local _, lines = lsp:getVM(info.uri) - local message = info.message - if not message then - local start_line = lines:rowcol(info.start) - local finish_line = lines:rowcol(info.finish) - local chars = {} - for n = start_line, finish_line do - chars[#chars+1] = lines:line(n) + if lines then + local message = info.message + if not message then + local start_line = lines:rowcol(info.start) + local finish_line = lines:rowcol(info.finish) + local chars = {} + for n = start_line, finish_line do + chars[#chars+1] = lines:line(n) + end + message = table.concat(chars, '\n') end - message = table.concat(chars, '\n') - end - related[i] = { - message = message, - location = { - uri = info.uri, - range = getRange(info.start, info.finish, lines), + related[#related+1] = { + message = message, + location = { + uri = info.uri, + range = getRange(info.start, info.finish, lines), + } } - } + end end diagnostic.relatedInformation = related end |