summaryrefslogtreecommitdiff
path: root/server-beta/src/core/field.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-10-11 11:16:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-10-11 11:16:22 +0800
commita54939cb662f8730a011cababf37b634e6344300 (patch)
tree318e1434fa9a99863e7bb19f2ba1d33a313e86bd /server-beta/src/core/field.lua
parent976e63df5340def77c363935f383da315ee5b5ab (diff)
downloadlua-language-server-a54939cb662f8730a011cababf37b634e6344300.zip
支持反找__index
Diffstat (limited to 'server-beta/src/core/field.lua')
-rw-r--r--server-beta/src/core/field.lua38
1 files changed, 24 insertions, 14 deletions
diff --git a/server-beta/src/core/field.lua b/server-beta/src/core/field.lua
index 95c9954f..997b38e3 100644
--- a/server-beta/src/core/field.lua
+++ b/server-beta/src/core/field.lua
@@ -3,23 +3,33 @@ local guide = require 'parser.guide'
local m = {}
function m:def(source, callback)
- local node = source.parent.node
- local key = guide.getKeyName(source)
- self:eachField(node, key, function (src, mode)
- if mode == 'set' then
- callback(src, mode)
- end
- end)
+ local parent = source.parent
+ if parent.type == 'setfield' or parent.type == 'getfield' then
+ local node = parent.node
+ local key = guide.getKeyName(source)
+ self:eachField(node, key, function (src, mode)
+ if mode == 'set' then
+ callback(src, mode)
+ end
+ end)
+ elseif parent.type == 'tablefield' then
+ self:eachDef(parent.value, callback)
+ end
end
function m:ref(source, callback)
- local node = source.parent.node
- local key = guide.getKeyName(source)
- self:eachField(node, key, function (src, mode)
- if mode == 'set' or mode == 'get' then
- callback(src, mode)
- end
- end)
+ local parent = source.parent
+ if parent.type == 'setfield' or parent.type == 'getfield' then
+ local node = parent.node
+ local key = guide.getKeyName(source)
+ self:eachField(node, key, function (src, mode)
+ if mode == 'set' or mode == 'get' then
+ callback(src, mode)
+ end
+ end)
+ elseif parent.type == 'tablefield' then
+ self:eachDef(parent.value, callback)
+ end
end
function m:value(source, callback)