summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-07 17:26:50 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-07 17:26:50 +0800
commit8bca250c629afe7cf99ade2042288b9f2cdde722 (patch)
tree9bf9b2db9927b950de66f51c3361bf7f34495010 /server
parentf3260ceb043848c26dd7ef45d0a5210ea6d4a5ba (diff)
downloadlua-language-server-8bca250c629afe7cf99ade2042288b9f2cdde722.zip
支持常亮oo
Diffstat (limited to 'server')
-rw-r--r--server/src/matcher/compile.lua39
-rw-r--r--server/test/find_lib/init.lua13
2 files changed, 34 insertions, 18 deletions
diff --git a/server/src/matcher/compile.lua b/server/src/matcher/compile.lua
index 434a0999..65755821 100644
--- a/server/src/matcher/compile.lua
+++ b/server/src/matcher/compile.lua
@@ -194,6 +194,9 @@ function mt:searchSimple(simple)
if name.type == 'name' then
var = self:getVar(name[1], name)
end
+ if name.type == 'string' then
+ var = self:getString(name)
+ end
self:searchExp(simple[1])
for i = 2, #simple do
local obj = simple[i]
@@ -209,14 +212,12 @@ function mt:searchSimple(simple)
var = self:getField(var, obj[1], obj)
self:addInfo(var, 'get', obj)
end
+ elseif obj.index and (obj.type == 'string' or obj.type == 'number' or obj.type == 'boolean') then
+ var = self:getField(var, obj[1], obj)
+ self:addInfo(var, 'get', obj)
else
- if obj.index and (obj.type == 'string' or obj.type == 'number' or obj.type == 'boolean') then
- var = self:getField(var, obj[1], obj)
- self:addInfo(var, 'get', obj)
- else
- self:searchExp(obj)
- var = nil
- end
+ self:searchExp(obj)
+ var = nil
end
end
return var
@@ -254,6 +255,7 @@ function mt:getString(exp)
return {
type = 'string',
string = exp[1],
+ childs = {},
}
end
@@ -315,6 +317,9 @@ function mt:markSimple(simple)
if name.type == 'name' then
var = self:getVar(name[1], name)
end
+ if name.type == 'string' then
+ var = self:getString(name)
+ end
self:searchExp(simple[1])
for i = 2, #simple do
local obj = simple[i]
@@ -337,19 +342,17 @@ function mt:markSimple(simple)
self:addInfo(var, 'get', obj)
end
end
- else
- if obj.index and (obj.type == 'string' or obj.type == 'number' or obj.type == 'boolean') then
- 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
+ elseif obj.index and (obj.type == 'string' or obj.type == 'number' or obj.type == 'boolean') then
+ if i == #simple then
+ var = self:addField(var, obj[1], obj)
+ self:addInfo(var, 'set', obj)
else
- self:searchExp(obj)
- var = nil
+ var = self:getField(var, obj[1], obj)
+ self:addInfo(var, 'get', obj)
end
+ else
+ self:searchExp(obj)
+ var = nil
end
end
return var
diff --git a/server/test/find_lib/init.lua b/server/test/find_lib/init.lua
index 910167c8..06e04912 100644
--- a/server/test/find_lib/init.lua
+++ b/server/test/find_lib/init.lua
@@ -81,5 +81,18 @@ require 'table'.<?insert?>()
TEST '*string:sub' [[
local str = 'xxx'
+str.<?sub?> = 1
+]]
+
+TEST '*string:sub' [[
+local str = 'xxx'
str:<?sub?>(1, 1)
]]
+
+TEST '*string:sub' [[
+('xxx').<?sub?> = 1
+]]
+
+TEST '*string:sub' [[
+('xxx'):<?sub?>()
+]]