diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-07-15 09:44:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-07-15 09:44:25 +0800 |
commit | 2b06194b9447fab098258d642df2623910355d39 (patch) | |
tree | 11efdbfd018d3ae2a2f20846e12c6d2c9bfafdb1 | |
parent | a0b866db543e1b0822772f534f0facc624d1b65b (diff) | |
download | lua-language-server-2b06194b9447fab098258d642df2623910355d39.zip |
支持参数描述
-rw-r--r-- | server/src/core/hover/function.lua | 17 | ||||
-rw-r--r-- | server/test/crossfile/hover.lua | 19 |
2 files changed, 35 insertions, 1 deletions
diff --git a/server/src/core/hover/function.lua b/server/src/core/hover/function.lua index 5adeeb7e..6139bd1b 100644 --- a/server/src/core/hover/function.lua +++ b/server/src/core/hover/function.lua @@ -184,7 +184,22 @@ local function getComment(func) if not func then return nil end - return func:getComment() + local comments = {} + local params = func:getEmmyParams() + if params then + for _, param in ipairs(params) do + local option = param:getOption() + if option and option.comment then + comments[#comments+1] = ('+ `%s`*(%s)*: %s'):format(param:getName(), param:getType(), option.comment) + end + end + end + comments[#comments+1] = '\n' + comments[#comments+1] = func:getComment() + if #comments == 0 then + return nil + end + return table.concat(comments, '\n') end local function getOverLoads(name, func, object, select) diff --git a/server/test/crossfile/hover.lua b/server/test/crossfile/hover.lua index 19e8912f..f104fa38 100644 --- a/server/test/crossfile/hover.lua +++ b/server/test/crossfile/hover.lua @@ -310,3 +310,22 @@ x: option |>'选项2' -- 注释2]] } } + +TEST { + { + path = 'a.lua', + content = '', + }, + { + path = 'b.lua', + content = [[ + ---@param x string {comment = 'aaaa'} + ---@param y string {comment = 'bbbb'} + local function <?f?>(x, y) end + ]] + }, + hover = { + label = 'function f(x: string, y: string)', + name = 'f', + } +} |