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 | |
parent | 24243540681b97956ef29a6bec9d94a6f1dc5208 (diff) | |
download | lua-language-server-71a267d42d6a28dcf1333092d57714f274fc698d.zip |
支持向后引用
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/lsp.lua | 2 | ||||
-rw-r--r-- | server/src/matcher/definition.lua | 28 |
2 files changed, 21 insertions, 9 deletions
diff --git a/server/src/lsp.lua b/server/src/lsp.lua index 01aa8814..7bdde99d 100644 --- a/server/src/lsp.lua +++ b/server/src/lsp.lua @@ -75,6 +75,7 @@ function mt:_readProtoContent(header) local id = res.id local method = res.method local params = res.params + log.debug('recive', id) local response, err = self:_callback(method, params) if id then if response then @@ -91,6 +92,7 @@ function mt:_readProtoContent(header) }, } end + log.debug('send', id) end if response == nil then log.error(err or ('没有回应:' .. method)) 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 |