diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-30 16:50:45 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-30 16:50:45 +0800 |
commit | cc2a431932e77236606d184c704f0ae49462d8d2 (patch) | |
tree | 586dc4b4472ec119e89edf1f0e1e2af270d1ae73 /server/src | |
parent | a2068e31eef72137a89dea5d701fa8447cb20ab7 (diff) | |
download | lua-language-server-cc2a431932e77236606d184c704f0ae49462d8d2.zip |
查找所有引用也需要参考field
Diffstat (limited to 'server/src')
-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 |