From b1a1b3f46771ac5461182a8156452517c280b153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 6 Dec 2021 19:30:55 +0800 Subject: only ignore used doced param in meta --- test/diagnostics/init.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua index 1bbd83b9..dcbfb962 100644 --- a/test/diagnostics/init.lua +++ b/test/diagnostics/init.lua @@ -974,6 +974,14 @@ end ]] TEST [[ +---@param a number +return function () +end +]] + +TEST [[ +---@meta + ---@param a number return function (a) end @@ -1154,6 +1162,7 @@ TEST [[ local emit = {} ]] +config.get 'Lua.diagnostics.neededFileStatus' ['unused-local'] = 'None' TEST [[ ---@param table table ---@param metatable table @@ -1292,6 +1301,8 @@ trim('str', 'left') trim('str', nil) ]] +config.get 'Lua.diagnostics.neededFileStatus' ['unused-local'] = 'Any' + ---不完整的函数参数定义,会跳过检查 TEST [[ ---@param mode string -- cgit v1.2.3 From d060e870a5d24e3e575459a0e02d229d9234109a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 6 Dec 2021 20:02:08 +0800 Subject: cleanup --- test/crossfile/hover.lua | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 86471936..82af9c32 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -41,20 +41,17 @@ end function TEST(expect) files.removeAll() - local targetScript, targetList = catch(expect[1].content, '?') - local targetUri = furi.encode(expect[1].path) - - local sourceScript, sourceList = catch(expect[2].content, '?') - local sourceUri = furi.encode(expect[2].path) - - files.setText(targetUri, targetScript) - files.setText(sourceUri, sourceScript) - - if targetList['?'] then - local targetPos = (targetList['?'][1][1] + targetList['?'][1][2]) // 2 - core.byUri(targetUri, targetPos) + local sourcePos, sourceUri + for _, file in ipairs(expect) do + local script, list = catch(file.content, '?') + local uri = furi.encode(file.path) + files.setText(uri, script) + if list['?'] then + sourceUri = uri + sourcePos = (list['?'][1][1] + list['?'][1][2]) // 2 + end end - local sourcePos = (sourceList['?'][1][1] + sourceList['?'][1][2]) // 2 + local hover = core.byUri(sourceUri, sourcePos) assert(hover) hover = tostring(hover):gsub('\r\n', '\n') -- cgit v1.2.3 From 9471213c956223fc9746d77b2082cd970c6617f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 6 Dec 2021 20:23:09 +0800 Subject: #842 --- test/crossfile/hover.lua | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'test') diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 82af9c32..492efe43 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -1072,3 +1072,64 @@ global G: A { } ```]] } + +TEST { + { + path = 'a.lua', + content = [[ + ---@overload fun(self, a) + function C:(a, b) end + ]] + }, + hover = [[ +```lua +method C:f(a: any, b: any) +``` + +--- + +```lua +method C:f(a: any) +```]] +} + +TEST { + { + path = 'a.lua', + content = [[ + ---@overload fun(self, a) + function C.(a, b) end + ]] + }, + hover = [[ +```lua +function C.f(a: any, b: any) +``` + +--- + +```lua +function C.f(self: any, a: any) +```]] +} + +TEST { + { + path = 'a.lua', + content = [[ + ---@async + ---@overload async fun(self, a) + function C:(a, b) end + ]] + }, + hover = [[ +```lua +async method C:f(a: any, b: any) +``` + +--- + +```lua +async method C:f(a: any) +```]] +} -- cgit v1.2.3 From 29b0c7064b1a0d623867c1136b84e5f1b5038f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 6 Dec 2021 20:37:24 +0800 Subject: fix #842 --- test/completion/common.lua | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/completion/common.lua b/test/completion/common.lua index 3a3d1d46..73337e58 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -2593,7 +2593,7 @@ c: TEST [[ ---@class Class ----@field on fun(x: "'aaa'"|"'bbb'") +---@field on fun(self, x: "'aaa'"|"'bbb'") local c c:on() @@ -2605,7 +2605,7 @@ TEST [[ ---@field on fun(x: "'aaa'"|"'bbb'") local c -c:on('') +c.on('') ]] (EXISTS) @@ -3037,3 +3037,26 @@ end) } }, } + +TEST [[ +---@meta + +---@alias testAlias +---| "'test1'" +---| "'test2'" +---| "'test3'" + +---@class TestClass +local TestClass = {} + +---@overload fun(self: TestClass, arg2: testAlias) +---@param arg1 integer +---@param arg2 testAlias +function TestClass:testFunc2(arg1, arg2) end + +---@type TestClass +local t + +t:testFunc2() +]] +(EXISTS) -- cgit v1.2.3 From 8b0d3827faf0cdc967e52ddfbe043c07c0dbe6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 16 Dec 2021 17:07:15 +0800 Subject: #847 normalize `./` --- test/crossfile/definition.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test') diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua index 058f5d18..b0cc232f 100644 --- a/test/crossfile/definition.lua +++ b/test/crossfile/definition.lua @@ -867,3 +867,28 @@ print(t.) ]] } } + +local originRuntimePath = config.get 'Lua.runtime.path' +config.set('Lua.runtime.path', { + './?.lua' +}) + +TEST { + { + path = 'a.lua', + content = [[ +return { + = 1, +} +]], + }, + { + path = 'b.lua', + content = [[ +local t = require 'a' +print(t.) + ]] + } +} + +config.set('Lua.runtime.path', originRuntimePath) -- cgit v1.2.3 From ab5e1b39ec6eedf3cc47c845fe0544da48e58829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 16 Dec 2021 17:30:37 +0800 Subject: clean up --- test/crossfile/definition.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua index b0cc232f..f44633e1 100644 --- a/test/crossfile/definition.lua +++ b/test/crossfile/definition.lua @@ -869,10 +869,10 @@ print(t.) } local originRuntimePath = config.get 'Lua.runtime.path' + config.set('Lua.runtime.path', { './?.lua' }) - TEST { { path = 'a.lua', @@ -891,4 +891,25 @@ print(t.) } } +--config.set('Lua.runtime.path', { +-- '/home/?.lua' +--}) +--TEST { +-- { +-- path = '/home/a.lua', +-- content = [[ +--return { +-- = 1, +--} +--]], +-- }, +-- { +-- path = 'b.lua', +-- content = [[ +--local t = require 'a' +--print(t.) +-- ]] +-- } +--} + config.set('Lua.runtime.path', originRuntimePath) -- cgit v1.2.3 From 028460ed338a0ba582e5f755a9734ed65b290c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 16 Dec 2021 20:08:23 +0800 Subject: fix #847 --- test/crossfile/definition.lua | 84 ++++++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua index f44633e1..aa971f3e 100644 --- a/test/crossfile/definition.lua +++ b/test/crossfile/definition.lua @@ -891,25 +891,69 @@ print(t.) } } ---config.set('Lua.runtime.path', { --- '/home/?.lua' ---}) ---TEST { --- { --- path = '/home/a.lua', --- content = [[ ---return { --- = 1, ---} ---]], --- }, --- { --- path = 'b.lua', --- content = [[ ---local t = require 'a' ---print(t.) --- ]] --- } ---} +config.set('Lua.runtime.path', { + '/home/?.lua' +}) +TEST { + { + path = '/home/a.lua', + content = [[ +return { + = 1, +} +]], + }, + { + path = 'b.lua', + content = [[ +local t = require 'a' +print(t.) + ]] + } +} +config.set('Lua.runtime.pathStrict', true) +config.set('Lua.runtime.path', { + './?.lua' +}) +TEST { + { + path = 'a.lua', + content = [[ +return { + = 1, +} +]], + }, + { + path = 'b.lua', + content = [[ +local t = require 'a' +print(t.) + ]] + } +} + +config.set('Lua.runtime.path', { + '/home/?.lua' +}) +TEST { + { + path = '/home/a.lua', + content = [[ +return { + = 1, +} +]], + }, + { + path = 'b.lua', + content = [[ +local t = require 'a' +print(t.) + ]] + } +} + +config.set('Lua.runtime.pathStrict', false) config.set('Lua.runtime.path', originRuntimePath) -- cgit v1.2.3