diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-12-05 17:20:53 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-12-05 17:20:53 +0800 |
commit | 51185264ab76b43571689dd717b3e685d4ff9c73 (patch) | |
tree | 1fe952e64d6bdef81f280eafdfbe3d27e022ca5c /script-beta/vm | |
parent | 96e499f4c62d7e444c74a4afebfd02211f3f9c16 (diff) | |
download | lua-language-server-51185264ab76b43571689dd717b3e685d4ff9c73.zip |
更新hover
Diffstat (limited to 'script-beta/vm')
-rw-r--r-- | script-beta/vm/getValue.lua | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/script-beta/vm/getValue.lua b/script-beta/vm/getValue.lua index 67954360..f4b1ff68 100644 --- a/script-beta/vm/getValue.lua +++ b/script-beta/vm/getValue.lua @@ -868,21 +868,7 @@ function vm.hasType(source, type) return false end -function vm.viewType(values) - if not values then - return 'any' - end - if type(values) ~= 'table' then - return values or 'any' - end - local types = {} - for i = 1, #values do - local tp = values[i].type - if not types[tp] then - types[tp] = true - types[#types+1] = tp - end - end +local function viewTypes(types) if #types == 0 then return 'any' end @@ -909,6 +895,37 @@ function vm.viewType(values) return table.concat(types, '|') end +function vm.viewType(values) + if not values then + return 'any' + end + if type(values) ~= 'table' then + return values or 'any' + end + local types = {} + for i = 1, #values do + local tp = values[i].type + if not types[tp] and tp ~= 'any' then + types[tp] = true + types[#types+1] = tp + end + end + return viewTypes(types) +end + +function vm.mergeTypeViews(...) + local types = {} + for _, view in ipairs {...} do + for tp in view:gmatch '[^|]+' do + if not types[tp] and tp ~= 'any' then + types[tp] = true + types[#types+1] = tp + end + end + end + return viewTypes(types) +end + function vm.getType(source) local values = vm.getValue(source) return vm.viewType(values) |