summaryrefslogtreecommitdiff
path: root/server-beta/src/core/diagnostics/undefined-global.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-10 21:44:05 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-10 21:44:05 +0800
commitcae5af4f384ce07da6dd5616c369d50356edee38 (patch)
treea276f8dd54d33581ce538b45c299bd9644ad9f74 /server-beta/src/core/diagnostics/undefined-global.lua
parent80f8f5bdda5a0401f28a83ea9dd649309ad16c55 (diff)
downloadlua-language-server-cae5af4f384ce07da6dd5616c369d50356edee38.zip
优化性能
Diffstat (limited to 'server-beta/src/core/diagnostics/undefined-global.lua')
-rw-r--r--server-beta/src/core/diagnostics/undefined-global.lua17
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]