summaryrefslogtreecommitdiff
path: root/server/src/matcher
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-20 20:02:45 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-20 20:02:45 +0800
commit0446a98c4c026fcd7101ba63a060b854b1b5753d (patch)
tree88475e89a66cfa0ae4621dcec01776e0a0f44594 /server/src/matcher
parentd0bd1eb92a2c18472d5ed0358c6fc75e06810e63 (diff)
downloadlua-language-server-0446a98c4c026fcd7101ba63a060b854b1b5753d.zip
支持跨文件了
Diffstat (limited to 'server/src/matcher')
-rw-r--r--server/src/matcher/definition.lua34
-rw-r--r--server/src/matcher/vm.lua1
2 files changed, 24 insertions, 11 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua
index 57c4be5d..2f52c9b8 100644
--- a/server/src/matcher/definition.lua
+++ b/server/src/matcher/definition.lua
@@ -5,8 +5,9 @@ local function parseResult(vm, result)
local tp = result.type
if tp == 'local' then
if result.value.uri ~= vm.uri then
- for _, info in ipairs(result) do
- if info.type == 'set' then
+ -- 跨越文件时,遍历的是值的绑定信息
+ for _, info in ipairs(result.value) do
+ if info.type == 'set'then
positions[#positions+1] = {
info.source.start,
info.source.finish,
@@ -14,16 +15,27 @@ 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
else
- for _, info in ipairs(result) do
- if info.type == 'local' then
- positions[#positions+1] = {
- info.source.start,
- info.source.finish,
- info.source.uri,
- }
- end
- end
+ for _, info in ipairs(result) do
+ if info.type == 'local' then
+ positions[#positions+1] = {
+ info.source.start,
+ info.source.finish,
+ info.source.uri,
+ }
+ end
+ end
end
elseif tp == 'field' then
for _, info in ipairs(result) do
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index 00b21ffc..ecb07bd5 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -269,6 +269,7 @@ function mt:setValue(var, value, source)
end
if source and source.start then
self:addInfo(var, 'set', source)
+ self:addInfo(value, 'set', source)
if not value.declarat then
value.declarat = source
end