diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-09-30 10:55:59 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-09-30 10:55:59 +0800 |
commit | c4eb4df1a64c595ebcba9b1f2f01d626e447c8d6 (patch) | |
tree | edf4a5d33361d989b15c9ed8884dadba0522434d /server-beta/src | |
parent | e02e98690dec2fd355a5a59af6b87cb2d94ed8b1 (diff) | |
download | lua-language-server-c4eb4df1a64c595ebcba9b1f2f01d626e447c8d6.zip |
更新field
Diffstat (limited to 'server-beta/src')
-rw-r--r-- | server-beta/src/core/engineer.lua | 11 | ||||
-rw-r--r-- | server-beta/src/parser/guide.lua | 15 |
2 files changed, 18 insertions, 8 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua index 0def3ff1..dc3fd721 100644 --- a/server-beta/src/core/engineer.lua +++ b/server-beta/src/core/engineer.lua @@ -29,12 +29,11 @@ end --- 查找所有域的引用 function mt:eachRefAsField(obj, callback) local node = obj.node - guide.eachFieldOf(node, guide.getKeyName(obj), function (value) - local tp = value.type - if tp == 'setglobal' or tp == 'setfield' then - callback(value, 'set') - elseif tp == 'getglobal' or tp == 'getfield' then - callback(value, 'get') + guide.eachRef(node, function (ref) + if ref.type == 'setglobal' or ref.type == 'setfield' then + callback(ref, 'set') + elseif ref.type == 'getglobal' or ref.type == 'getfield' then + callback(ref, 'get') end end) end diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua index fdd29be7..37dd8061 100644 --- a/server-beta/src/parser/guide.lua +++ b/server-beta/src/parser/guide.lua @@ -352,9 +352,9 @@ end --- 获取对象作为key时的名字 function m.getKeyName(obj) if obj.type == 'getglobal' or obj.type == 'setglobal' then - return 'string|' .. obj[1] + return 's|' .. obj[1] elseif obj.type == 'getfield' or obj.type == 'getglobal' then - return 'string|' .. obj[1] + return 's|' .. obj[1] end end @@ -397,4 +397,15 @@ function m.eachFieldOf(obj, field, callback) end end +--- 获取对象的所有引用 +function m.eachRef(obj, callback) + local ref = obj.ref + if not ref then + return + end + for i = 1, #ref do + callback(ref[i]) + end +end + return m |