summaryrefslogtreecommitdiff
path: root/server/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/core')
-rw-r--r--server/src/core/definition.lua31
-rw-r--r--server/src/core/implementation.lua31
2 files changed, 62 insertions, 0 deletions
diff --git a/server/src/core/definition.lua b/server/src/core/definition.lua
index 3ca27b89..60038724 100644
--- a/server/src/core/definition.lua
+++ b/server/src/core/definition.lua
@@ -28,6 +28,34 @@ local function parseResultAcrossUri(positions, vm, result)
end
end
+local function findFieldBySource(positions, source, obj, result)
+ if source.type == 'name' and source[1] == result.key then
+ if obj.type == 'field' then
+ for _, info in ipairs(obj) do
+ if info.type == 'set' and info.source == source then
+ positions[#positions+1] = {
+ source.start,
+ source.finish,
+ source.uri,
+ }
+ 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
+ end
+end
+
local function parseResult(vm, result)
local positions = {}
local tp = result.type
@@ -58,6 +86,9 @@ local function parseResult(vm, result)
}
end
end
+ if #positions == 0 then
+ findFieldByName(positions, vm, result)
+ end
end
elseif tp == 'label' then
for _, info in ipairs(result) do
diff --git a/server/src/core/implementation.lua b/server/src/core/implementation.lua
index 9ff3fdca..c10cfaf9 100644
--- a/server/src/core/implementation.lua
+++ b/server/src/core/implementation.lua
@@ -28,6 +28,34 @@ local function parseResultAcrossUri(positions, vm, result)
end
end
+local function findFieldBySource(positions, source, obj, result)
+ if source.type == 'name' and source[1] == result.key then
+ if obj.type == 'field' then
+ for _, info in ipairs(obj) do
+ if info.type == 'set' and info.source == source then
+ positions[#positions+1] = {
+ source.start,
+ source.finish,
+ source.uri,
+ }
+ 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
+ end
+end
+
local function parseResult(vm, result)
local positions = {}
local tp = result.type
@@ -58,6 +86,9 @@ local function parseResult(vm, result)
}
end
end
+ if #positions == 0 then
+ findFieldByName(positions, vm, result)
+ end
end
elseif tp == 'label' then
for _, info in ipairs(result) do