summaryrefslogtreecommitdiff
path: root/server/src/matcher/definition.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-20 20:11:29 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-20 20:11:29 +0800
commit57c35307702b66554ff1b3f2ff3996ce9aabab93 (patch)
tree5141be92bdefc5fdd1873b5ca4d2dd62400382ed /server/src/matcher/definition.lua
parent0446a98c4c026fcd7101ba63a060b854b1b5753d (diff)
downloadlua-language-server-57c35307702b66554ff1b3f2ff3996ce9aabab93.zip
修正bug
Diffstat (limited to 'server/src/matcher/definition.lua')
-rw-r--r--server/src/matcher/definition.lua58
1 files changed, 33 insertions, 25 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua
index 2f52c9b8..c31f817c 100644
--- a/server/src/matcher/definition.lua
+++ b/server/src/matcher/definition.lua
@@ -1,13 +1,38 @@
local findResult = require 'matcher.find_result'
+local function parseResultAcrossUri(positions, vm, result)
+ -- 跨越文件时,遍历的是值的绑定信息
+ for _, info in ipairs(result.value) do
+ if info.type == 'set' and info.source.uri == result.value.uri then
+ positions[#positions+1] = {
+ info.source.start,
+ info.source.finish,
+ info.source.uri,
+ }
+ end
+ end
+ if #positions == 0 then
+ for _, info in ipairs(result.value) do
+ if info.type == 'return' and info.source.uri == result.value.uri then
+ positions[#positions+1] = {
+ info.source.start,
+ info.source.finish,
+ info.source.uri,
+ }
+ end
+ end
+ end
+end
+
local function parseResult(vm, result)
local positions = {}
local tp = result.type
if tp == 'local' then
if result.value.uri ~= vm.uri then
- -- 跨越文件时,遍历的是值的绑定信息
- for _, info in ipairs(result.value) do
- if info.type == 'set'then
+ parseResultAcrossUri(positions, vm, result)
+ else
+ for _, info in ipairs(result) do
+ if info.type == 'local' then
positions[#positions+1] = {
info.source.start,
info.source.finish,
@@ -15,20 +40,13 @@ local function parseResult(vm, result)
}
end
end
- if #positions == 0 then
- for _, info in ipairs(result.value) do
- if info.type == 'return'then
- positions[#positions+1] = {
- info.source.start,
- info.source.finish,
- info.source.uri,
- }
- end
- end
- end
+ end
+ elseif tp == 'field' then
+ if result.value.uri ~= vm.uri then
+ parseResultAcrossUri(positions, vm, result)
else
for _, info in ipairs(result) do
- if info.type == 'local' then
+ if info.type == 'set' then
positions[#positions+1] = {
info.source.start,
info.source.finish,
@@ -37,16 +55,6 @@ local function parseResult(vm, result)
end
end
end
- elseif tp == 'field' then
- for _, info in ipairs(result) do
- if info.type == 'set' then
- positions[#positions+1] = {
- info.source.start,
- info.source.finish,
- info.source.uri,
- }
- end
- end
elseif tp == 'label' then
for _, info in ipairs(result) do
if info.type == 'set' then