summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-28 00:43:59 +0800
committerGitHub <noreply@github.com>2022-06-28 00:43:59 +0800
commit4774c8ce50f0c971f9e9efde44c083c606f3105a (patch)
treecaef79104f1bdef992ced4584fd37137f8f4e5b7 /test
parentf9b3b65445e86ae0e9c1026ea1fac44bf5d884da (diff)
parenta824f07a2df80f66a8017fd1d6dac8c3df5cf6e2 (diff)
downloadlua-language-server-4774c8ce50f0c971f9e9efde44c083c606f3105a.zip
Merge pull request #1241 from FAForever/array-contents-support
Array contents support
Diffstat (limited to 'test')
-rw-r--r--test/completion/common.lua258
1 files changed, 258 insertions, 0 deletions
diff --git a/test/completion/common.lua b/test/completion/common.lua
index 27431000..fe09dea2 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -1640,6 +1640,264 @@ f('<??>')
}
TEST [[
+---@alias Option string | "AAA" | "BBB" | "CCC"
+---@param x Option[]
+function f(x)
+end
+
+f({<??>})
+]]
+{
+ {
+ label = '"AAA"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"BBB"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"CCC"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ }
+}
+
+TEST [[
+---@alias Option string | "AAA" | "BBB" | "CCC"
+---@param x Option[]
+function f(x)
+end
+
+f({"<??>"})
+]]
+{
+ {
+ label = '"AAA"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"BBB"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"CCC"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ }
+}
+
+TEST [[
+---@alias Option string | "AAA" | "BBB" | "CCC"
+---@param x Option[]
+function f(x)
+end
+
+f(<??>)
+]]
+ (nil)
+
+TEST [[
+---@alias Option "AAA" | "BBB" | "CCC"
+
+---@type Option[]
+local l = {<??>}
+]]
+{
+ {
+ label = '"AAA"',
+ kind = define.CompletionItemKind.EnumMember,
+ },
+ {
+ label = '"BBB"',
+ kind = define.CompletionItemKind.EnumMember,
+ },
+ {
+ label = '"CCC"',
+ kind = define.CompletionItemKind.EnumMember,
+ }
+}
+
+TEST [[
+---@alias Option "AAA" | "BBB" | "CCC"
+
+---@type Option[]
+local l = {"<??>"}
+]]
+{
+ {
+ label = '"AAA"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"BBB"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"CCC"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ }
+}
+
+TEST [[
+---@alias Option "AAA" | "BBB" | "CCC"
+
+---@type Option[]
+local l = <??>
+]]
+ (nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+
+---@type OptionObj[]
+local l = { {<??>} }
+]]
+{
+ {
+ label = 'a',
+ kind = define.CompletionItemKind.Property,
+ },
+ {
+ label = 'b',
+ kind = define.CompletionItemKind.Property,
+ }
+}
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+
+---@type OptionObj[]
+local l = { <??> }
+]]
+ (nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+
+---@type OptionObj[]
+local l = <??>
+]]
+ (nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@field children OptionObj[]
+
+---@type OptionObj[]
+local l = {
+ {
+ a = true,
+ children = { {<??>} }
+ }
+}
+]]
+{
+ {
+ label = 'a',
+ kind = define.CompletionItemKind.Property,
+ },
+ {
+ label = 'b',
+ kind = define.CompletionItemKind.Property,
+ },
+ {
+ label = 'children',
+ kind = define.CompletionItemKind.Property,
+ }
+}
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@field children OptionObj[]
+
+---@type OptionObj[]
+local l = {
+ {
+ children = {<??>}
+ }
+}
+]]
+(nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@field children OptionObj[]
+
+---@type OptionObj[]
+local l = {
+ {
+ children = <??>
+ }
+}
+]]
+(nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@param x OptionObj[]
+function f(x)
+end
+
+f({ {<??>} })
+]]
+{
+ {
+ label = 'a',
+ kind = define.CompletionItemKind.Property,
+ },
+ {
+ label = 'b',
+ kind = define.CompletionItemKind.Property,
+ }
+}
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@param x OptionObj[]
+function f(x)
+end
+
+f({<??>})
+]]
+ (nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@param x OptionObj[]
+function f(x)
+end
+
+f(<??>)
+]]
+ (nil)
+
+TEST [[
---this is
---a multi line
---comment