summaryrefslogtreecommitdiff
path: root/script/vm/global.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-11 18:19:30 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-11 18:19:30 +0800
commit2e4f530b33467b94376321c7f9879f2a879429bb (patch)
tree47f3fb4cef9e6cffe9d5484b2ce8cad663c4786e /script/vm/global.lua
parent4f98d5565b416f71d605cafcb22bd76cf697fd03 (diff)
downloadlua-language-server-2e4f530b33467b94376321c7f9879f2a879429bb.zip
fix #1036
Diffstat (limited to 'script/vm/global.lua')
-rw-r--r--script/vm/global.lua43
1 files changed, 21 insertions, 22 deletions
diff --git a/script/vm/global.lua b/script/vm/global.lua
index 218e09db..5ac18ced 100644
--- a/script/vm/global.lua
+++ b/script/vm/global.lua
@@ -21,6 +21,9 @@ local ID_SPLITE = '\x1F'
---@param source parser.object
function mt:addSet(uri, source)
local link = self.links[uri]
+ if not link.sets then
+ link.sets = {}
+ end
link.sets[#link.sets+1] = source
self.setsCache = nil
end
@@ -29,6 +32,9 @@ end
---@param source parser.object
function mt:addGet(uri, source)
local link = self.links[uri]
+ if not link.gets then
+ link.gets = {}
+ end
link.gets[#link.gets+1] = source
self.getsCache = nil
end
@@ -38,20 +44,19 @@ function mt:getSets(suri)
if not self.setsCache then
self.setsCache = {}
end
- ---@type scope
- local scp = suri and scope.getScope(suri) or nil
- local cacheUri = scp and scp.uri or '<fallback>'
+ local scp = scope.getScope(suri)
+ local cacheUri = scp.uri or '<callback>'
if self.setsCache[cacheUri] then
return self.setsCache[cacheUri]
end
self.setsCache[cacheUri] = {}
local cache = self.setsCache[cacheUri]
for uri, link in pairs(self.links) do
- if not scp
- or scp:isChildUri(uri)
- or scp:isLinkedUri(uri) then
- for _, source in ipairs(link.sets) do
- cache[#cache+1] = source
+ if link.sets then
+ if scp:isVisible(uri) then
+ for _, source in ipairs(link.sets) do
+ cache[#cache+1] = source
+ end
end
end
end
@@ -63,20 +68,19 @@ function mt:getGets(suri)
if not self.getsCache then
self.getsCache = {}
end
- ---@type scope
- local scp = suri and scope.getScope(suri) or nil
- local cacheUri = scp and scp.uri or '<fallback>'
+ local scp = scope.getScope(suri)
+ local cacheUri = scp.uri or '<callback>'
if self.getsCache[cacheUri] then
return self.getsCache[cacheUri]
end
self.getsCache[cacheUri] = {}
local cache = self.getsCache[cacheUri]
for uri, link in pairs(self.links) do
- if not scp
- or scp:isChildUri(uri)
- or scp:isLinkedUri(uri) then
- for _, source in ipairs(link.gets) do
- cache[#cache+1] = source
+ if link.gets then
+ if scp:isVisible(uri) then
+ for _, source in ipairs(link.gets) do
+ cache[#cache+1] = source
+ end
end
end
end
@@ -111,11 +115,6 @@ return function (name, cate)
return setmetatable({
name = name,
cate = cate,
- links = util.defaultTable(function ()
- return {
- sets = {},
- gets = {},
- }
- end),
+ links = util.multiTable(2),
}, mt)
end