summaryrefslogtreecommitdiff
path: root/script/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-26 01:31:45 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-26 01:31:45 +0800
commitc78fbf09aa4406db905a8a0e6dd5731871f2c262 (patch)
tree50d1c7005f1ab879608a5738d626370e1a01ac70 /script/parser
parented64703ef9fec2b1c6736a0deb68bd567875a654 (diff)
downloadlua-language-server-c78fbf09aa4406db905a8a0e6dd5731871f2c262.zip
#1207
return names and parentheses can be used in `DocFunction`
Diffstat (limited to 'script/parser')
-rw-r--r--script/parser/luadoc.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 06cd5511..392b476f 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -434,11 +434,31 @@ local function parseTypeUnitFunction(parent)
end
if checkToken('symbol', ':', 1) then
nextToken()
+ local needCloseParen
+ if checkToken('symbol', '(', 1) then
+ nextToken()
+ needCloseParen = true
+ end
while true do
+ local name
+ try(function ()
+ local returnName = parseName('doc.return.name', typeUnit)
+ or parseDots('doc.return.name', typeUnit)
+ if not returnName then
+ return false
+ end
+ if checkToken('symbol', ':', 1) then
+ nextToken()
+ name = returnName
+ return true
+ end
+ return false
+ end)
local rtn = parseType(typeUnit)
if not rtn then
break
end
+ rtn.name = name
if checkToken('symbol', '?', 1) then
nextToken()
rtn.optional = true
@@ -450,6 +470,9 @@ local function parseTypeUnitFunction(parent)
break
end
end
+ if needCloseParen then
+ nextSymbolOrError ')'
+ end
end
typeUnit.finish = getFinish()
return typeUnit