From f1e6d2b134af4f44ecbd5a7d8c465ccce6d36939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 23 Nov 2020 18:33:31 +0800 Subject: stage --- script/core/diagnostics/undefined-global.lua | 38 ++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'script/core/diagnostics') 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 -- cgit v1.2.3