From 79bf3e605d282cdbe425eea1b5793fc97d8404da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 26 Nov 2020 19:40:48 +0800 Subject: close #135 param comment --- script/core/hover/description.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'script') 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 -- cgit v1.2.3