diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-30 15:23:18 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-30 15:23:18 +0800 |
commit | 71a267d42d6a28dcf1333092d57714f274fc698d (patch) | |
tree | 29f4d0dff2d052d3c94c5b6bf7cf42de4bbcc646 /server/src/matcher/definition.lua | |
parent | 24243540681b97956ef29a6bec9d94a6f1dc5208 (diff) | |
download | lua-language-server-71a267d42d6a28dcf1333092d57714f274fc698d.zip |
支持向后引用
Diffstat (limited to 'server/src/matcher/definition.lua')
-rw-r--r-- | server/src/matcher/definition.lua | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index 6c2f64b4..a7e51121 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -19,6 +19,9 @@ function mt:getVar(key, source) end function mt:addVarInfo(var, info) + if not var then + return nil + end var[#var+1] = info return var end @@ -197,12 +200,24 @@ function mt:markSimple(simple) elseif tp == 'name' then if not obj.index then var = self:addField(var, obj[1], obj) + if i == #simple then + self:addVarInfo(var, { + type = 'set', + source = obj, + }) + end else var = nil end else if obj.index then var = self:addField(var, obj[1], obj) + if i == #simple then + self:addVarInfo(var, { + type = 'set', + source = obj, + }) + end else var = nil end @@ -407,17 +422,12 @@ local function parseResult(result) end results[1] = {source.start, source.finish} elseif var.type == 'field' then - local source = var.source - if not source then + if #var == 0 then return false end - if #var == 0 then - results[1] = {source.start, source.finish} - else - for i, info in ipairs(var) do - if info.type == 'set' then - results[i] = {info.source.start, info.source.finish} - end + for i, info in ipairs(var) do + if info.type == 'set' then + results[i] = {info.source.start, info.source.finish} end end else |