diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-30 13:43:48 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-30 13:43:48 +0800 |
commit | b14edd27b790ea984276f40202e5ba4acba652ba (patch) | |
tree | 27d643011a5ed4907d76e848c4e78fe36604d65e /server/src/core | |
parent | 3b6db7fa2512f2af92abc758cbf79844ad9f0301 (diff) | |
download | lua-language-server-b14edd27b790ea984276f40202e5ba4acba652ba.zip |
简单支持查找引用
Diffstat (limited to 'server/src/core')
-rw-r--r-- | server/src/core/references.lua | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/server/src/core/references.lua b/server/src/core/references.lua index f49ebbfc..7262ca91 100644 --- a/server/src/core/references.lua +++ b/server/src/core/references.lua @@ -1,26 +1,32 @@ local findResult = require 'core.find_result' -local function parseResult(result, declarat) +local function parseResult(vm, result, declarat) local positions = {} local tp = result.type if tp == 'local' then - for _, info in ipairs(result) do + vm:eachInfo(result, 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} + positions[#positions+1] = {info.source.start, info.source.finish, info.source.uri} end - end + end) elseif tp == 'field' then - for _, info in ipairs(result) do + vm:eachInfo(result, 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} + positions[#positions+1] = {info.source.start, info.source.finish, info.source.uri} end - end + end) elseif tp == 'label' then - for _, info in ipairs(result) do + vm:eachInfo(result, function (info) if declarat or info.type == 'goto' then - positions[#positions+1] = {info.source.start, info.source.finish} + positions[#positions+1] = {info.source.start, info.source.finish, info.source.uri} end - end + end) end return positions end @@ -30,6 +36,6 @@ return function (vm, pos, declarat) if not result then return nil end - local positions = parseResult(result, declarat) + local positions = parseResult(vm, result, declarat) return positions end |