summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-27 18:23:33 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-27 18:23:33 +0800
commit1b465b38a3a6dd90f05cf96f2fbb8d201ca2ea60 (patch)
treeb55b19aae07ba0d082b3e3a75e6bc952a60149d1
parentc8fbfd0f9db355ebfc9a3dd84b7553b30c2a1dc6 (diff)
downloadlua-language-server-1b465b38a3a6dd90f05cf96f2fbb8d201ca2ea60.zip
整理代码
-rw-r--r--server/src/matcher/diagnostics.lua21
-rw-r--r--server/src/method/textDocument/publishDiagnostics.lua2
2 files changed, 15 insertions, 8 deletions
diff --git a/server/src/matcher/diagnostics.lua b/server/src/matcher/diagnostics.lua
index 584a0cb5..a6672c0b 100644
--- a/server/src/matcher/diagnostics.lua
+++ b/server/src/matcher/diagnostics.lua
@@ -1,5 +1,12 @@
local lang = require 'language'
+local DiagnosticSeverity = {
+ Error = 1,
+ Warning = 2,
+ Information = 3,
+ Hint = 4,
+}
+
local function searchUnusedLocals(results, callback)
for _, var in ipairs(results.locals) do
if var.key == 'self'
@@ -199,7 +206,7 @@ return function (vm, lines, uri)
datas[#datas+1] = {
start = start,
finish = finish,
- level = 'Information',
+ level = DiagnosticSeverity.Information,
message = lang.script('DIAG_UNUSED_LOCAL', key),
}
end)
@@ -208,7 +215,7 @@ return function (vm, lines, uri)
datas[#datas+1] = {
start = start,
finish = finish,
- level = 'Warning',
+ level = DiagnosticSeverity.Warning,
message = lang.script('DIAG_UNDEFINED_GLOBAL', key),
}
end)
@@ -217,7 +224,7 @@ return function (vm, lines, uri)
datas[#datas+1] = {
start = start,
finish = finish,
- level = 'Information',
+ level =DiagnosticSeverity.Information,
message = lang.script('DIAG_UNUSED_LABEL', key)
}
end)
@@ -226,7 +233,7 @@ return function (vm, lines, uri)
datas[#datas+1] = {
start = start,
finish = finish,
- level = 'Information',
+ level = DiagnosticSeverity.Information,
message = message,
}
end)
@@ -235,7 +242,7 @@ return function (vm, lines, uri)
datas[#datas+1] = {
start = start,
finish = finish,
- level = 'Information',
+ level = DiagnosticSeverity.Information,
message = lang.script('DIAG_REDEFINED_LOCAL', key),
related = related,
}
@@ -245,7 +252,7 @@ return function (vm, lines, uri)
datas[#datas+1] = {
start = start,
finish = finish,
- level = 'Warning',
+ level = DiagnosticSeverity.Information,
message = lang.script.DIAG_PREVIOUS_CALL,
}
end)
@@ -254,7 +261,7 @@ return function (vm, lines, uri)
datas[#datas+1] = {
start = start,
finish = finish,
- level = 'Warning',
+ level = DiagnosticSeverity.Warning,
message = lang.script('DIAG_OVER_MAX_ARGS', max, passed),
}
end)
diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua
index 552a4ca7..362851ed 100644
--- a/server/src/method/textDocument/publishDiagnostics.lua
+++ b/server/src/method/textDocument/publishDiagnostics.lua
@@ -47,7 +47,7 @@ local function createInfo(data, lines)
local diagnostic = {
source = 'Lua Language Server',
range = getRange(data.start, data.finish, lines),
- severity = DiagnosticSeverity[data.level],
+ severity = data.level,
message = data.message,
}
if data.related then