diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-06-26 16:42:19 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-06-26 16:42:19 +0800 |
commit | f8407a7ed2faa1892ab63fbaed5539420af90180 (patch) | |
tree | 68466bb0b0ccc6512bd52cfe45b4059ea4b2bd66 /server/src/core/completion.lua | |
parent | e98245ae3492ce132ddfe9153b1a5a80f3a3e3e4 (diff) | |
download | lua-language-server-f8407a7ed2faa1892ab63fbaed5539420af90180.zip |
自动完成对多原型函数的支持
Diffstat (limited to 'server/src/core/completion.lua')
-rw-r--r-- | server/src/core/completion.lua | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index a938d83c..34eecb0e 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -82,25 +82,40 @@ end local function getDetail(value) local literal = value:getLiteral() local tp = type(literal) + local detals = {} + if value:getType() ~= 'any' then + detals[#detals+1] = ('(%s)'):format(value:getType()) + end if tp == 'boolean' then - return ('= %q'):format(literal) + detals[#detals+1] = (' = %q'):format(literal) elseif tp == 'string' then - return ('= %q'):format(literal) + detals[#detals+1] = (' = %q'):format(literal) elseif tp == 'number' then if math.type(literal) == 'integer' then - return ('= %q'):format(literal) + detals[#detals+1] = (' = %q'):format(literal) else - local str = ('= %.16f'):format(literal) + local str = (' = %.16f'):format(literal) local dot = str:find('.', 1, true) local suffix = str:find('[0]+$', dot + 2) if suffix then - return str:sub(1, suffix - 1) + detals[#detals+1] = str:sub(1, suffix - 1) else - return str + detals[#detals+1] = str end end end - return nil + if value:getType() == 'function' then + ---@type emmyFunction + local func = value:getFunction() + local overLoads = func and func:getEmmyOverLoads() + if overLoads then + detals[#detals+1] = ('(%d 个原型)'):format(#overLoads + 1) + end + end + if #detals == 0 then + return nil + end + return table.concat(detals) end local function getKind(cata, value) |