summaryrefslogtreecommitdiff
path: root/server-beta/src/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-04 17:28:42 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-04 17:28:42 +0800
commit137ede024f4ddeac7c602351371447cd6cf36091 (patch)
treebff1d78ec63125294bf9337a192902f706db731a /server-beta/src/parser
parenteb1fffc9ddfaa804973b1e05c7001d84194ce5a6 (diff)
downloadlua-language-server-137ede024f4ddeac7c602351371447cd6cf36091.zip
更新诊断
Diffstat (limited to 'server-beta/src/parser')
-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 }