diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-12-24 15:33:58 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-12-24 15:33:58 +0800 |
commit | 41d5da00933be228f5a18c2f67490b0b2a822931 (patch) | |
tree | f8c25e3f1d3418fdaf31e3110ff514f41d71b77f /script-beta/vm/eachRef.lua | |
parent | f60fffa9afd4c799c449065cbc5beba68e2bdcb1 (diff) | |
download | lua-language-server-41d5da00933be228f5a18c2f67490b0b2a822931.zip |
更新 eachRef
Diffstat (limited to 'script-beta/vm/eachRef.lua')
-rw-r--r-- | script-beta/vm/eachRef.lua | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index fe38924e..04a2cf6c 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -43,17 +43,26 @@ local function ofGlobal(source, callback) end end +local function ofTableField(source, callback) + local tbl = source.parent + local src = tbl.parent + if not src then + return + end + local key = guide.getKeyName(source) + vm.eachField(src, function (src) + if key == guide.getKeyName(src) then + callback(src) + end + end) +end + local function ofField(source, callback) local parent = source.parent local key = guide.getKeyName(source) if parent.type == 'tablefield' or parent.type == 'tableindex' then - local tbl = parent.parent - vm.eachField(tbl, function (src) - if key == guide.getKeyName(src) then - callback(src) - end - end) + ofTableField(parent, callback) else local node = parent.node vm.eachField(node, function (src) @@ -69,10 +78,11 @@ local function ofLiteral(source, callback) if not parent then return end - if parent.type == 'setindex' - or parent.type == 'getindex' - or parent.type == 'tableindex' then + if parent.type == 'setindex' + or parent.type == 'getindex' then ofField(source, callback) + elseif parent.type == 'tableindex' then + ofTableField(parent, callback) end end @@ -93,15 +103,6 @@ local function ofGoTo(source, callback) end end -local function ofTableField(source, callback) - local tbl = source.parent - local src = tbl.parent - if not src then - return - end - return vm.eachField(src, callback) -end - local function findIndex(parent, source) for i = 1, #parent do if parent[i] == source then |