summaryrefslogtreecommitdiff
path: root/script/parser/guide.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-10 02:48:25 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-10 02:48:25 +0800
commit06d0640c3b408474337be76ae50ef36fe29bfdc0 (patch)
tree63258f77191de87ff303bfa09f9c3ba3959e2020 /script/parser/guide.lua
parent528c8073b4785a2a0cfd80466357d2ba252ed950 (diff)
downloadlua-language-server-06d0640c3b408474337be76ae50ef36fe29bfdc0.zip
fix warnings
Diffstat (limited to 'script/parser/guide.lua')
-rw-r--r--script/parser/guide.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 2b22d1b2..c4b0b1db 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -53,6 +53,10 @@ local type = type
---@field state table
---@field comment table
---@field optional boolean
+---@field max parser.object
+---@field init parser.object
+---@field step parser.object
+---@field redundant { max: integer, passed: integer }
---@field _root parser.object
---@class guide
@@ -672,6 +676,10 @@ local function getSourceTypeCache(ast)
end
--- 遍历所有指定类型的source
+---@param ast parser.object
+---@param type string
+---@param callback fun(src: parser.object)
+---@return any
function m.eachSourceType(ast, type, callback)
local cache = getSourceTypeCache(ast)
local myCache = cache[type]
@@ -679,10 +687,16 @@ function m.eachSourceType(ast, type, callback)
return
end
for i = 1, #myCache do
- callback(myCache[i])
+ local res = callback(myCache[i])
+ if res ~= nil then
+ return res
+ end
end
end
+---@param ast parser.object
+---@param tps string[]
+---@param callback fun(src: parser.object)
function m.eachSourceTypes(ast, tps, callback)
local cache = getSourceTypeCache(ast)
for x = 1, #tps do
@@ -696,6 +710,8 @@ function m.eachSourceTypes(ast, tps, callback)
end
--- 遍历所有的source
+---@param ast parser.object
+---@param callback fun(src: parser.object)
function m.eachSource(ast, callback)
local cache = ast._eachCache
if not cache then