summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/core/references.lua40
-rw-r--r--server/test/crossfile/completion.lua2
2 files changed, 34 insertions, 8 deletions
diff --git a/server/src/core/references.lua b/server/src/core/references.lua
index 9486dafe..05ba99a9 100644
--- a/server/src/core/references.lua
+++ b/server/src/core/references.lua
@@ -1,34 +1,48 @@
local findResult = require 'core.find_result'
-local function parseResult(vm, result, declarat)
- local positions = {}
+local function parseResult(vm, result, declarat, callback)
local tp = result.type
if tp == 'local' then
+ vm:eachInfo(result, function (info)
+ if info.source.uri == '' or not info.source.uri then
+ return
+ end
+ if declarat or info.type == 'get' then
+ callback(info.source)
+ end
+ end)
result.value:eachInfo(function (info)
if info.source.uri == '' or not info.source.uri then
return
end
if declarat or info.type == 'get' then
- positions[#positions+1] = {info.source.start, info.source.finish, info.source.uri}
+ callback(info.source)
end
end)
elseif tp == 'field' then
+ vm:eachInfo(result, function (info)
+ if info.source.uri == '' or not info.source.uri then
+ return
+ end
+ if declarat or info.type == 'get' then
+ callback(info.source)
+ end
+ end)
result.value:eachInfo(function (info)
if info.source.uri == '' or not info.source.uri then
return
end
if declarat or info.type == 'get' then
- positions[#positions+1] = {info.source.start, info.source.finish, info.source.uri}
+ callback(info.source)
end
end)
elseif tp == 'label' then
vm:eachInfo(result, function (info)
if declarat or info.type == 'goto' then
- positions[#positions+1] = {info.source.start, info.source.finish, info.source.uri}
+ callback(info.source)
end
end)
end
- return positions
end
return function (vm, pos, declarat)
@@ -36,6 +50,18 @@ return function (vm, pos, declarat)
if not result then
return nil
end
- local positions = parseResult(vm, result, declarat)
+ local positions = {}
+ local mark = {}
+ parseResult(vm, result, declarat, function (source)
+ if mark[source] then
+ return
+ end
+ mark[source] = true
+ positions[#positions+1] = {
+ source.start,
+ source.finish,
+ source.uri,
+ }
+ end)
return positions
end
diff --git a/server/test/crossfile/completion.lua b/server/test/crossfile/completion.lua
index 61908dbd..0ad6cd21 100644
--- a/server/test/crossfile/completion.lua
+++ b/server/test/crossfile/completion.lua
@@ -228,7 +228,7 @@ TEST {
}
}
-TEST {
+TEST {
{
path = 'abc.lua',
content = '',