From cae5af4f384ce07da6dd5616c369d50356edee38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 10 Nov 2019 21:44:05 +0800 Subject: =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/core/diagnostics/undefined-global.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'server-beta/src/core') diff --git a/server-beta/src/core/diagnostics/undefined-global.lua b/server-beta/src/core/diagnostics/undefined-global.lua index 1a0af9d9..921ba086 100644 --- a/server-beta/src/core/diagnostics/undefined-global.lua +++ b/server-beta/src/core/diagnostics/undefined-global.lua @@ -10,12 +10,17 @@ return function (uri, callback) return end + local globalCache = {} + -- 遍历全局变量,检查所有没有 mode['set'] 的全局变量 local globals = searcher.getGlobals(ast.ast) for key, infos in pairs(globals) do if infos.mode['set'] == true then goto CONTINUE end + if globalCache[key] then + goto CONTINUE + end local skey = key and key:match '^s|(.+)$' if not skey then goto CONTINUE @@ -26,6 +31,18 @@ return function (uri, callback) if config.config.diagnostics.globals[skey] then goto CONTINUE end + if globalCache[key] == nil then + local uris = files.findGlobals(key) + for i = 1, #uris do + local destAst = files.getAst(uris[i]) + local destGlobals = searcher.getGlobals(destAst.ast) + if destGlobals[key] and destGlobals[key].mode['set'] then + globalCache[key] = true + goto CONTINUE + end + end + end + globalCache[key] = false local message local otherVersion = library.other[skey] local customVersion = library.custom[skey] -- cgit v1.2.3