diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-18 17:42:53 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-18 17:42:53 +0800 |
commit | 3a62f5fd81e5857e558057a2871e068320d796f0 (patch) | |
tree | e660d603bc2726773452db81b11b22e7285cc84b /server-beta/src/core/getfield.lua | |
parent | b127f95a82fdbcb41447f8f4067c80b6723587e1 (diff) | |
download | lua-language-server-3a62f5fd81e5857e558057a2871e068320d796f0.zip |
整理代码
Diffstat (limited to 'server-beta/src/core/getfield.lua')
-rw-r--r-- | server-beta/src/core/getfield.lua | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/server-beta/src/core/getfield.lua b/server-beta/src/core/getfield.lua index 4cc5d3f8..aa07719b 100644 --- a/server-beta/src/core/getfield.lua +++ b/server-beta/src/core/getfield.lua @@ -19,38 +19,29 @@ function m:field(source, key, callback) self:eachRef(source, function (src) used[src] = true - if src.type == 'getfield' then - if guide.getKeyName(src.field) == key then - callback(src.field, 'get') + local child, mode = self:childMode(src) + if child then + if key == guide.getKeyName(child) then + callback(child, mode) end - elseif src.type == 'setfield' then - if guide.getKeyName(src.field) == key then - callback(src.field, 'set') - end - elseif src.type == 'getmethod' then - if guide.getKeyName(src.method) == key then - callback(src.method, 'get') - end - elseif src.type == 'setmethod' then - if guide.getKeyName(src.method) == key then - callback(src.method, 'set') - end - elseif src.type == 'getindex' then - if guide.getKeyName(src.index) == key then - callback(src.index, 'get') - end - elseif src.type == 'setindex' then - if guide.getKeyName(src.index) == key then - callback(src.index, 'set') - end - elseif src.type == 'getglobal' then - if guide.getKeyName(src.parent) == key then - callback(src.parent, 'get') + return + end + if src.type == 'getglobal' then + local parent = src.parent + child, mode = self:childMode(parent) + if child then + if key == guide.getKeyName(child) then + callback(child, mode) + end end elseif src.type == 'setglobal' then - --if guide.getKeyName(src.parent) == key then - -- callback(src.parent, 'set') - --end + local parent = src.parent + child, mode = self:childMode(parent) + if child then + if key == guide.getKeyName(child) then + callback(child, mode) + end + end else self:eachField(src, key, callback) end |