diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-10-31 14:13:53 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-10-31 14:13:53 +0800 |
commit | ea065efb34ad658030335164bc6b2a4266b34347 (patch) | |
tree | 75e446fd8f32394d147e9657b9fb9d80b9b858b4 /script-beta | |
parent | 66f0bedc723d07ef6527f28fff76e7cbc46d9e2e (diff) | |
download | lua-language-server-ea065efb34ad658030335164bc6b2a4266b34347.zip |
hover支持 overload
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/hover/init.lua | 7 | ||||
-rw-r--r-- | script-beta/parser/guide.lua | 19 |
2 files changed, 17 insertions, 9 deletions
diff --git a/script-beta/core/hover/init.lua b/script-beta/core/hover/init.lua index 5e7a4072..d0873c98 100644 --- a/script-beta/core/hover/init.lua +++ b/script-beta/core/hover/init.lua @@ -8,7 +8,7 @@ local findSource = require 'core.find-source' local lang = require 'language' local function getHoverAsFunction(source) - local values = vm.getInfers(source, 'deep') + local values = vm.getDefs(source, 'deep') local desc = getDesc(source) local labels = {} local defs = 0 @@ -18,8 +18,9 @@ local function getHoverAsFunction(source) or source.type == 'getmethod' or source.type == 'setmethod' for _, value in ipairs(values) do - if value.type == 'function' then - local label = getLabel(value.source, oop) + if value.type == 'function' + or value.type == 'doc.type.function' then + local label = getLabel(value, oop) if label then defs = defs + 1 labels[label] = (labels[label] or 0) + 1 diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index e98a5d4d..7974f325 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -1480,13 +1480,12 @@ function m.checkSameSimpleByBindDocs(status, obj, start, queue, mode) m.searchRefs(newStatus, ref, mode) end end - else - queue[#queue+1] = { - obj = res, - start = start, - force = true, - } end + queue[#queue+1] = { + obj = res, + start = start, + force = true, + } end for _, res in ipairs(newStatus.results) do queue[#queue+1] = { @@ -2710,6 +2709,14 @@ function m.inferCheckUpDoc(status, source) return true end end + elseif doc.type == 'doc.overload' then + if source.value and source.value.type == 'function' then + local typeName = getDocTypeUnitName(doc.overload) + status.results[#status.results+1] = { + type = typeName, + source = doc.overload, + } + end end end end |