diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-08 17:32:43 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-08 17:32:43 +0800 |
commit | 96955fce58180eb5bf86d11747f7712bbefbcf62 (patch) | |
tree | 3ac82e2a61c212c2b247025f980475dcd9e5aae4 /server-beta/src | |
parent | 2c0db6c014b5b3d1dd48167f9f9bf9f4f65841bd (diff) | |
download | lua-language-server-96955fce58180eb5bf86d11747f7712bbefbcf62.zip |
暂存
Diffstat (limited to 'server-beta/src')
-rw-r--r-- | server-beta/src/searcher/isGlobal.lua | 22 | ||||
-rw-r--r-- | server-beta/src/searcher/searcher.lua | 1 |
2 files changed, 19 insertions, 4 deletions
diff --git a/server-beta/src/searcher/isGlobal.lua b/server-beta/src/searcher/isGlobal.lua index 549220a9..d59a6876 100644 --- a/server-beta/src/searcher/isGlobal.lua +++ b/server-beta/src/searcher/isGlobal.lua @@ -1,15 +1,29 @@ local searcher = require 'searcher.searcher' -function searcher.isGlobal(source) +local function isGlobal(source) local node = source.node if not node then return false end - local isGlobal + local global searcher.eachRef(node, function (info) if info.source.tag == '_ENV' then - isGlobal = true + global = true end end) - return isGlobal + return global +end + +function searcher.isGlobal(source) + local cache = searcher.cache.isGlobal[source] + if cache ~= nil then + return cache + end + cache = isGlobal(source) + searcher.cache.isGlobal[source] = cache + searcher.eachRef(source, function (info) + local src = info.source + searcher.cache.isGlobal[src] = cache + end) + return cache end diff --git a/server-beta/src/searcher/searcher.lua b/server-beta/src/searcher/searcher.lua index 059afe8a..a5b2d677 100644 --- a/server-beta/src/searcher/searcher.lua +++ b/server-beta/src/searcher/searcher.lua @@ -108,6 +108,7 @@ function m.refreshCache() eachRef = {}, eachField = {}, eachGlobal = {}, + isGlobal = {}, specialName = {}, getLibrary = {}, specials = nil, |