diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-08-16 19:34:38 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-08-16 19:34:38 +0800 |
commit | 85f2cf816e5b3e2d439731e48129678a32b70d60 (patch) | |
tree | 12b8659be0c00577f97a0265fe041afdf2a5dfd4 /script-beta | |
parent | 13ebfd293897200bda9cb1840fef6cb03a9c6d43 (diff) | |
download | lua-language-server-85f2cf816e5b3e2d439731e48129678a32b70d60.zip |
暂存
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/hover/label.lua | 12 | ||||
-rw-r--r-- | script-beta/parser/guide.lua | 14 |
2 files changed, 16 insertions, 10 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua index c3607415..cc2cdd09 100644 --- a/script-beta/core/hover/label.lua +++ b/script-beta/core/hover/label.lua @@ -22,9 +22,9 @@ local function asValue(source, title) local type = 'any' local literal = '' local cont - local values = vm.getInfers(source) - if values then - for _, value in ipairs(values) do + local infers = vm.getInfers(source) + if infers then + for _, value in ipairs(infers) do local src = value.source local tp = value.type class = guide.mergeTypes {class, vm.getClass(src)} @@ -54,10 +54,12 @@ local function asValue(source, title) pack[#pack+1] = name .. ':' if cont then type = nil + end + if class == 'any' then + pack[#pack+1] = type else - type = type or 'any' + pack[#pack+1] = class end - pack[#pack+1] = class or type if literal ~= '' then pack[#pack+1] = '=' pack[#pack+1] = literal diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 863d828e..835e62ba 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -1846,16 +1846,15 @@ function m.allocInfer(o) -- TODO assert(o.type) if type(o.type) == 'table' then - local values = {} + local infers = {} for i = 1, #o.type do - local sub = { + infers[i] = { type = o.type[i], value = o.value, source = o.source, } - values[i] = sub end - return values + return infers else return { [1] = o, @@ -1865,9 +1864,11 @@ end function m.mergeTypes(infers) local types = {} + local mark = {} for i = 1, #infers do for tp in infers[i]:gmatch '[^|]+' do - if not types[tp] and tp ~= 'any' then + if not mark[tp] and tp ~= 'any' then + mark[tp] = true types[#types+1] = tp end end @@ -2733,6 +2734,9 @@ function m.cleanInfers(infers) local mark = {} for i = 1, #infers do local infer = infers[i] + if not infer then + return + end local key = ('%s|%p'):format(infer.type, infer.source) if mark[key] then infers[i] = infers[#infers] |