summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-08-09 15:14:33 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-08-09 15:14:33 +0800
commit81e64790e12bfc3d5bb150f51051d72bea551a3f (patch)
treea88da887579c874808d3ac43dad86d01665426c9 /server/src
parent9fa1b31633845429bd7d63460d553a9556cad815 (diff)
downloadlua-language-server-81e64790e12bfc3d5bb150f51051d72bea551a3f.zip
诊断支持 Unnecessary
Diffstat (limited to 'server/src')
-rw-r--r--server/src/constant/DiagnosticDefaultSeverity.lua6
-rw-r--r--server/src/constant/DiagnosticTag.lua3
-rw-r--r--server/src/core/diagnostics.lua11
-rw-r--r--server/src/method/textDocument/publishDiagnostics.lua1
4 files changed, 16 insertions, 5 deletions
diff --git a/server/src/constant/DiagnosticDefaultSeverity.lua b/server/src/constant/DiagnosticDefaultSeverity.lua
index 77877434..33df37d8 100644
--- a/server/src/constant/DiagnosticDefaultSeverity.lua
+++ b/server/src/constant/DiagnosticDefaultSeverity.lua
@@ -6,14 +6,14 @@ return {
['trailing-space'] = 'Hint',
['redefined-local'] = 'Hint',
['newline-call'] = 'Information',
- ['redundant-parameter'] = 'Information',
+ ['redundant-parameter'] = 'Hint',
['ambiguity-1'] = 'Warning',
['lowercase-global'] = 'Information',
['undefined-env-child'] = 'Information',
['duplicate-index'] = 'Warning',
['duplicate-method'] = 'Warning',
- ['empty-block'] = 'Information',
- ['redundant-value'] = 'Information',
+ ['empty-block'] = 'Hint',
+ ['redundant-value'] = 'Hint',
['emmy-lua'] = 'Warning',
['set-const'] = 'Error',
}
diff --git a/server/src/constant/DiagnosticTag.lua b/server/src/constant/DiagnosticTag.lua
new file mode 100644
index 00000000..886a69c8
--- /dev/null
+++ b/server/src/constant/DiagnosticTag.lua
@@ -0,0 +1,3 @@
+return {
+ Unnecessary = 1,
+}
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua
index 07c3379d..e3d3ee6a 100644
--- a/server/src/core/diagnostics.lua
+++ b/server/src/core/diagnostics.lua
@@ -4,6 +4,7 @@ local library = require 'core.library'
local buildGlobal = require 'vm.global'
local DiagnosticSeverity = require 'constant.DiagnosticSeverity'
local DiagnosticDefaultSeverity = require 'constant.DiagnosticDefaultSeverity'
+local DiagnosticTag = require 'constant.DiagnosticTag'
local mt = {}
mt.__index = mt
@@ -791,6 +792,7 @@ return function (vm, lines, uri)
session:doDiagnostics(session.searchUnusedLocals, 'unused-local', function (key)
return {
message = lang.script('DIAG_UNUSED_LOCAL', key),
+ tags = {DiagnosticTag.Unnecessary},
}
end)
-- 读取未定义全局变量
@@ -811,13 +813,15 @@ return function (vm, lines, uri)
-- 未使用的Label
session:doDiagnostics(session.searchUnusedLabel, 'unused-label', function (key)
return {
- message = lang.script('DIAG_UNUSED_LABEL', key)
+ message = lang.script('DIAG_UNUSED_LABEL', key),
+ tags = {DiagnosticTag.Unnecessary},
}
end)
-- 未使用的不定参数
session:doDiagnostics(session.searchUnusedVararg, 'unused-vararg', function ()
return {
- message = lang.script.DIAG_UNUSED_VARARG
+ message = lang.script.DIAG_UNUSED_VARARG,
+ tags = {DiagnosticTag.Unnecessary},
}
end)
-- 只有空格与制表符的行,以及后置空格
@@ -843,6 +847,7 @@ return function (vm, lines, uri)
session:doDiagnostics(session.searchRedundantParameters, 'redundant-parameter', function (max, passed)
return {
message = lang.script('DIAG_OVER_MAX_ARGS', max, passed),
+ tags = {DiagnosticTag.Unnecessary},
}
end)
-- x or 0 + 1
@@ -887,12 +892,14 @@ return function (vm, lines, uri)
session:doDiagnostics(session.searchEmptyBlock, 'empty-block', function ()
return {
message = lang.script.DIAG_EMPTY_BLOCK,
+ tags = {DiagnosticTag.Unnecessary},
}
end)
-- 多余的赋值
session:doDiagnostics(session.searchRedundantValue, 'redundant-value', function (max, passed)
return {
message = lang.script('DIAG_OVER_MAX_VALUES', max, passed),
+ tags = {DiagnosticTag.Unnecessary},
}
end)
-- Emmy相关的检查
diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua
index 0698baea..6c949ceb 100644
--- a/server/src/method/textDocument/publishDiagnostics.lua
+++ b/server/src/method/textDocument/publishDiagnostics.lua
@@ -50,6 +50,7 @@ local function createInfo(lsp, data, lines)
severity = data.level,
message = data.message,
code = data.code,
+ tags = data.tags,
}
if data.related then
local related = {}