diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-08 17:41:16 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-08 17:41:16 +0800 |
commit | 3e37fb57f9548e553e21083acd66339cee528f3e (patch) | |
tree | 08073f3b7ea003b610beaa5c2d4856e1383038a1 /server | |
parent | a310232d2d873813023b099292efd9a78551e4d7 (diff) | |
download | lua-language-server-3e37fb57f9548e553e21083acd66339cee528f3e.zip |
换个实现
Diffstat (limited to 'server')
-rw-r--r-- | server/src/core/definition.lua | 26 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 3 |
2 files changed, 17 insertions, 12 deletions
diff --git a/server/src/core/definition.lua b/server/src/core/definition.lua index 2b476b92..9b9cd75e 100644 --- a/server/src/core/definition.lua +++ b/server/src/core/definition.lua @@ -37,6 +37,7 @@ local function parseValueCrossFile(vm, source, lsp) if #positions > 0 then return positions end + value:eachInfo(function (info) if info.type == 'set' and info.source.uri == value.uri then positions[#positions+1] = { @@ -49,6 +50,20 @@ local function parseValueCrossFile(vm, source, lsp) if #positions > 0 then return positions end + + value:eachInfo(function (info) + if info.type == 'return' and info.source.uri == value.uri then + positions[#positions+1] = { + info.source.start, + info.source.finish, + value.uri, + } + end + end) + if #positions > 0 then + return positions + end + local destVM = lsp:getVM(value.uri) if not destVM then positions[#positions+1] = { @@ -68,17 +83,6 @@ local function parseValueCrossFile(vm, source, lsp) return positions end - local main = destVM.main - local mainValue = main:getFunction() - local mainSource = mainValue.source - local returnSource = mainSource[#mainSource] - if returnSource.type == 'return' then - positions[#positions+1] = { - returnSource[1].start, - returnSource[1].finish, - value.uri, - } - end return positions end diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 643c68ea..07e6917f 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -696,7 +696,8 @@ function mt:doReturn(action) local func = self:getCurrentFunction() values:eachValue(function (n, value) value.uri = self:getUri() - func:setReturn(n, value, action[n]) + func:setReturn(n, value) + value:addInfo('return', action[n]) end) end |