summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/core/implementation.lua33
1 files changed, 16 insertions, 17 deletions
diff --git a/server/src/core/implementation.lua b/server/src/core/implementation.lua
index 6879c9b9..8e42556a 100644
--- a/server/src/core/implementation.lua
+++ b/server/src/core/implementation.lua
@@ -1,7 +1,8 @@
-local function findFieldBySource(positions, source, obj, result)
+local function findFieldBySource(positions, source, vm, result)
if source.type == 'name' and source[1] == result.key then
+ local obj = source.bind
if obj.type == 'field' then
- for _, info in ipairs(obj) do
+ vm:eachInfo(obj, function (info)
if info.type == 'set' and info.source == source then
positions[#positions+1] = {
source.start,
@@ -9,23 +10,18 @@ local function findFieldBySource(positions, source, obj, result)
source.uri,
}
end
- end
+ end)
end
end
end
local function findFieldByName(positions, vm, result)
- for source, obj in pairs(vm.results.sources) do
- if source.type == 'multi-source' then
- for i = 1, #obj do
- findFieldBySource(positions, source, obj[i], result)
- end
- else
- findFieldBySource(positions, source, obj, result)
- end
+ for _, source in pairs(vm.results.sources) do
+ findFieldBySource(positions, source, vm, result)
end
end
+
local function parseResultAcrossUri(positions, vm, result)
-- 跨越文件时,遍历的是值的绑定信息
result.value:eachInfo(function (info)
@@ -76,13 +72,16 @@ local function parseResultAsVar(vm, result, lsp)
local positions = {}
local tp = result.type
if tp == 'local' then
+ if result.link then
+ result = result.link
+ end
if result.value.lib then
return positions
end
if result.value.uri ~= vm.uri then
parseResultAcrossUri(positions, vm, result)
else
- for _, info in ipairs(result) do
+ vm:eachInfo(result, function (info)
if info.type == 'set' then
positions[#positions+1] = {
info.source.start,
@@ -90,7 +89,7 @@ local function parseResultAsVar(vm, result, lsp)
info.source.uri,
}
end
- end
+ end)
end
elseif tp == 'field' then
if result.value.lib then
@@ -99,7 +98,7 @@ local function parseResultAsVar(vm, result, lsp)
if result.value.uri ~= vm.uri then
parseResultAcrossUri(positions, vm, result)
else
- for _, info in ipairs(result) do
+ vm:eachInfo(result, function (info)
if info.type == 'set' then
positions[#positions+1] = {
info.source.start,
@@ -107,21 +106,21 @@ local function parseResultAsVar(vm, result, lsp)
info.source.uri,
}
end
- end
+ end)
if #positions == 0 then
findFieldByName(positions, vm, result)
findFieldCrossUriByName(positions, vm, result, lsp)
end
end
elseif tp == 'label' then
- for _, info in ipairs(result) do
+ vm:eachInfo(result, function (info)
if info.type == 'set' then
positions[#positions+1] = {
info.source.start,
info.source.finish,
}
end
- end
+ end)
end
return positions
end