diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-25 17:07:26 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-25 17:07:26 +0800 |
commit | 1fdf8d070c67ea572316515aa36708b7967b83f9 (patch) | |
tree | e7026b1485495ccb2ca83deee368c897a8266053 /script/core | |
parent | 2d6a3b6875fe50854b3f8cdf5dd13bd2b342e3e8 (diff) | |
download | lua-language-server-1fdf8d070c67ea572316515aa36708b7967b83f9.zip |
update
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/infer.lua | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/script/core/infer.lua b/script/core/infer.lua index 528ef51a..425992fc 100644 --- a/script/core/infer.lua +++ b/script/core/infer.lua @@ -1,8 +1,7 @@ local searcher = require 'core.searcher' local config = require 'config' local noder = require 'core.noder' -local vm = require "vm.vm" -local guide = require "parser.guide" +local util = require 'utility' local STRING_OR_TABLE = {'STRING_OR_TABLE'} local BE_RETURN = {'BE_RETURN'} @@ -170,8 +169,26 @@ local function searchLiteralOfValue(value, literals) if value.type == 'unary' then local op = value.op.type if op == '-' then + local subLiterals = m.searchLiterals(value[1]) + if subLiterals then + for subLiteral in pairs(subLiterals) do + local num = tonumber(subLiteral) + if num then + literals[-num] = true + end + end + end end if op == '~' then + local subLiterals = m.searchLiterals(value[1]) + if subLiterals then + for subLiteral in pairs(subLiterals) do + local num = math.tointeger(subLiteral) + if num then + literals[~num] = true + end + end + end end end return @@ -280,21 +297,18 @@ end ---@param literals string[] ---@return string function m.viewLiterals(literals) - if literals[0] then - return literals[0] - end local result = {} local count = 0 for infer in pairs(literals) do count = count + 1 - result[count] = infer + result[count] = util.viewLiteral(infer) end if count == 0 then return nil end table.sort(result) - literals[0] = table.concat(result, '|') - return literals[0] + local view = table.concat(result, '|') + return view end local function getDocName(doc) |