summaryrefslogtreecommitdiff
path: root/server-beta/src/parser/guide.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/parser/guide.lua')
-rw-r--r--server-beta/src/parser/guide.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua
index 0ca83489..773fb6d5 100644
--- a/server-beta/src/parser/guide.lua
+++ b/server-beta/src/parser/guide.lua
@@ -307,6 +307,23 @@ function m.eachSourceContain(ast, offset, callback)
end
end
+--- 遍历所有指定类型的source
+function m.eachSourceType(ast, type, callback)
+ local cache = ast.typeCache
+ if not cache then
+ cache = {}
+ ast.typeCache = cache
+ m.eachSource(ast, function (source)
+ if source.type == type then
+ cache[#cache+1] = source
+ end
+ end)
+ end
+ for i = 1, #cache do
+ callback(cache[i])
+ end
+end
+
--- 遍历所有的source
function m.eachSource(ast, callback)
local list = { ast }