summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-23 18:33:31 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-23 18:33:31 +0800
commitf1e6d2b134af4f44ecbd5a7d8c465ccce6d36939 (patch)
treed63d0ba58e952df366b561e08ad8fe95e9dbb16d
parentdf7487ab0ad9729082bbc71e03070cde3c2046e4 (diff)
downloadlua-language-server-f1e6d2b134af4f44ecbd5a7d8c465ccce6d36939.zip
stage
-rw-r--r--script/core/diagnostics/undefined-global.lua38
-rw-r--r--script/vm/getDocs.lua17
-rw-r--r--test/diagnostics/init.lua6
3 files changed, 46 insertions, 15 deletions
diff --git a/script/core/diagnostics/undefined-global.lua b/script/core/diagnostics/undefined-global.lua
index 778fc1f1..c07c3570 100644
--- a/script/core/diagnostics/undefined-global.lua
+++ b/script/core/diagnostics/undefined-global.lua
@@ -3,6 +3,7 @@ local vm = require 'vm'
local lang = require 'language'
local config = require 'config'
local guide = require 'parser.guide'
+local define = require 'proto.define'
return function (uri, callback)
local ast = files.getAst(uri)
@@ -19,22 +20,39 @@ return function (uri, callback)
if config.config.diagnostics.globals[key] then
return
end
- if #vm.getGlobalSets(guide.getKeyName(src)) > 0 then
+ if #vm.getGlobalSets(guide.getKeyName(src)) == 0 then
+ local message = lang.script('DIAG_UNDEF_GLOBAL', key)
+ callback {
+ start = src.start,
+ finish = src.finish,
+ message = message,
+ }
return
end
- local message = lang.script('DIAG_UNDEF_GLOBAL', key)
- -- TODO check other version
- local otherVersion
- local customVersion
- if otherVersion then
- message = ('%s(%s)'):format(message, lang.script('DIAG_DEFINED_VERSION', table.concat(otherVersion, '/'), config.config.runtime.version))
- elseif customVersion then
- message = ('%s(%s)'):format(message, lang.script('DIAG_DEFINED_CUSTOM', table.concat(customVersion, '/')))
+ if not vm.isDeprecated(src, 'deep') then
+ return
end
+
+ do return end
+
callback {
start = src.start,
finish = src.finish,
- message = message,
+ tags = { define.DiagnosticTag.Deprecated },
+ message = 'adsad',
}
+
+ do return end
+
+ local defs = vm.getDefs(src, 'deep')
+ local versions = {}
+ for _, def in ipairs(defs) do
+
+ end
+ -- TODO check other version
+ local otherVersion
+ if otherVersion then
+ message = ('%s(%s)'):format(message, lang.script('DIAG_DEFINED_VERSION', table.concat(otherVersion, '/'), config.config.runtime.version))
+ end
end)
end
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua
index 842b089d..a620fd0f 100644
--- a/script/vm/getDocs.lua
+++ b/script/vm/getDocs.lua
@@ -161,6 +161,19 @@ local function isDeprecated(value)
return false
end
-function vm.isDeprecated(value)
- return isDeprecated(value)
+function vm.isDeprecated(value, deep)
+ if deep then
+ local defs = vm.getDefs(value, 'deep')
+ if #defs == 0 then
+ return false
+ end
+ for _, def in ipairs(defs) do
+ if not isDeprecated(def) then
+ return false
+ end
+ end
+ return true
+ else
+ return isDeprecated(value)
+ end
end
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index 5d29c1e5..69d0c7bf 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -465,9 +465,9 @@ local f = load('')
f(1, 2, 3)
]]
-TEST [[
-unpack(1)
-]]
+--TEST [[
+--<!unpack!>(1)
+--]]
TEST [[
X = table[<!x!>]