summaryrefslogtreecommitdiff
path: root/server-beta/src/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-04 18:22:51 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-04 18:22:51 +0800
commit521feda953a686ad876186366391340f945ca65b (patch)
treedbda5f79ce6cf55b882b01b10f08fd2638c93de1 /server-beta/src/parser
parent137ede024f4ddeac7c602351371447cd6cf36091 (diff)
downloadlua-language-server-521feda953a686ad876186366391340f945ca65b.zip
更新诊断实现
Diffstat (limited to 'server-beta/src/parser')
-rw-r--r--server-beta/src/parser/guide.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua
index 773fb6d5..d8dd873e 100644
--- a/server-beta/src/parser/guide.lua
+++ b/server-beta/src/parser/guide.lua
@@ -309,16 +309,19 @@ end
--- 遍历所有指定类型的source
function m.eachSourceType(ast, type, callback)
- local cache = ast.typeCache
+ if not ast.typeCache then
+ ast.typeCache = {}
+ end
+ local cache = ast.typeCache[type]
if not cache then
cache = {}
- ast.typeCache = cache
- m.eachSource(ast, function (source)
- if source.type == type then
- cache[#cache+1] = source
- end
- end)
+ ast.typeCache[type] = cache
end
+ m.eachSource(ast, function (source)
+ if source.type == type then
+ cache[#cache+1] = source
+ end
+ end)
for i = 1, #cache do
callback(cache[i])
end