summaryrefslogtreecommitdiff
path: root/script-beta/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-16 00:09:54 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-16 00:09:54 +0800
commit51592cb52f944d8b22ce0a7e1ac1a940a4aef735 (patch)
tree20d6a02fe7ecc5d2d0b239afd702e488d84920a9 /script-beta/parser
parent643bdff2713f8d0ac0b9bfd781e35fa2246a1c6d (diff)
downloadlua-language-server-51592cb52f944d8b22ce0a7e1ac1a940a4aef735.zip
从业务层获取缓存
Diffstat (limited to 'script-beta/parser')
-rw-r--r--script-beta/parser/guide.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index 55aa339a..faa77745 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -1736,9 +1736,30 @@ function m.cleanResults(results)
end
end
+function m.getCache(status, obj, mode)
+ if not status.interface.cache then
+ return
+ end
+ if obj.type == 'getglobal'
+ or obj.type == 'setglobal' then
+ local name = m.getKeyName(obj)
+ return status.interface.cache(name, mode)
+ else
+ return status.interface.cache(obj, mode)
+ end
+end
+
function m.searchRefs(status, obj, mode)
status.depth = status.depth + 1
+ local cache, makeCache = m.getCache(status, obj, mode)
+ if cache then
+ for i = 1, #cache do
+ status.results[#status.results+1] = cache[i]
+ end
+ return
+ end
+
-- 检查单步引用
local res = m.getStepRef(obj, mode)
if res then
@@ -1759,6 +1780,10 @@ function m.searchRefs(status, obj, mode)
status.depth = status.depth - 1
m.cleanResults(status.results)
+
+ if makeCache then
+ makeCache(status.results)
+ end
end
function m.searchRefOfValue(status, obj)