diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-12-24 14:42:16 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-12-24 14:42:16 +0800 |
commit | f60fffa9afd4c799c449065cbc5beba68e2bdcb1 (patch) | |
tree | 90218eee67448fed9834983b8cb1a094c40e46cc /script-beta/core/definition.lua | |
parent | e3874a12dd5a3273f0d2266134c8764182fc42e3 (diff) | |
download | lua-language-server-f60fffa9afd4c799c449065cbc5beba68e2bdcb1.zip |
分离 eachRef 与 eachDef
Diffstat (limited to 'script-beta/core/definition.lua')
-rw-r--r-- | script-beta/core/definition.lua | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/script-beta/core/definition.lua b/script-beta/core/definition.lua index 8afdc2ba..ded2fb1c 100644 --- a/script-beta/core/definition.lua +++ b/script-beta/core/definition.lua @@ -17,37 +17,22 @@ local function findDef(source, callback) and source.type ~= 'goto' then return end - vm.eachDef(source, function (info) - if info.source.library then - return - end - if info.mode == 'declare' - or info.mode == 'set' then - local src = info.source - local root = guide.getRoot(src) - local uri = root.uri - if src.type == 'setfield' - or src.type == 'getfield' - or src.type == 'tablefield' then - callback(src.field, uri) - elseif src.type == 'setindex' - or src.type == 'getindex' - or src.type == 'tableindex' then - callback(src.index, uri) - elseif src.type == 'getmethod' - or src.type == 'setmethod' then - callback(src.method, uri) - else - callback(src, uri) - end - end - if info.mode == 'value' then - local src = info.source - local root = guide.getRoot(src) - local uri = root.uri - if src.parent.type == 'return' then - callback(src, uri) - end + vm.eachDef(source, function (src) + local root = guide.getRoot(src) + local uri = root.uri + if src.type == 'setfield' + or src.type == 'getfield' + or src.type == 'tablefield' then + callback(src.field, uri) + elseif src.type == 'setindex' + or src.type == 'getindex' + or src.type == 'tableindex' then + callback(src.index, uri) + elseif src.type == 'getmethod' + or src.type == 'setmethod' then + callback(src.method, uri) + else + callback(src, uri) end end) end |