summaryrefslogtreecommitdiff
path: root/script/parser/guide.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-07-29 15:47:21 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-07-29 15:47:21 +0800
commit6c452f5c36417289f5030074ce4834783e56d06f (patch)
treed5c19f7f5dcba99eb19eae730d5d8ac7e91503bc /script/parser/guide.lua
parent990596122167d4fa5bdc113f10d05027bb3a6bdf (diff)
downloadlua-language-server-6c452f5c36417289f5030074ce4834783e56d06f.zip
stash
Diffstat (limited to 'script/parser/guide.lua')
-rw-r--r--script/parser/guide.lua21
1 files changed, 19 insertions, 2 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 82871d90..0c1462ef 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -640,8 +640,7 @@ function m.eachSourceBetween(ast, start, finish, callback)
end
end
---- 遍历所有指定类型的source
-function m.eachSourceType(ast, type, callback)
+local function getSourceTypeCache(ast)
local cache = ast.typeCache
if not cache then
cache = {}
@@ -659,6 +658,12 @@ function m.eachSourceType(ast, type, callback)
myCache[#myCache+1] = source
end)
end
+ return cache
+end
+
+--- 遍历所有指定类型的source
+function m.eachSourceType(ast, type, callback)
+ local cache = getSourceTypeCache(ast)
local myCache = cache[type]
if not myCache then
return
@@ -668,6 +673,18 @@ function m.eachSourceType(ast, type, callback)
end
end
+function m.eachSourceTypes(ast, tps, callback)
+ local cache = getSourceTypeCache(ast)
+ for x = 1, #tps do
+ local tpCache = cache[tps[x]]
+ if tpCache then
+ for i = 1, #tpCache do
+ callback(tpCache[i])
+ end
+ end
+ end
+end
+
--- 遍历所有的source
function m.eachSource(ast, callback)
local cache = ast.eachCache