summaryrefslogtreecommitdiff
path: root/script/parser/guide.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-12-28 19:09:46 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-12-29 15:10:48 +0800
commit7233ce63aa6a1ac7df24a9afea81065877e3965a (patch)
treebc0cb871c30a02188495322e2e507089f539ce65 /script/parser/guide.lua
parent248ca2a2ba50f2c059d8ab2d3d5688584e98bf62 (diff)
downloadlua-language-server-7233ce63aa6a1ac7df24a9afea81065877e3965a.zip
cleanup code
Diffstat (limited to 'script/parser/guide.lua')
-rw-r--r--script/parser/guide.lua54
1 files changed, 39 insertions, 15 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index a6149dd7..ea250356 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -1919,15 +1919,22 @@ function m.checkSameSimpleInCall(status, ref, start, pushQueue, mode)
end
end
m.cleanResults(objs)
- local newStatus = m.status(status)
+ local mark = {}
for _, obj in ipairs(objs) do
+ if mark[obj] then
+ goto CONTINUE
+ end
+ local newStatus = m.status(status)
m.searchRefs(newStatus, obj, mode)
pushQueue(obj, start, true)
+ mark[obj] = true
+ for _, obj in ipairs(newStatus.results) do
+ pushQueue(obj, start, true)
+ mark[obj] = true
+ end
+ ::CONTINUE::
end
status.share.crossCallCount = status.share.crossCallCount - 1
- for _, obj in ipairs(newStatus.results) do
- pushQueue(obj, start, true)
- end
end
local function searchRawset(ref, results)
@@ -2651,12 +2658,9 @@ end
--end
function m.getRefCache(status, obj, mode)
- local cache, globalCache
- if status.depth == 1
- and status.deep then
- globalCache = status.interface.cache and status.interface.cache() or {}
- end
- cache = status.share.refCache or {}
+ local isDeep = status.deep and status.depth == 1
+ local cache = status.share.refCache or {}
+ local deepCache = status.interface.cache and status.interface.cache() or {}
status.share.refCache = cache
if m.isGlobal(obj) then
obj = m.getKeyName(obj)
@@ -2664,22 +2668,42 @@ function m.getRefCache(status, obj, mode)
if not cache[mode] then
cache[mode] = {}
end
- if globalCache and not globalCache[mode] then
- globalCache[mode] = {}
+ if not deepCache[mode] then
+ deepCache[mode] = {}
+ end
+ local sourceCache
+ if isDeep then
+ sourceCache = deepCache[mode][obj]
+ else
+ sourceCache = cache[mode][obj]
end
- local sourceCache = globalCache and globalCache[mode][obj] or cache[mode][obj]
if sourceCache then
return sourceCache
end
sourceCache = {}
cache[mode][obj] = sourceCache
- if globalCache then
- globalCache[mode][obj] = sourceCache
+ if isDeep then
+ deepCache[mode][obj] = sourceCache
end
return nil, function (results)
for i = 1, #results do
sourceCache[i] = results[i]
end
+ if not isDeep then
+ return
+ end
+ if mode == 'ref'
+ or mode == 'def' then
+ for i = 1, #results do
+ local res = results[i]
+ if not deepCache[mode][res] then
+ cache[mode][res] = sourceCache
+ if isDeep then
+ deepCache[mode][res] = sourceCache
+ end
+ end
+ end
+ end
end
end