summaryrefslogtreecommitdiff
path: root/server/src/matcher/implementation.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/matcher/implementation.lua')
-rw-r--r--server/src/matcher/implementation.lua51
1 files changed, 7 insertions, 44 deletions
diff --git a/server/src/matcher/implementation.lua b/server/src/matcher/implementation.lua
index e51d7a22..34b09693 100644
--- a/server/src/matcher/implementation.lua
+++ b/server/src/matcher/implementation.lua
@@ -1,54 +1,17 @@
local findResult = require 'matcher.find_result'
-local function tryMeta(var)
- local keys = {}
- repeat
- if var.childs.meta then
- local metavar = var.childs.meta
- for i = #keys, 1, -1 do
- local key = keys[i]
- metavar = metavar.childs[key]
- if not metavar then
- return nil
- end
- end
- return metavar
- end
- keys[#keys+1] = var.key
- var = var.parent
- until not var
- return nil
-end
-
local function parseResult(result)
local positions = {}
local tp = result.type
- if tp == 'var' then
- local var = result.var
- if var.type == 'local' then
- local source = var.source
- if not source then
- return false
- end
- positions[1] = {source.start, source.finish}
- end
- for _, info in ipairs(var) do
+ if tp == 'local' then
+ for _, info in ipairs(result.object) do
if info.type == 'set' then
positions[#positions+1] = {info.source.start, info.source.finish}
end
end
- local metavar = tryMeta(var)
- if metavar then
- for _, info in ipairs(metavar) do
- if info.type == 'set' then
- positions[#positions+1] = {info.source.start, info.source.finish}
- end
- end
- end
- elseif tp == 'dots' then
- local dots = result.dots
- for _, info in ipairs(dots) do
- if info.type == 'local' then
+ elseif tp == 'field' then
+ for _, info in ipairs(result.object) do
+ if info.type == 'set' then
positions[#positions+1] = {info.source.start, info.source.finish}
end
end
@@ -65,8 +28,8 @@ local function parseResult(result)
return positions
end
-return function (results, pos)
- local result = findResult(results, pos)
+return function (vm, pos)
+ local result = findResult(vm.results, pos)
if not result then
return nil
end