diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | server/src/matcher/vm.lua | 15 | ||||
-rw-r--r-- | server/src/parser/ast.lua | 10 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 2 | ||||
-rw-r--r-- | server/test/definition/table.lua | 8 |
5 files changed, 20 insertions, 16 deletions
@@ -19,6 +19,7 @@ - [ ] Multi Workspace - [ ] Type Format - [ ] Accurate Type Inference +- [ ] Document Symbols ### Locale diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 3d3fc4e5..6bd7e7c3 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -995,23 +995,22 @@ function mt:getSimple(simple, mode) func = func, } parentName = parentName .. '(...)' - elseif obj.index then - local index = self:getIndex(obj) - field = self:getField(value, index, obj) + elseif tp == 'index' then + local child = obj[1] + local index = self:getIndex(child) + field = self:getField(value, index, child) field.parentValue = value value = self:getValue(field) if mode == 'value' or i < #simple then - if obj.start then - self:addInfo(field, 'get', obj) - end + self:addInfo(field, 'get', obj) end field.parent = lastField lastField = field obj.object = object obj.parentName = parentName - if obj.type == 'string' then + if obj[1].type == 'string' then parentName = ('%s[%q]'):format(parentName, index) - elseif obj.type == 'number' or obj.type == 'boolean' then + elseif obj[1].type == 'number' or obj[1].type == 'boolean' then parentName = ('%s[%s]'):format(parentName, index) else parentName = ('%s[?]'):format(parentName) diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 4521ffd5..8c4e1a1c 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -93,9 +93,13 @@ local defs = { return first end end, - Index = function (exp) - exp.index = true - return exp + Index = function (start, exp, finish) + return { + type = 'index', + start = start, + finish = finish - 1, + [1] = exp, + } end, Call = function (start, arg, finish) if arg == nil then diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index d21f07b9..ce7e4794 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -264,7 +264,7 @@ Suffix <- DOT MustName / COLON MustName / Sp ({} Table {}) -> Call / Sp ({} String {}) -> Call - / BL DirtyExp -> Index BR? + / Sp ({} BL DirtyExp (BR / Sp) {}) -> Index / Sp ({} PL ExpList (PR / Sp) {}) -> Call DirtyExp <- Exp / DirtyName diff --git a/server/test/definition/table.lua b/server/test/definition/table.lua index b4585d16..6376d7f2 100644 --- a/server/test/definition/table.lua +++ b/server/test/definition/table.lua @@ -35,25 +35,25 @@ t.<?x?>() TEST [[ local t -t[<!1!>] = 1 +t<![1]!> = 1 t[<?1?>]() ]] TEST [[ local t -t[<!true!>] = 1 +t<![true]!> = 1 t[<?true?>]() ]] TEST [[ local t -t[<!"method"!>] = 1 +t<!["method"]!> = 1 t[<?"method"?>]() ]] TEST [[ local t -t[<!"longString"!>] = 1 +t<!["longString"]!> = 1 t[<?[==[longString]==]?>]() ]] |