From 4e0a890060aea1eb54b14b3a77cba8fc42ceeebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 10 Apr 2022 03:12:05 +0800 Subject: supports `---@type (string|integer)[]` --- script/parser/luadoc.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'script/parser') diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 6adbfa68..f9cd3db0 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -598,6 +598,16 @@ local function parseBoolean(parent) return boolean end +local function parseParen(parent) + if not checkToken('symbol', '(', 1) then + return + end + nextToken() + local tp = parseType(parent) + nextSymbolOrError(')') + return tp +end + function parseTypeUnit(parent) local result = parseFunction(parent) or parseTable(parent) @@ -605,6 +615,7 @@ function parseTypeUnit(parent) or parseInteger(parent) or parseBoolean(parent) or parseDots('doc.type.name', parent) + or parseParen(parent) if not result then local literal = checkToken('symbol', '`', 1) if literal then -- cgit v1.2.3