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 6
6
+ ` type-check ` : removed for now
7
7
+ ` no-implicit-any ` : renamed to ` no-unknown `
8
8
* ` CHG ` formatter: no longer need` --preview `
9
+ * ` CHG ` ` LuaDoc ` : supports ` ---@type (string|integer)[] `
9
10
* ` FIX ` semantic: color of ` function `
10
11
* ` FIX ` [ #1027 ] ( https://github.com/sumneko/lua-language-server/issues/1027 )
11
12
* ` 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)
598
598
return boolean
599
599
end
600
600
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
+
601
611
function parseTypeUnit (parent )
602
612
local result = parseFunction (parent )
603
613
or parseTable (parent )
604
614
or parseString (parent )
605
615
or parseInteger (parent )
606
616
or parseBoolean (parent )
607
617
or parseDots (' doc.type.name' , parent )
618
+ or parseParen (parent )
608
619
if not result then
609
620
local literal = checkToken (' symbol' , ' `' , 1 )
610
621
if literal then
Original file line number Diff line number Diff line change @@ -111,7 +111,11 @@ local viewNodeSwitch = util.switch()
111
111
: case ' doc.type.array'
112
112
: call (function (source , infer )
113
113
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 .. ' []'
115
119
end )
116
120
: case ' doc.type.table'
117
121
: call (function (source , infer )
Original file line number Diff line number Diff line change @@ -1434,3 +1434,8 @@ local t = { 'x' }
1434
1434
1435
1435
local <?x?> = t[#t]
1436
1436
]]
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