diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-06 00:25:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-06 00:25:14 +0800 |
commit | 21d1b8fd59bcfff3797453e787a1151f8987ae0b (patch) | |
tree | 0e146319e02373c2a90d307c1c06e4af562c57b5 /test/completion | |
parent | d308b37e66d01737d5079b5a062127cdfcba47b1 (diff) | |
parent | 63b360689f0c2c99a1ae410518f6866f49972f98 (diff) | |
download | lua-language-server-21d1b8fd59bcfff3797453e787a1151f8987ae0b.zip |
Merge commit '63b360689f0c2c99a1ae410518f6866f49972f98' into 3.0
Diffstat (limited to 'test/completion')
-rw-r--r-- | test/completion/common.lua | 163 |
1 files changed, 160 insertions, 3 deletions
diff --git a/test/completion/common.lua b/test/completion/common.lua index dbc90ade..6fde16fe 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -76,6 +76,29 @@ zac<??> }, } +config.set(nil, 'Lua.completion.callSnippet', 'Disable') +TEST [[ +ass<??> +]] +{ + { + label = 'assert(v, message)', + kind = define.CompletionItemKind.Function, + }, +} + +config.set(nil, 'Lua.completion.callSnippet', 'Replace') +TEST [[ +ass<??> +]] +{ + { + label = 'assert(v, message)', + kind = define.CompletionItemKind.Function, + }, +} + +config.set(nil, 'Lua.completion.callSnippet', 'Both') TEST [[ ass<??> ]] @@ -2414,6 +2437,108 @@ zzzz<??> insertText = 'zzzz(${1:a: any}, ${2:b: any})', }, } + +TEST [[ +---@param a any +---@param b? any +---@param c? any +---@vararg any +local function foo(a, b, c, ...) end +foo<??> +]] +{ + { + label = 'foo(a, b, c, ...)', + kind = define.CompletionItemKind.Function, + insertText = 'foo', + }, + { + label = 'foo(a, b, c, ...)', + kind = define.CompletionItemKind.Snippet, + insertText = 'foo(${1:a: any})', + }, +} + +TEST [[ +---@param a any +---@param b? any +---@param c? any +---@vararg any +local function foo(a, b, c, ...) end +foo<??> +]] +{ + { + label = 'foo(a, b, c, ...)', + kind = define.CompletionItemKind.Function, + insertText = 'foo', + }, + { + label = 'foo(a, b, c, ...)', + kind = define.CompletionItemKind.Snippet, + insertText = 'foo(${1:a: any})', + }, +} + +TEST [[ +---@param a? any +---@param b? any +---@param c? any +---@vararg any +local function foo(a, b, c, ...) end +foo<??> +]] +{ + { + label = 'foo(a, b, c, ...)', + kind = define.CompletionItemKind.Function, + insertText = 'foo', + }, + { + label = 'foo(a, b, c, ...)', + kind = define.CompletionItemKind.Snippet, + insertText = 'foo($1)', + }, +} + +TEST [[ +---@param a? any +---@param b any +---@param c? any +---@vararg any +local function foo(a, b, c, ...) end +foo<??> +]] +{ + { + label = 'foo(a, b, c, ...)', + kind = define.CompletionItemKind.Function, + insertText = 'foo', + }, + { + label = 'foo(a, b, c, ...)', + kind = define.CompletionItemKind.Snippet, + insertText = 'foo(${1:a?: any}, ${2:b: any})', + }, +} + +TEST [[ +---@param f fun(a: any, b: any) +local function foo(f) end +foo<??> +]] +{ + { + label = 'foo(f)', + kind = define.CompletionItemKind.Function, + insertText = 'foo', + }, + { + label = 'foo(f)', + kind = define.CompletionItemKind.Snippet, + insertText = 'foo(${1:f: fun(a: any, b: any)})', + }, +} Cared['insertText'] = false TEST [[ @@ -2681,9 +2806,9 @@ class2:<??> TEST [[ --- @class Emit ---- @field on fun(eventName: string, cb: function) ---- @field on fun(eventName: '"died"', cb: fun(i: integer)) ---- @field on fun(eventName: '"won"', cb: fun(s: string)) +--- @field on fun(self: Emit, eventName: string, cb: function) +--- @field on fun(self: Emit, eventName: '"died"', cb: fun(i: integer)) +--- @field on fun(self: Emit, eventName: '"won"', cb: fun(s: string)) local emit = {} emit:on('<??>') @@ -2697,6 +2822,22 @@ TEST [[ --- @field on fun(eventName: '"won"', cb: fun(s: string)) local emit = {} +emit.on('died', <??>) +]] +{ + [1] = { + label = 'fun(i: integer)', + kind = define.CompletionItemKind.Function, + } +} + +TEST [[ +--- @class Emit +--- @field on fun(self: Emit, eventName: string, cb: function) +--- @field on fun(self: Emit, eventName: '"died"', cb: fun(i: integer)) +--- @field on fun(self: Emit, eventName: '"won"', cb: fun(s: string)) +local emit = {} + emit:on('won', <??>) ]] { @@ -2707,6 +2848,22 @@ emit:on('won', <??>) } TEST [[ +--- @class Emit +--- @field on fun(self: Emit, eventName: string, cb: function) +--- @field on fun(self: Emit, eventName: '"died"', cb: fun(i: integer)) +--- @field on fun(self: Emit, eventName: '"won"', cb: fun(s: string)) +local emit = {} + +emit.on(emit, 'won', <??>) +]] +{ + [1] = { + label = 'fun(s: string)', + kind = define.CompletionItemKind.Function, + } +} + +TEST [[ local function f() local inferCache in<??> |