diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/compile.lua | 18 | ||||
-rw-r--r-- | server/test/definition/method.lua | 4 | ||||
-rw-r--r-- | server/test/find_lib/init.lua | 4 | ||||
-rw-r--r-- | server/test/type_inference/init.lua | 8 |
4 files changed, 30 insertions, 4 deletions
diff --git a/server/src/matcher/compile.lua b/server/src/matcher/compile.lua index bcf2ca91..c6ccedfe 100644 --- a/server/src/matcher/compile.lua +++ b/server/src/matcher/compile.lua @@ -278,13 +278,31 @@ function mt:getString(exp) } end +function mt:getBoolean(exp) + return { + type = 'boolean', + boolean = exp[1], + valuetype = 'boolean', + } +end + +function mt:getNumber(exp) + return { + type = 'number', + number = exp[1], + valuetype = 'number', + } +end + function mt:searchExp(exp) local tp = exp.type if tp == 'nil' then elseif tp == 'string' then return self:getString(exp) elseif tp == 'boolean' then + return self:getBoolean(exp) elseif tp == 'number' then + return self:getNumber(exp) elseif tp == 'name' then return self:checkName(exp) elseif tp == 'simple' then diff --git a/server/test/definition/method.lua b/server/test/definition/method.lua index 05820e97..5e90177b 100644 --- a/server/test/definition/method.lua +++ b/server/test/definition/method.lua @@ -46,7 +46,7 @@ mt.__index = mt function mt:<!method1!>() end -local obj = setmetatable(1, mt) +local obj = setmetatable({}, mt) obj:<?method1?>() ]] @@ -55,7 +55,7 @@ local mt function mt:<!method1!>() end -local obj = setmetatable(1, { __index = mt }) +local obj = setmetatable({}, { __index = mt }) obj:<?method1?>() ]] diff --git a/server/test/find_lib/init.lua b/server/test/find_lib/init.lua index 18b88399..26dbc893 100644 --- a/server/test/find_lib/init.lua +++ b/server/test/find_lib/init.lua @@ -78,7 +78,7 @@ require 'table'.<?insert?>() TEST '*string:sub' [[ local str = 'xxx' -str.<?sub?> = 1 +str.<?sub?>() ]] TEST '*string:sub' [[ @@ -87,7 +87,7 @@ str:<?sub?>(1, 1) ]] TEST '*string:sub' [[ -('xxx').<?sub?> = 1 +('xxx').<?sub?>() ]] TEST 'bee::filesystem' [[ diff --git a/server/test/type_inference/init.lua b/server/test/type_inference/init.lua index ee47b223..913228bb 100644 --- a/server/test/type_inference/init.lua +++ b/server/test/type_inference/init.lua @@ -26,3 +26,11 @@ end TEST 'string' [[ local <?var?> = '111' ]] + +TEST 'boolean' [[ +local <?var?> = true +]] + +TEST 'number' [[ +local <?var?> = 1 +]] |