summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/hover/description.lua27
-rw-r--r--test/crossfile/hover.lua16
-rw-r--r--test/hover/init.lua8
3 files changed, 32 insertions, 19 deletions
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 0e4dd9a7..2fac0d99 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -198,11 +198,38 @@ local function tryDocOverloadToComment(source)
end
end
+local function tyrDocParamComment(source)
+ if source.type == 'setlocal'
+ or source.type == 'getlocal' then
+ source = source.node
+ end
+ if source.type ~= 'local' then
+ return
+ end
+ if source.parent.type ~= 'funcargs' then
+ return
+ end
+ if not source.bindDocs then
+ return
+ end
+ for _, doc in ipairs(source.bindDocs) do
+ if doc.type == 'doc.param' then
+ if doc.param[1] == source[1] then
+ if doc.comment then
+ return doc.comment.text
+ end
+ break
+ end
+ end
+ end
+end
+
return function (source)
if source.type == 'string' then
return asString(source)
end
return tryDocOverloadToComment(source)
or tryDocFieldUpComment(source)
+ or tyrDocParamComment(source)
or tryDocComment(source)
end
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index 715d658f..1bfb81e6 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -422,7 +422,6 @@ function f()
}
}
-do return end
TEST {
{
path = 'a.lua',
@@ -431,18 +430,13 @@ TEST {
{
path = 'b.lua',
content = [[
- ---@param x string {comment = 'aaaa'}
- ---@param y string {comment = 'bbbb'}
- local function <?f?>(x, y) end
+---@param x string this is comment
+function f(<?x?>) end
]]
},
hover = {
- label = 'function f(x: string, y: string)',
- name = 'f',
- args = EXISTS,
- description = [[
-+ `x`*(string)*: aaaa
-
-+ `y`*(string)*: bbbb]]
+ label = 'local x: string',
+ name = 'x',
+ description = 'this is comment',
}
}
diff --git a/test/hover/init.lua b/test/hover/init.lua
index 54f1e451..4bfde29e 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -1441,11 +1441,3 @@ local <?y?>
[[
local y: any
]]
-
-TEST [[
----@param x string this is comment
-function f(<?x?>) end
-]]
-[[
-local x: string
-]]