summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-03 20:57:19 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-03 20:57:19 +0800
commit66c33f2ba3d6cb19434318b496b982d930a18159 (patch)
treee608bdb46d2e1a83880f4cebc356a83261d7eb18 /server
parent1a78d51e0580bfb19d07353bc7228bad37639839 (diff)
downloadlua-language-server-66c33f2ba3d6cb19434318b496b982d930a18159.zip
修正bug
Diffstat (limited to 'server')
-rw-r--r--server/src/matcher/compile.lua39
-rw-r--r--server/test/definition/bug.lua9
-rw-r--r--server/test/definition/init.lua4
3 files changed, 36 insertions, 16 deletions
diff --git a/server/src/matcher/compile.lua b/server/src/matcher/compile.lua
index 0e6bf7da..c9b847e5 100644
--- a/server/src/matcher/compile.lua
+++ b/server/src/matcher/compile.lua
@@ -153,16 +153,12 @@ function mt:searchSimple(simple)
var = nil
else
var = self:getField(var, obj[1], obj)
- if i ~= #simple then
- self:addInfo(var, 'get', obj)
- end
+ self:addInfo(var, 'get', obj)
end
else
if obj.index and (obj.type == 'string' or obj.type == 'number' or obj.type == 'boolean') then
var = self:getField(var, obj[1], obj)
- if i ~= #simple then
- self:addInfo(var, 'get', obj)
- end
+ self:addInfo(var, 'get', obj)
else
self:searchExp(obj)
var = nil
@@ -178,7 +174,7 @@ function mt:searchBinary(exp)
end
function mt:searchUnary(exp)
- return self:searchExp(exp[1])
+ self:searchExp(exp[1])
end
function mt:searchTable(exp)
@@ -247,28 +243,42 @@ end
function mt:markSimple(simple)
local name = simple[1]
- local var = self:getVar(name[1], name)
+ local var
+ if name.type == 'name' then
+ var = self:getVar(name[1], name)
+ end
+ self:searchExp(simple[1])
for i = 2, #simple do
local obj = simple[i]
local tp = obj.type
- if tp == ':' then
+ if tp == 'call' then
+ var = self:searchCall(obj, simple, i)
+ elseif tp == ':' then
var = self:createLocal('self', simple[i-1], self:getVar(simple[i-1][1]))
elseif tp == 'name' then
- if not obj.index then
- var = self:addField(var, obj[1], obj)
+ if obj.index then
+ self:checkName(obj)
+ var = nil
+ else
if i == #simple then
+ var = self:addField(var, obj[1], obj)
self:addInfo(var, 'set', obj)
+ else
+ var = self:getField(var, obj[1], obj)
+ self:addInfo(var, 'get', obj)
end
- else
- var = nil
end
else
if obj.index and (obj.type == 'string' or obj.type == 'number' or obj.type == 'boolean') then
- var = self:addField(var, obj[1], obj)
if i == #simple then
+ var = self:addField(var, obj[1], obj)
self:addInfo(var, 'set', obj)
+ else
+ var = self:getField(var, obj[1], obj)
+ self:addInfo(var, 'get', obj)
end
else
+ self:searchExp(obj)
var = nil
end
end
@@ -282,7 +292,6 @@ function mt:markSet(simple, tbl)
self:addInfo(var, 'set', simple)
self:setTable(var, tbl)
else
- self:searchSimple(simple)
local var = self:markSimple(simple)
self:setTable(var, tbl)
end
diff --git a/server/test/definition/bug.lua b/server/test/definition/bug.lua
index a6214425..0386a1d3 100644
--- a/server/test/definition/bug.lua
+++ b/server/test/definition/bug.lua
@@ -43,3 +43,12 @@ io.load(root / <?args?>.source / 'API' / path)
TEST [[
obj[#<?obj?>+1] = {}
]]
+
+TEST [[
+self = {
+ results = {
+ <!labels!> = {},
+ }
+}
+self[self.results.<?labels?>] = lbl
+]]
diff --git a/server/test/definition/init.lua b/server/test/definition/init.lua
index 435ab2f8..e5dccd4f 100644
--- a/server/test/definition/init.lua
+++ b/server/test/definition/init.lua
@@ -41,7 +41,9 @@ end
function TEST(script)
local target = catch_target(script)
- local pos = script:find('<?', 1, true) + 2
+ local start = script:find('<?', 1, true)
+ local finish = script:find('?>', 1, true)
+ local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast, err = parser:ast(new_script)
assert(ast)