summaryrefslogtreecommitdiff
path: root/script
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
parent528c8073b4785a2a0cfd80466357d2ba252ed950 (diff)
downloadlua-language-server-06d0640c3b408474337be76ae50ef36fe29bfdc0.zip
fix warnings
Diffstat (limited to 'script')
-rw-r--r--script/core/diagnostics/redundant-parameter.lua6
-rw-r--r--script/parser/ast.lua1
-rw-r--r--script/parser/guide.lua18
3 files changed, 17 insertions, 8 deletions
diff --git a/script/core/diagnostics/redundant-parameter.lua b/script/core/diagnostics/redundant-parameter.lua
index 8176f0af..4adf169e 100644
--- a/script/core/diagnostics/redundant-parameter.lua
+++ b/script/core/diagnostics/redundant-parameter.lua
@@ -71,13 +71,7 @@ return function (uri, callback)
return
end
- local cache = vm.getCache 'redundant-parameter'
-
guide.eachSourceType(ast.ast, 'call', function (source)
- -- parameters be expanded by iterator
- if source.node.iterator then
- return
- end
local callArgs = countCallArgs(source)
if callArgs == 0 then
return
diff --git a/script/parser/ast.lua b/script/parser/ast.lua
index 18bff05c..648a6890 100644
--- a/script/parser/ast.lua
+++ b/script/parser/ast.lua
@@ -1577,7 +1577,6 @@ local Defs = {
symbol = symbol,
}
}
- return
end,
UnknownAction = function (start, symbol)
PushError {
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