diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-01-16 21:06:06 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-01-16 21:06:06 +0800 |
commit | 5aaecf51b9fccddf52ed3e4749757a03819fae61 (patch) | |
tree | 87ceb62c6eb926cb54d8ba794697f0d3ddd0b1e3 /test | |
parent | a6798e6adb81da6b7f833bc39da0a6368178a090 (diff) | |
download | lua-language-server-5aaecf51b9fccddf52ed3e4749757a03819fae61.zip |
support `---@meta [name]`
once declared `name`, user can only require this file by declared name
meta file can not be required with name `_`
Diffstat (limited to 'test')
-rw-r--r-- | test/completion/common.lua | 2 | ||||
-rw-r--r-- | test/crossfile/completion.lua | 52 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 49 |
3 files changed, 101 insertions, 2 deletions
diff --git a/test/completion/common.lua b/test/completion/common.lua index 7e4aac61..e0668ea3 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -3538,7 +3538,7 @@ TEST [[ require '<??>' ]] (function (results) - assert(#results == 11, require 'utility'.dump(results)) + assert(#results == 9, require 'utility'.dump(results)) end) TEST [[ diff --git a/test/crossfile/completion.lua b/test/crossfile/completion.lua index 3ad8c385..d613f621 100644 --- a/test/crossfile/completion.lua +++ b/test/crossfile/completion.lua @@ -10,6 +10,7 @@ local define = require 'proto.define' rawset(_G, 'TEST', true) local CompletionItemKind = define.CompletionItemKind +local NeedRemoveMeta = false local EXISTS = {} @@ -87,7 +88,9 @@ function TEST(data) assert(result ~= nil) result.complete = nil result.enableCommon = nil - removeMetas(result) + if NeedRemoveMeta then + removeMetas(result) + end for _, item in ipairs(result) do if item.id then local r = core.resolve(item.id) @@ -441,6 +444,51 @@ config.set(nil, 'Lua.runtime.path', originRuntimePath) TEST { { + path = 'abc.lua', + content = '---@meta _', + }, + { + path = 'test.lua', + content = 'require "a<??>"', + main = true, + }, + completion = nil +} + +TEST { + { + path = 'abc.lua', + content = '---@meta xxxxx', + }, + { + path = 'test.lua', + content = 'require "a<??>"', + main = true, + }, + completion = nil +} + +TEST { + { + path = 'abc.lua', + content = '---@meta xxxxx', + }, + { + path = 'test.lua', + content = 'require "xx<??>"', + main = true, + }, + completion = { + { + label = 'xxxxx', + kind = CompletionItemKind.File, + textEdit = EXISTS, + } + } +} + +TEST { + { path = 'a.lua', content = [[ return { @@ -561,6 +609,8 @@ TEST { completion = nil, } +NeedRemoveMeta = true + TEST { { path = 'f/a.lua' }, { path = 'f/b.lua' }, diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index d47bb41b..3cd560ff 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -176,6 +176,55 @@ end TEST { { path = 'a.lua', + content = '---@meta _', + }, + { + path = 'b.lua', + content = 'require <?"a"?>', + }, + hover = [[ +```lua +1 个字节 +```]], +} + +TEST { + { + path = 'a.lua', + content = '---@meta xxx', + }, + { + path = 'b.lua', + content = 'require <?"a"?>', + }, + hover = [[ +```lua +1 个字节 +```]], +} + +TEST { + { + path = 'a.lua', + content = '---@meta xxx', + }, + { + path = 'b.lua', + content = 'require <?"xxx"?>', + }, + hover = [=[ +```lua +3 个字节 +``` + +--- + +* [[meta]](file:///a.lua)]=], +} + +TEST { + { + path = 'a.lua', content = [[ local function f(a, b) end |