File tree Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 66 + ` type-check ` : removed for now
77 + ` no-implicit-any ` : renamed to ` no-unknown `
88* ` CHG ` formatter: no longer need` --preview `
9+ * ` CHG ` ` LuaDoc ` : supports ` ---@type (string|integer)[] `
910* ` FIX ` semantic: color of ` function `
1011* ` FIX ` [ #1027 ] ( https://github.com/sumneko/lua-language-server/issues/1027 )
1112* ` FIX ` [ #1028 ] ( https://github.com/sumneko/lua-language-server/issues/1028 )
Original file line number Diff line number Diff line change @@ -598,13 +598,24 @@ local function parseBoolean(parent)
598598 return boolean
599599end
600600
601+ local function parseParen (parent )
602+ if not checkToken (' symbol' , ' (' , 1 ) then
603+ return
604+ end
605+ nextToken ()
606+ local tp = parseType (parent )
607+ nextSymbolOrError (' )' )
608+ return tp
609+ end
610+
601611function parseTypeUnit (parent )
602612 local result = parseFunction (parent )
603613 or parseTable (parent )
604614 or parseString (parent )
605615 or parseInteger (parent )
606616 or parseBoolean (parent )
607617 or parseDots (' doc.type.name' , parent )
618+ or parseParen (parent )
608619 if not result then
609620 local literal = checkToken (' symbol' , ' `' , 1 )
610621 if literal then
Original file line number Diff line number Diff line change @@ -111,7 +111,11 @@ local viewNodeSwitch = util.switch()
111111 : case ' doc.type.array'
112112 : call (function (source , infer )
113113 infer ._hasClass = true
114- return m .getInfer (source .node ):view () .. ' []'
114+ local view = m .getInfer (source .node ):view ()
115+ if source .node .type == ' doc.type' then
116+ view = ' (' .. view .. ' )'
117+ end
118+ return view .. ' []'
115119 end )
116120 : case ' doc.type.table'
117121 : call (function (source , infer )
Original file line number Diff line number Diff line change @@ -1434,3 +1434,8 @@ local t = { 'x' }
14341434
14351435local <?x?> = t[#t]
14361436]]
1437+
1438+ TEST ' (string|integer)[]' [[
1439+ ---@type (string|integer)[]
1440+ local <?x?>
1441+ ]]
You can’t perform that action at this time.
0 commit comments