Skip to content

Commit 06d0640

Browse files
committed
fix warnings
1 parent 528c807 commit 06d0640

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

script/core/diagnostics/redundant-parameter.lua

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ return function (uri, callback)
7171
return
7272
end
7373

74-
local cache = vm.getCache 'redundant-parameter'
75-
7674
guide.eachSourceType(ast.ast, 'call', function (source)
77-
-- parameters be expanded by iterator
78-
if source.node.iterator then
79-
return
80-
end
8175
local callArgs = countCallArgs(source)
8276
if callArgs == 0 then
8377
return

script/parser/ast.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,6 @@ local Defs = {
15771577
symbol = symbol,
15781578
}
15791579
}
1580-
return
15811580
end,
15821581
UnknownAction = function (start, symbol)
15831582
PushError {

script/parser/guide.lua

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ local type = type
5353
---@field state table
5454
---@field comment table
5555
---@field optional boolean
56+
---@field max parser.object
57+
---@field init parser.object
58+
---@field step parser.object
59+
---@field redundant { max: integer, passed: integer }
5660
---@field _root parser.object
5761

5862
---@class guide
@@ -672,17 +676,27 @@ local function getSourceTypeCache(ast)
672676
end
673677

674678
--- 遍历所有指定类型的source
679+
---@param ast parser.object
680+
---@param type string
681+
---@param callback fun(src: parser.object)
682+
---@return any
675683
function m.eachSourceType(ast, type, callback)
676684
local cache = getSourceTypeCache(ast)
677685
local myCache = cache[type]
678686
if not myCache then
679687
return
680688
end
681689
for i = 1, #myCache do
682-
callback(myCache[i])
690+
local res = callback(myCache[i])
691+
if res ~= nil then
692+
return res
693+
end
683694
end
684695
end
685696

697+
---@param ast parser.object
698+
---@param tps string[]
699+
---@param callback fun(src: parser.object)
686700
function m.eachSourceTypes(ast, tps, callback)
687701
local cache = getSourceTypeCache(ast)
688702
for x = 1, #tps do
@@ -696,6 +710,8 @@ function m.eachSourceTypes(ast, tps, callback)
696710
end
697711

698712
--- 遍历所有的source
713+
---@param ast parser.object
714+
---@param callback fun(src: parser.object)
699715
function m.eachSource(ast, callback)
700716
local cache = ast._eachCache
701717
if not cache then

0 commit comments

Comments
 (0)