diff options
Diffstat (limited to 'server-beta')
-rw-r--r-- | server-beta/src/core/engineer.lua | 23 | ||||
-rw-r--r-- | server-beta/src/parser/ast.lua | 18 | ||||
-rw-r--r-- | server-beta/src/parser/guide.lua | 8 | ||||
-rw-r--r-- | server-beta/test/definition/table.lua | 21 |
4 files changed, 62 insertions, 8 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua index 0f0bff95..5fc92e7e 100644 --- a/server-beta/src/core/engineer.lua +++ b/server-beta/src/core/engineer.lua @@ -59,9 +59,14 @@ mt['local'] = function (self, source, mode, callback) or tp == 'getindex' then callback(parent) end + elseif ref.type == 'setlocal' then + self:eachRef(ref.value, 'field', callback) end end end + if source.value then + self:eachRef(source.value, 'field', callback) + end end end mt['getlocal'] = function (self, source, mode, callback) @@ -142,8 +147,13 @@ mt['field'] = function (self, source, mode, callback) self:eachRef(node, 'field', function (src) if key == guide.getKeyName(src) then if mode == 'def' then - if src.type == 'setfield' then + if src.type == 'setfield' + or src.type == 'tablefield' + then callback(src.field, 'set') + elseif src.type == 'setindex' + or src.type == 'tableindex' then + callback(src.index, 'set') end end end @@ -189,6 +199,17 @@ mt['boolean'] = mt['asindex'] mt['string'] = function (self, source, mode, callback) mt['asindex'](self, source, mode, callback) end +mt['table'] = function (self, source, mode, callback) + if mode == 'field' then + for i = 1, #source do + local src = source[i] + if src.type == 'tablefield' + or src.type == 'tableindex' then + callback(src) + end + end + end +end function mt:getSpecial(source) local node = source.node diff --git a/server-beta/src/parser/ast.lua b/server-beta/src/parser/ast.lua index 4297ab42..ae8f9a7a 100644 --- a/server-beta/src/parser/ast.lua +++ b/server-beta/src/parser/ast.lua @@ -578,7 +578,9 @@ local Defs = { finish = finish - 1, index = index, } - index.parent = obj + if index then + index.parent = obj + end return obj end, GetMethod = function (colon, method) @@ -911,8 +913,10 @@ local Defs = { field = field, value = value, } - field.type = 'field' - field.parent = obj + if field then + field.type = 'field' + field.parent = obj + end return obj end, Index = function (start, index, finish) @@ -922,7 +926,9 @@ local Defs = { finish = finish - 1, index = index, } - index.parent = obj + if index then + index.parent = obj + end return obj end, NewIndex = function (start, index, value, finish) @@ -933,7 +939,9 @@ local Defs = { index = index, value = value, } - index.parent = obj + if index then + index.parent = obj + end return obj end, FuncArgs = function (start, args, finish) diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua index a89af6b4..428f3b8d 100644 --- a/server-beta/src/parser/guide.lua +++ b/server-beta/src/parser/guide.lua @@ -365,13 +365,17 @@ function m.getKeyName(obj) or tp == 'setglobal' then return 's|' .. obj[1] elseif tp == 'getfield' - or tp == 'setfield' then + or tp == 'setfield' + or tp == 'tablefield' then return 's|' .. obj.field[1] elseif tp == 'getindex' - or tp == 'setindex' then + or tp == 'setindex' + or tp == 'tableindex' then return m.getKeyName(obj.index) elseif tp == 'field' then return 's|' .. obj[1] + elseif tp == 'index' then + return m.getKeyName(obj.index) elseif tp == 'string' then local s = obj[1] if s then diff --git a/server-beta/test/definition/table.lua b/server-beta/test/definition/table.lua index 90e7926f..f4a2f630 100644 --- a/server-beta/test/definition/table.lua +++ b/server-beta/test/definition/table.lua @@ -96,6 +96,27 @@ local t = { t.<?insert?>() ]] +TEST[[ +local t = { + <!['insert']!> = 1, +} +t.<?insert?>() +]] + +TEST[[ +local t;t = { + <!insert!> = 1, +} +t.<?insert?>() +]] + +TEST[[ +local t;t = { + <!insert!> = 1, +} +t.<?insert?>() +]] + --TEST[[ --local t = { -- <!insert!> = 1, |