summaryrefslogtreecommitdiff
path: root/script-beta/core/hover/table.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-18 20:14:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-18 20:14:37 +0800
commit9f5bd0f4e506797da27b1e9769323f42d04f715b (patch)
tree8919e7dac40106019470588676f5e3b606f37b2e /script-beta/core/hover/table.lua
parent4be6c0b2a1c50152d63434792a5c0615beb40a8b (diff)
downloadlua-language-server-9f5bd0f4e506797da27b1e9769323f42d04f715b.zip
尽量去掉table里的any
Diffstat (limited to 'script-beta/core/hover/table.lua')
-rw-r--r--script-beta/core/hover/table.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua
index 69cb84d3..be980092 100644
--- a/script-beta/core/hover/table.lua
+++ b/script-beta/core/hover/table.lua
@@ -113,6 +113,7 @@ end
return function (source)
local literals = {}
local classes = {}
+ local knownClasses = {}
vm.eachField(source, function (src)
local key, class, literal = getField(src)
if not key then
@@ -130,9 +131,18 @@ return function (source)
for key, class in pairs(classes) do
classes[key] = guide.mergeTypes(class)
literals[key] = mergeLiteral(literals[key])
+ if key ~= '[any]' then
+ for i = 1, #class do
+ knownClasses[#knownClasses+1] = class[i]
+ end
+ end
end
- if classes['[any]'] == 'any' then
- classes['[any]'] = nil
+ if classes['[any]'] then
+ if classes['[any]'] == 'any' then
+ classes['[any]'] = nil
+ elseif classes['[any]'] == guide.mergeTypes(knownClasses) then
+ classes['[any]'] = nil
+ end
end
if not next(classes) then
return '{}'