fix(lsp): add parentheses to generated union array types (#27560)

This commit is contained in:
Maria José Solano
2024-02-21 03:31:56 -08:00
committed by GitHub
parent 09651342e7
commit ac0e8323dc
2 changed files with 8 additions and 4 deletions

View File

@@ -409,7 +409,7 @@ error('Cannot require a meta file')
--- ---
---If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then ---If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then
---only plain `TextEdit`s using the `changes` property are supported. ---only plain `TextEdit`s using the `changes` property are supported.
---@field documentChanges? lsp.TextDocumentEdit|lsp.CreateFile|lsp.RenameFile|lsp.DeleteFile[] ---@field documentChanges? (lsp.TextDocumentEdit|lsp.CreateFile|lsp.RenameFile|lsp.DeleteFile)[]
--- ---
---A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and ---A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and
---delete file / folder operations. ---delete file / folder operations.
@@ -1888,7 +1888,7 @@ error('Cannot require a meta file')
--- ---
---@since 3.16.0 - support for AnnotatedTextEdit. This is guarded using a ---@since 3.16.0 - support for AnnotatedTextEdit. This is guarded using a
---client capability. ---client capability.
---@field edits lsp.TextEdit|lsp.AnnotatedTextEdit[] ---@field edits (lsp.TextEdit|lsp.AnnotatedTextEdit)[]
---Create file operation. ---Create file operation.
---@class lsp.CreateFile: lsp.ResourceOperation ---@class lsp.CreateFile: lsp.ResourceOperation
@@ -3146,7 +3146,7 @@ error('Cannot require a meta file')
---@class lsp.NotebookDocumentSyncOptions ---@class lsp.NotebookDocumentSyncOptions
--- ---
---The notebooks to be synced ---The notebooks to be synced
---@field notebookSelector lsp._anonym14.notebookSelector|lsp._anonym16.notebookSelector[] ---@field notebookSelector (lsp._anonym14.notebookSelector|lsp._anonym16.notebookSelector)[]
--- ---
---Whether save notification should be forwarded to ---Whether save notification should be forwarded to
---the server. Will only be honored if mode === `notebook`. ---the server. Will only be honored if mode === `notebook`.

View File

@@ -224,7 +224,11 @@ function M.gen(opt)
-- ArrayType -- ArrayType
elseif type.kind == 'array' then elseif type.kind == 'array' then
return parse_type(type.element, prefix) .. '[]' local parsed_items = parse_type(type.element, prefix)
if type.element.items and #type.element.items > 1 then
parsed_items = '(' .. parsed_items .. ')'
end
return parsed_items .. '[]'
-- OrType -- OrType
elseif type.kind == 'or' then elseif type.kind == 'or' then