diff options
Diffstat (limited to 'server-beta/src/core/diagnostics')
-rw-r--r-- | server-beta/src/core/diagnostics/undefined-global.lua | 17 |
1 files changed, 17 insertions, 0 deletions
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] |