diff options
Diffstat (limited to 'server/src/core/references.lua')
-rw-r--r-- | server/src/core/references.lua | 40 |
1 files changed, 33 insertions, 7 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 |