diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-30 11:13:36 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-30 11:13:36 +0800 |
commit | 25c9a2d66c82d9244c225ab1c5b56ff389574901 (patch) | |
tree | 1433e4f3ac6676a6f2acf7cdf1edac9e2f42b9ba /server | |
parent | 2ba16469b5c0fd91c2c1723bd1502c00d2873151 (diff) | |
download | lua-language-server-25c9a2d66c82d9244c225ab1c5b56ff389574901.zip |
由API内部判空
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/definition.lua | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index 3fc93dd8..91bacf23 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -183,6 +183,9 @@ function mt:markLocal(name) end function mt:forList(list, callback) + if not list then + return + end if list.type == 'list' then for i = 1, #list do callback(list[i]) @@ -208,11 +211,9 @@ function mt:markLocals(action) local keys = action[1] local values = action[2] -- 要先计算赋值 - if values then - self:forList(values, function (value) - self:searchExp(value) - end) - end + self:forList(values, function (value) + self:searchExp(value) + end) self:forList(keys, function (key) self:markLocal(key) end) @@ -279,11 +280,9 @@ function mt:searchFunction(func) if func.name then self:markSet(func.name) end - if func.arg then - self:forList(func.arg, function (arg) - self:markLocal(arg) - end) - end + self:forList(func.arg, function (arg) + self:markLocal(arg) + end) self:searchActions(func) self.env:pop() end @@ -291,11 +290,9 @@ end function mt:searchLocalFunction(func) self:markLocal(func.name) self.env:push() - if func.arg then - self:forList(func.arg, function (arg) - self:markLocal(arg) - end) - end + self:forList(func.arg, function (arg) + self:markLocal(arg) + end) self:searchActions(func) self.env:pop() end |