summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-28 11:31:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-28 11:31:13 +0800
commit0007a89a9c9bb153c2475b85b11664761264566f (patch)
tree10f4eec41c202d446fc7663b636a3f2dab3ae06c /server/src
parent8d63f26209a4e241bb30551d81ceb4ca246b228a (diff)
downloadlua-language-server-0007a89a9c9bb153c2475b85b11664761264566f.zip
实例化index
Diffstat (limited to 'server/src')
-rw-r--r--server/src/matcher/vm.lua15
-rw-r--r--server/src/parser/ast.lua10
-rw-r--r--server/src/parser/grammar.lua2
3 files changed, 15 insertions, 12 deletions
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