File tree 3 files changed +32
-19
lines changed
3 files changed +32
-19
lines changed Original file line number Diff line number Diff line change @@ -198,11 +198,38 @@ local function tryDocOverloadToComment(source)
198
198
end
199
199
end
200
200
201
+ local function tyrDocParamComment (source )
202
+ if source .type == ' setlocal'
203
+ or source .type == ' getlocal' then
204
+ source = source .node
205
+ end
206
+ if source .type ~= ' local' then
207
+ return
208
+ end
209
+ if source .parent .type ~= ' funcargs' then
210
+ return
211
+ end
212
+ if not source .bindDocs then
213
+ return
214
+ end
215
+ for _ , doc in ipairs (source .bindDocs ) do
216
+ if doc .type == ' doc.param' then
217
+ if doc .param [1 ] == source [1 ] then
218
+ if doc .comment then
219
+ return doc .comment .text
220
+ end
221
+ break
222
+ end
223
+ end
224
+ end
225
+ end
226
+
201
227
return function (source )
202
228
if source .type == ' string' then
203
229
return asString (source )
204
230
end
205
231
return tryDocOverloadToComment (source )
206
232
or tryDocFieldUpComment (source )
233
+ or tyrDocParamComment (source )
207
234
or tryDocComment (source )
208
235
end
Original file line number Diff line number Diff line change @@ -422,7 +422,6 @@ function f()
422
422
}
423
423
}
424
424
425
- do return end
426
425
TEST {
427
426
{
428
427
path = ' a.lua' ,
@@ -431,18 +430,13 @@ TEST {
431
430
{
432
431
path = ' b.lua' ,
433
432
content = [[
434
- ---@param x string {comment = 'aaaa'}
435
- ---@param y string {comment = 'bbbb'}
436
- local function <?f?>(x, y) end
433
+ ---@param x string this is comment
434
+ function f(<?x?>) end
437
435
]]
438
436
},
439
437
hover = {
440
- label = ' function f(x: string, y: string)' ,
441
- name = ' f' ,
442
- args = EXISTS ,
443
- description = [[
444
- + `x`*(string)*: aaaa
445
-
446
- + `y`*(string)*: bbbb]]
438
+ label = ' local x: string' ,
439
+ name = ' x' ,
440
+ description = ' this is comment' ,
447
441
}
448
442
}
Original file line number Diff line number Diff line change @@ -1441,11 +1441,3 @@ local <?y?>
1441
1441
[[
1442
1442
local y: any
1443
1443
]]
1444
-
1445
- TEST [[
1446
- ---@param x string this is comment
1447
- function f(<?x?>) end
1448
- ]]
1449
- [[
1450
- local x: string
1451
- ]]
You can’t perform that action at this time.
0 commit comments