diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-23 19:37:58 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-23 19:37:58 +0800 |
commit | e185f2f4ca0df0654359537bb7df352eb0b2697b (patch) | |
tree | 9a4d5bf3abca83ad759b91afc45cf4da368a210d /script/core | |
parent | f1e6d2b134af4f44ecbd5a7d8c465ccce6d36939 (diff) | |
download | lua-language-server-e185f2f4ca0df0654359537bb7df352eb0b2697b.zip |
check global version
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/code-action.lua | 8 | ||||
-rw-r--r-- | script/core/diagnostics/undefined-global.lua | 46 |
2 files changed, 37 insertions, 17 deletions
diff --git a/script/core/code-action.lua b/script/core/code-action.lua index cd5f2f80..b434e2bc 100644 --- a/script/core/code-action.lua +++ b/script/core/code-action.lua @@ -74,9 +74,13 @@ local function solveUndefinedGlobal(uri, diag, results) local name = guide.getName(source) markGlobal(uri, name, results) - - -- TODO check other version end) + + if diag.data and diag.data.versions then + for _, version in ipairs(diag.data.versions) do + changeVersion(uri, version, results) + end + end end local function solveLowercaseGlobal(uri, diag, results) diff --git a/script/core/diagnostics/undefined-global.lua b/script/core/diagnostics/undefined-global.lua index c07c3570..2b7c7b41 100644 --- a/script/core/diagnostics/undefined-global.lua +++ b/script/core/diagnostics/undefined-global.lua @@ -33,26 +33,42 @@ return function (uri, callback) return end - do return end + local message = lang.script('DIAG_UNDEF_GLOBAL', key) + local defs = vm.getDefs(src, 'deep') + local validVersions + for _, def in ipairs(defs) do + if def.bindDocs then + for _, doc in ipairs(def.bindDocs) do + if doc.type == 'doc.version' then + validVersions = vm.getValidVersions(doc) + break + end + end + end + end + + local versions + if validVersions then + versions = {} + for version, valid in pairs(validVersions) do + if valid then + versions[#versions+1] = version + end + end + table.sort(versions) + if #versions > 0 then + message = ('%s(%s)'):format(message, lang.script('DIAG_DEFINED_VERSION', table.concat(versions, '/'), config.config.runtime.version)) + end + end callback { start = src.start, finish = src.finish, tags = { define.DiagnosticTag.Deprecated }, - message = 'adsad', + message = message, + data = { + versions = versions, + } } - - 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 |