summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-27 18:20:31 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-27 18:20:31 +0800
commitc8fbfd0f9db355ebfc9a3dd84b7553b30c2a1dc6 (patch)
tree121988970394f99eafc9804c5f10087499596e76
parentffbff19e45c6f41fd6dba9f0baec0eda45b6f05b (diff)
downloadlua-language-server-c8fbfd0f9db355ebfc9a3dd84b7553b30c2a1dc6.zip
改进
-rw-r--r--server/locale/en-US/script.lni1
-rw-r--r--server/locale/zh-CN/script.lni1
-rw-r--r--server/src/method/textDocument/publishDiagnostics.lua17
3 files changed, 16 insertions, 3 deletions
diff --git a/server/locale/en-US/script.lni b/server/locale/en-US/script.lni
index 2b14012f..42bb683a 100644
--- a/server/locale/en-US/script.lni
+++ b/server/locale/en-US/script.lni
@@ -14,3 +14,4 @@ MWS_NOT_COMPLETE = 'Workspace is not complete yet. You may try again later.
MWS_COMPLETE = 'Workspace is complete now. You may try again...'
PARSER_CRASH = 'Parser crashed! Last words:{}'
+PARSER_IN_DEVELOPMENT = 'Syntax check is still in TODO...'
diff --git a/server/locale/zh-CN/script.lni b/server/locale/zh-CN/script.lni
index 17b0948d..300e8cc7 100644
--- a/server/locale/zh-CN/script.lni
+++ b/server/locale/zh-CN/script.lni
@@ -14,3 +14,4 @@ MWS_NOT_COMPLETE = '工作目录还没有准备好,你可以稍后再试
MWS_COMPLETE = '工作目录准备好了,你可以再试一下了...'
PARSER_CRASH = '语法解析崩溃了!遗言:{}'
+PARSER_IN_DEVELOPMENT = '语法检查还在TODO列表里...'
diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua
index 1186374d..552a4ca7 100644
--- a/server/src/method/textDocument/publishDiagnostics.lua
+++ b/server/src/method/textDocument/publishDiagnostics.lua
@@ -1,4 +1,5 @@
local matcher = require 'matcher'
+local lang = require 'language'
local DiagnosticSeverity = {
Error = 1,
@@ -78,15 +79,25 @@ end
local function buildError(err, lines)
local diagnostic = {
source = 'Lua Language Server',
- message = 'Error',
+ message = lang.script.PARSER_IN_DEVELOPMENT,
}
if err.level == 'error' then
diagnostic.severity = DiagnosticSeverity.Error
else
diagnostic.severity = DiagnosticSeverity.Warning
end
- local range = getRange(err.pos, err.pos, lines)
- range['end'].character = 9999
+ local row, col = lines:rowcol(err.pos)
+ local _, max = lines:range(row)
+ local range = {
+ start = {
+ line = row - 1,
+ character = col - 1,
+ },
+ ['end'] = {
+ line = row - 1,
+ character = max,
+ },
+ }
diagnostic.range = range
return diagnostic
end