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/src/core/definition.lua | |
parent | a310232d2d873813023b099292efd9a78551e4d7 (diff) | |
download | lua-language-server-3e37fb57f9548e553e21083acd66339cee528f3e.zip |
换个实现
Diffstat (limited to 'server/src/core/definition.lua')
-rw-r--r-- | server/src/core/definition.lua | 26 |
1 files changed, 15 insertions, 11 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 |