summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-21 18:32:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-21 18:32:56 +0800
commit8de0c9246ada8f823f6abb1edde38c5768af19fa (patch)
treeb618420a970839dba69f0385d4695f97e0913387
parent320680b3529d2d4be84c13ac5ca6d728c6c5621c (diff)
downloadlua-language-server-8de0c9246ada8f823f6abb1edde38c5768af19fa.zip
用一个专用函数实现,以免影响别人
-rw-r--r--server/src/matcher/vm.lua14
-rw-r--r--server/test/diagnostics/init.lua4
2 files changed, 16 insertions, 2 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index e7863e47..23a74c7f 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -38,6 +38,16 @@ end
local mt = {}
mt.__index = mt
+function mt:createDummyVar(source, value)
+ local loc = {
+ type = 'local',
+ key = '',
+ source = source or DefaultSource,
+ }
+ self:setValue(loc, value, source)
+ return loc
+end
+
function mt:createLocal(key, source, value)
local loc = {
type = 'local',
@@ -784,11 +794,11 @@ function mt:getSimple(simple, mode)
parentName = field.key
elseif tp == 'string' or tp == 'number' or tp == 'nil' or tp == 'boolean' then
local v = self:createValue(tp, simple[1], simple[1][1])
- field = self:createLocal('', simple[1], v)
+ field = self:createDummyVar(simple[1], v)
parentName = '*' .. tp
else
local v = self:createValue('any', simple[1])
- field = self:createLocal('', simple[1], v)
+ field = self:createDummyVar(simple[1], v)
parentName = '?'
end
local object
diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua
index 9ea8b4bd..4fb15448 100644
--- a/server/test/diagnostics/init.lua
+++ b/server/test/diagnostics/init.lua
@@ -143,6 +143,10 @@ instanceName = 1
instance = _G[instanceName]
]]
+TEST [[
+(''):sub(1, 2)
+]]
+
-- TODO
--TEST [=[
--return [[