diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/completion/init.lua | 202 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 30 | ||||
-rw-r--r-- | test/diagnostics/init.lua | 8 | ||||
-rw-r--r-- | test/document_symbol/init.lua | 32 |
4 files changed, 138 insertions, 134 deletions
diff --git a/test/completion/init.lua b/test/completion/init.lua index 22103896..89772853 100644 --- a/test/completion/init.lua +++ b/test/completion/init.lua @@ -60,6 +60,8 @@ local Cared = { ['deprecated'] = true, } +local IgnoreFunction = false + function TEST(script) return function (expect) files.removeAll() @@ -86,6 +88,16 @@ function TEST(script) end end end + if IgnoreFunction then + for i = #result, 1, -1 do + local item = result[i] + if item.label:find '%(' + and not item.label:find 'function' then + result[i] = result[#result] + result[#result] = nil + end + end + end assert(result) if expect.include then expect.include = nil @@ -175,11 +187,11 @@ ass$ ]] { { - label = 'assert', + label = 'assert(v, message)', kind = define.CompletionItemKind.Function, }, { - label = 'assert()', + label = 'assert(v, message)', kind = define.CompletionItemKind.Snippet, }, } @@ -201,11 +213,11 @@ _G.ass$ ]] { { - label = 'assert', + label = 'assert(v, message)', kind = define.CompletionItemKind.Function, }, { - label = 'assert()', + label = 'assert(v, message)', kind = define.CompletionItemKind.Snippet, }, } @@ -217,11 +229,11 @@ ff$ ]] { { - label = 'ffff', + label = 'ffff(a, b)', kind = define.CompletionItemKind.Function, }, { - label = 'ffff()', + label = 'ffff(a, b)', kind = define.CompletionItemKind.Snippet, } } @@ -285,11 +297,11 @@ mt:g$ ]] { { - label = 'get', + label = 'get(a, b)', kind = define.CompletionItemKind.Method, }, { - label = 'get()', + label = 'get(a, b)', kind = define.CompletionItemKind.Snippet, }, { @@ -311,15 +323,16 @@ loc$ kind = define.CompletionItemKind.Snippet, }, { - label = 'collectgarbage', + label = 'collectgarbage(opt, ...)', kind = define.CompletionItemKind.Function, }, { - label = 'collectgarbage()', + label = 'collectgarbage(opt, ...)', kind = define.CompletionItemKind.Snippet, }, } +IgnoreFunction = true TEST [[ do$ ]] @@ -332,50 +345,6 @@ do$ label = 'do .. end', kind = define.CompletionItemKind.Snippet, }, - { - label = 'dofile', - kind = define.CompletionItemKind.Function, - }, - { - label = 'dofile()', - kind = define.CompletionItemKind.Snippet, - }, - { - label = 'load', - kind = define.CompletionItemKind.Function, - }, - { - label = 'load()', - kind = define.CompletionItemKind.Snippet, - }, - { - label = 'loadfile', - kind = define.CompletionItemKind.Function, - }, - { - label = 'loadfile()', - kind = define.CompletionItemKind.Snippet, - }, - { - label = 'loadstring', - kind = define.CompletionItemKind.Function, - deprecated = true, - }, - { - label = 'loadstring()', - kind = define.CompletionItemKind.Snippet, - deprecated = true, - }, - { - label = 'module', - kind = define.CompletionItemKind.Function, - deprecated = true, - }, - { - label = 'module()', - kind = define.CompletionItemKind.Snippet, - deprecated = true, - }, } TEST [[ @@ -454,6 +423,7 @@ t. $ }, } +IgnoreFunction = false TEST [[ t.a = {} function t:b() @@ -462,7 +432,7 @@ t:$ ]] { { - label = 'b', + label = 'b()', kind = define.CompletionItemKind.Method, }, { @@ -507,6 +477,7 @@ TEST 'local s = "a:$"' (nil) TEST 'debug.$' (EXISTS) +IgnoreFunction = true TEST [[ local xxxx = { xxyy = 1, @@ -530,22 +501,6 @@ local t = { label = 'xxzz', kind = define.CompletionItemKind.Property, }, - { - label = 'next', - kind = define.CompletionItemKind.Function, - }, - { - label = 'next()', - kind = define.CompletionItemKind.Snippet, - }, - { - label = 'xpcall', - kind = define.CompletionItemKind.Function, - }, - { - label = 'xpcall()', - kind = define.CompletionItemKind.Snippet, - }, } TEST [[ @@ -1030,25 +985,10 @@ else$ label = 'ELSE', kind = define.CompletionItemKind.Enum, }, - { - label = 'select', - kind = define.CompletionItemKind.Function, - }, - { - label = 'select()', - kind = define.CompletionItemKind.Snippet, - }, - { - label = 'setmetatable', - kind = define.CompletionItemKind.Function, - }, - { - label = 'setmetatable()', - kind = define.CompletionItemKind.Snippet, - }, } Cared['insertText'] = true +IgnoreFunction = false TEST [[ local xpcal xpcal$ @@ -1059,11 +999,12 @@ xpcal$ kind = define.CompletionItemKind.Variable, }, { - label = 'xpcall', + label = 'xpcall(f, msgh, arg1, ...)', kind = define.CompletionItemKind.Function, + insertText = EXISTS, }, { - label = 'xpcall()', + label = 'xpcall(f, msgh, arg1, ...)', kind = define.CompletionItemKind.Snippet, insertText = EXISTS, }, @@ -1077,11 +1018,12 @@ mt:f$ ]] { { - label = 'f', + label = 'f(a, b, c)', kind = define.CompletionItemKind.Method, + insertText = EXISTS, }, { - label = 'f()', + label = 'f(a, b, c)', kind = define.CompletionItemKind.Snippet, insertText = 'f(${1:a: any}, ${2:b: any}, ${3:c: any})', }, @@ -1123,6 +1065,7 @@ end", }, } Cared['insertText'] = false +IgnoreFunction = true TEST [[ local function f() @@ -1143,22 +1086,6 @@ end label = 'elseif .. then', kind = define.CompletionItemKind.Snippet, }, - { - label = 'select', - kind = define.CompletionItemKind.Function, - }, - { - label = 'select()', - kind = define.CompletionItemKind.Snippet, - }, - { - label = 'setmetatable', - kind = define.CompletionItemKind.Function, - }, - { - label = 'setmetatable()', - kind = define.CompletionItemKind.Snippet, - }, } TEST [[ @@ -1259,17 +1186,18 @@ io$ ]] (EXISTS) +IgnoreFunction = false TEST [[ loadstring$ ]] { { - label = 'loadstring', + label = 'loadstring(text, chunkname)', kind = define.CompletionItemKind.Function, deprecated = true, }, { - label = 'loadstring()', + label = 'loadstring(text, chunkname)', kind = define.CompletionItemKind.Snippet, deprecated = true, }, @@ -1293,13 +1221,23 @@ loadstring$ ]] { { - label = 'loadstring', + label = 'loadstring()', kind = define.CompletionItemKind.Function, }, { label = 'loadstring()', kind = define.CompletionItemKind.Snippet, }, + { + label = 'loadstring(text, chunkname)', + deprecated = true, + kind = define.CompletionItemKind.Function, + }, + { + label = 'loadstring(text, chunkname)', + deprecated = true, + kind = define.CompletionItemKind.Snippet, + }, } TEST [[ @@ -1307,12 +1245,12 @@ debug.setcsta$ ]] { { - label = 'setcstacklimit', + label = 'setcstacklimit(limit)', kind = define.CompletionItemKind.Function, deprecated = true, }, { - label = 'setcstacklimit()', + label = 'setcstacklimit(limit)', kind = define.CompletionItemKind.Snippet, deprecated = true, }, @@ -1837,9 +1775,6 @@ end) TEST [[ --- JustTest ----@overload fun(list:table):string ----@overload fun(list:table, sep:string):string ----@overload fun(list:table, sep:string, i:number):string ---@param list table ---@param sep string ---@param i number @@ -1851,11 +1786,12 @@ zzz$ ]] { { - label = 'zzzzz', + label = 'zzzzz(list, sep, i, j)', kind = define.CompletionItemKind.Function, + insertText = EXISTS, }, { - label = 'zzzzz()', + label = 'zzzzz(list, sep, i, j)', kind = define.CompletionItemKind.Snippet, insertText = EXISTS, } @@ -2334,8 +2270,9 @@ end m.f$ ]]{ { - label = "f", + label = "f()", kind = define.CompletionItemKind.Function, + insertText = EXISTS, }, { label = "f()", @@ -2541,3 +2478,32 @@ TEST [[ }, } } + +Cared['insertText'] = true +TEST [[ +---@overload fun(a: any, b: any) +local function zzzz(a) end +zzzz$ +]] +{ + { + label = 'zzzz(a)', + kind = define.CompletionItemKind.Function, + insertText = 'zzzz', + }, + { + label = 'zzzz(a)', + kind = define.CompletionItemKind.Snippet, + insertText = 'zzzz(${1:a: any})', + }, + { + label = 'zzzz(a, b)', + kind = define.CompletionItemKind.Function, + insertText = 'zzzz', + }, + { + label = 'zzzz(a, b)', + kind = define.CompletionItemKind.Snippet, + insertText = 'zzzz(${1:a: any}, ${2:b: any})', + }, +} diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 521f5a49..bf56b39a 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -731,3 +731,33 @@ hover = { label = 'field Food.firstField: integer = 0', name = 'food.firstField', }} + +TEST {{ path = 'a.lua', content = '', }, { + path = 'b.lua', + content = [[ +--[=[ +I'm a multiline comment +]=] +local <?food?> +]] +}, +hover = { + label = 'local food: any', + name = 'food', + description = "I'm a multiline comment\n" +}} + +TEST {{ path = 'a.lua', content = '', }, { + path = 'b.lua', + content = [[ +---@return string # 'this is a tab `\t`' +local function <?f?>() end +]] +}, +hover = { + label = [[ +function f() + -> string]], + name = 'food', + description = "@*return* — this is a tab `\t`" +}} diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua index 00a2cda8..d4bffdb5 100644 --- a/test/diagnostics/init.lua +++ b/test/diagnostics/init.lua @@ -100,7 +100,7 @@ local <!t!> = {} ]] TEST([[ -<!local function x() +local <!function x() end!> ]], [[ @@ -119,9 +119,9 @@ local <!x!> ]] TEST([[ -<!local function x() +local <!function x() end!> -<!local function y() +local <!function y() x() end!> ]], @@ -363,7 +363,7 @@ local f;f = <!function () end!> ]] TEST [[ -<!local function f() end!> +local <!function f() end!> ]] config.config.diagnostics.disable['unused-local'] = nil diff --git a/test/document_symbol/init.lua b/test/document_symbol/init.lua index d9f1bec3..718089e2 100644 --- a/test/document_symbol/init.lua +++ b/test/document_symbol/init.lua @@ -77,9 +77,9 @@ end name = 'f', detail = 'function ()', kind = define.SymbolKind.Function, - range = {1, 22}, + range = {7, 22}, selectionRange = {16, 16}, - valueRange = {1, 22}, + valueRange = {7, 22}, } } @@ -227,9 +227,9 @@ local z name = 'f', detail = 'function ()', kind = define.SymbolKind.Function, - range = {13, 79}, + range = {19, 79}, selectionRange = {28, 28}, - valueRange = {13, 79}, + valueRange = {19, 79}, children = { [1] = { name = 'x', @@ -360,9 +360,9 @@ g = 1 name = 'g', detail = 'function ()', kind = define.SymbolKind.Function, - range = {1, 22}, + range = {7, 22}, selectionRange = {16, 16}, - valueRange = {1, 22}, + valueRange = {7, 22}, }, [2] = { name = 'g', @@ -449,6 +449,14 @@ local function range = {7, 7}, selectionRange = {7, 7}, }, + [2] = { + name = "", + detail = "function ()", + kind = 12, + range = {15, 22}, + selectionRange = {15, 15}, + valueRange = {15, 22}, + }, } TEST [[ @@ -496,17 +504,17 @@ end name = 'x', detail = 'function ()', kind = define.SymbolKind.Function, - range = {1, 22}, + range = {7, 22}, selectionRange = {16, 16}, - valueRange = {1, 22}, + valueRange = {7, 22}, }, [2] = { name = 'f', detail = 'function ()', kind = define.SymbolKind.Function, - range = {25, 58}, + range = {31, 58}, selectionRange = {40, 40}, - valueRange = {25, 58}, + valueRange = {31, 58}, children = { [1] = { name = 'c', @@ -563,9 +571,9 @@ end name = 'f', detail = 'function (a, b)', kind = define.SymbolKind.Function, - range = {15, 40}, + range = {21, 40}, selectionRange = {30, 30}, - valueRange = {15, 40}, + valueRange = {21, 40}, children = { [1] = { name = 'a', |