diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-08 17:34:50 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-08 17:34:50 +0800 |
commit | e8058b91113196218d13befcbc529ddc2b621a3f (patch) | |
tree | 26a15d29c2ebbebed65b66f0e7272f5fd06bc14b /server-beta | |
parent | 5c47b0112b8103ac42e37352410e518cee6b5c71 (diff) | |
download | lua-language-server-e8058b91113196218d13befcbc529ddc2b621a3f.zip |
method
Diffstat (limited to 'server-beta')
-rw-r--r-- | server-beta/src/core/engineer.lua | 44 | ||||
-rw-r--r-- | server-beta/src/parser/guide.lua | 6 |
2 files changed, 30 insertions, 20 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua index 5fc92e7e..97101235 100644 --- a/server-beta/src/core/engineer.lua +++ b/server-beta/src/core/engineer.lua @@ -55,6 +55,8 @@ mt['local'] = function (self, source, mode, callback) local tp = parent.type if tp == 'setfield' or tp == 'getfield' + or tp == 'setmethod' + or tp == 'getmethod' or tp == 'setindex' or tp == 'getindex' then callback(parent) @@ -77,7 +79,8 @@ mt['_G'] = function (self, source, mode, callback) if mode == 'def' then local parent = source.parent if parent.type == 'setfield' - or parent.type == 'setindex' then + or parent.type == 'setindex' + or parent.type == 'setmethod' then callback(parent, 'set') elseif parent.type == 'getfield' or parent.type == 'getindex' then @@ -88,10 +91,12 @@ mt['_G'] = function (self, source, mode, callback) elseif mode == 'ref' then local parent = source.parent if parent.type == 'setfield' - or parent.type == 'setindex' then + or parent.type == 'setindex' + or parent.type == 'setmethod' then callback(parent, 'set') elseif parent.type == 'getfield' - or parent.type == 'getindex' then + or parent.type == 'getindex' + or parent.type == 'getmethod' then callback(parent, 'get') elseif parent.type == 'getfield' then self:search(parent, 'special', mode, callback) @@ -133,6 +138,8 @@ mt['getglobal'] = function (self, source, mode, callback) local tp = parent.type if tp == 'setfield' or tp == 'getfield' + or tp == 'setmethod' + or tp == 'getmethod' or tp == 'setindex' or tp == 'getindex' then callback(parent) @@ -141,24 +148,33 @@ mt['getglobal'] = function (self, source, mode, callback) end end mt['setglobal'] = mt['getglobal'] -mt['field'] = function (self, source, mode, callback) - local node = source.parent.node - local key = guide.getKeyName(source) +mt['eachfield'] = function (self, node, key, mode, callback) self:eachRef(node, 'field', function (src) if key == guide.getKeyName(src) then if mode == 'def' then if src.type == 'setfield' - or src.type == 'tablefield' - then + or src.type == 'tablefield' then callback(src.field, 'set') elseif src.type == 'setindex' or src.type == 'tableindex' then callback(src.index, 'set') + elseif src.type == 'setmethod' then + callback(src.method, 'set') end end end end) end +mt['field'] = function (self, source, mode, callback) + local node = source.parent.node + local key = guide.getKeyName(source) + mt['eachfield'](self, node, key, mode, callback) +end +mt['method'] = function (self, source, mode, callback) + local node = source.parent.node + local key = guide.getKeyName(source) + mt['eachfield'](self, node, key, mode, callback) +end mt['special'] = function (self, source, mode, callback) local name = self:getSpecial(source) if not name then @@ -182,17 +198,7 @@ mt['asindex'] = function (self, source, mode, callback) end local node = parent.node local key = guide.getKeyName(source) - self:eachRef(node, 'field', function (src) - if key == guide.getKeyName(src) then - if mode == 'def' then - if src.type == 'setfield' then - callback(src.field, 'set') - elseif src.type == 'setindex' then - callback(src.index, 'set') - end - end - end - end) + mt['eachfield'](self, node, key, mode, callback) end mt['number'] = mt['asindex'] mt['boolean'] = mt['asindex'] diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua index 428f3b8d..2120fe48 100644 --- a/server-beta/src/parser/guide.lua +++ b/server-beta/src/parser/guide.lua @@ -368,11 +368,15 @@ function m.getKeyName(obj) or tp == 'setfield' or tp == 'tablefield' then return 's|' .. obj.field[1] + elseif tp == 'getmethod' + or tp == 'setmethod' then + return 's|' .. obj.method[1] elseif tp == 'getindex' or tp == 'setindex' or tp == 'tableindex' then return m.getKeyName(obj.index) - elseif tp == 'field' then + elseif tp == 'field' + or tp == 'method' then return 's|' .. obj[1] elseif tp == 'index' then return m.getKeyName(obj.index) |