From 06d0640c3b408474337be76ae50ef36fe29bfdc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 10 Apr 2022 02:48:25 +0800 Subject: fix warnings --- script/parser/guide.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'script/parser/guide.lua') 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 -- cgit v1.2.3