summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-01 18:01:08 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-01 18:01:08 +0800
commit430d9b11f13df182a1f4088c6393761f715b1ffe (patch)
treeb9776261383e8be8b258bec3f867169469e695d9
parentf6570295633065a319e695211c05cddc71c1c4a6 (diff)
downloadlua-language-server-430d9b11f13df182a1f4088c6393761f715b1ffe.zip
未使用的标签
-rw-r--r--server/src/core/diagnostics.lua38
1 files changed, 19 insertions, 19 deletions
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua
index e2c7c5ec..447fb224 100644
--- a/server/src/core/diagnostics.lua
+++ b/server/src/core/diagnostics.lua
@@ -75,23 +75,23 @@ function mt:searchUndefinedGlobal(callback)
end
function mt:searchUnusedLabel(callback)
- local results = self.results
- for _, label in ipairs(results.labels) do
- local ok = self.vm:eachInfo(label, function (info)
- if info.type == 'goto' then
+ self.vm:eachSource(function (source)
+ local label = source:bindLabel()
+ if not label then
+ return
+ end
+ if source:action() ~= 'set' then
+ return
+ end
+ local used = label:eachInfo(function (info)
+ if info.type == 'get' then
return true
end
end)
- if ok then
- goto NEXT_LABEL
+ if not used then
+ callback(source.start, source.finish, label:getName())
end
- self.vm:eachInfo(label, function (info)
- if info.type == 'set' then
- callback(info.source.start, info.source.finish, label.key)
- end
- end)
- ::NEXT_LABEL::
- end
+ end)
end
local function isContainPos(obj, start, finish)
@@ -262,12 +262,12 @@ return function (vm, lines, uri)
}
end)
-- 未使用的Label
- --session:doDiagnostics(session.searchUnusedLabel, 'unused-label', function --(key)
- -- return {
- -- level =DiagnosticSeverity.Hint,
- -- message = lang.script('DIAG_UNUSED_LABEL', key)
- -- }
- --end)
+ session:doDiagnostics(session.searchUnusedLabel, 'unused-label', function (key)
+ return {
+ level =DiagnosticSeverity.Hint,
+ message = lang.script('DIAG_UNUSED_LABEL', key)
+ }
+ end)
-- 只有空格与制表符的行,以及后置空格
--session:doDiagnostics(session.searchSpaces, 'trailing-space', function --(message)
-- return {