summaryrefslogtreecommitdiff
path: root/script-beta/vm/eachDef.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-24 17:27:11 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-24 17:27:11 +0800
commit16f26d627f29912421da68280e14df967c6c670e (patch)
treec9e6b873a1c5915c9da08724d7ff28a79f016a1e /script-beta/vm/eachDef.lua
parent41d5da00933be228f5a18c2f67490b0b2a822931 (diff)
downloadlua-language-server-16f26d627f29912421da68280e14df967c6c670e.zip
暂存
Diffstat (limited to 'script-beta/vm/eachDef.lua')
-rw-r--r--script-beta/vm/eachDef.lua24
1 files changed, 8 insertions, 16 deletions
diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua
index 45da2fc6..96001d97 100644
--- a/script-beta/vm/eachDef.lua
+++ b/script-beta/vm/eachDef.lua
@@ -62,18 +62,16 @@ local function ofGlobal(source, callback)
end
end
+local function ofTableField(source, callback)
+ callback(source)
+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 vm.isSet(src)
- and key == guide.getKeyName(src) then
- callback(src)
- end
- end)
+ ofTableField(parent, callback)
else
local node = parent.node
vm.eachField(node, function (src)
@@ -82,6 +80,9 @@ local function ofField(source, callback)
callback(src)
end
end)
+ vm.eachRef(node, function (src)
+ vm.eachFieldInTable(src.value, callback)
+ end)
end
end
@@ -116,15 +117,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