diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-11 11:16:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-11 11:16:22 +0800 |
commit | a54939cb662f8730a011cababf37b634e6344300 (patch) | |
tree | 318e1434fa9a99863e7bb19f2ba1d33a313e86bd /server-beta/src/core/field.lua | |
parent | 976e63df5340def77c363935f383da315ee5b5ab (diff) | |
download | lua-language-server-a54939cb662f8730a011cababf37b634e6344300.zip |
支持反找__index
Diffstat (limited to 'server-beta/src/core/field.lua')
-rw-r--r-- | server-beta/src/core/field.lua | 38 |
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) |