diff options
author | sumneko <sumneko@hotmail.com> | 2021-12-21 22:49:59 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2021-12-21 22:49:59 +0800 |
commit | b7344640a0ab9a07551ee5ebc435657b45659553 (patch) | |
tree | 0fef08a7dbb0a115e0e1249b6123fd529cf1fc58 /test/crossfile | |
parent | c47baf932309a05673b7931fdf6a1be207fb7bc4 (diff) | |
parent | ec4f497aa2624d9dce29e1de0cfd28ecd85e7df3 (diff) | |
download | lua-language-server-b7344640a0ab9a07551ee5ebc435657b45659553.zip |
Merge remote-tracking branch 'origin/master' into multi-workspace
Diffstat (limited to 'test/crossfile')
-rw-r--r-- | test/crossfile/definition.lua | 90 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 84 |
2 files changed, 161 insertions, 13 deletions
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua index 8f4dd7e8..c9a95658 100644 --- a/test/crossfile/definition.lua +++ b/test/crossfile/definition.lua @@ -867,3 +867,93 @@ print(t.<?x?>) ]] } } + +local originRuntimePath = config.get 'Lua.runtime.path' + +config.set('Lua.runtime.path', { + './?.lua' +}) +TEST { + { + path = 'a.lua', + content = [[ +return { + <!x!> = 1, +} +]], + }, + { + path = 'b.lua', + content = [[ +local t = require 'a' +print(t.<?x?>) + ]] + } +} + +config.set('Lua.runtime.path', { + '/home/?.lua' +}) +TEST { + { + path = '/home/a.lua', + content = [[ +return { + <!x!> = 1, +} +]], + }, + { + path = 'b.lua', + content = [[ +local t = require 'a' +print(t.<?x?>) + ]] + } +} + +config.set('Lua.runtime.pathStrict', true) +config.set('Lua.runtime.path', { + './?.lua' +}) +TEST { + { + path = 'a.lua', + content = [[ +return { + <!x!> = 1, +} +]], + }, + { + path = 'b.lua', + content = [[ +local t = require 'a' +print(t.<?x?>) + ]] + } +} + +config.set('Lua.runtime.path', { + '/home/?.lua' +}) +TEST { + { + path = '/home/a.lua', + content = [[ +return { + <!x!> = 1, +} +]], + }, + { + path = 'b.lua', + content = [[ +local t = require 'a' +print(t.<?x?>) + ]] + } +} + +config.set('Lua.runtime.pathStrict', false) +config.set('Lua.runtime.path', originRuntimePath) diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 86471936..492efe43 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') @@ -1075,3 +1072,64 @@ global G: A { } ```]] } + +TEST { + { + path = 'a.lua', + content = [[ + ---@overload fun(self, a) + function C:<?f?>(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.<?f?>(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:<?f?>(a, b) end + ]] + }, + hover = [[ +```lua +async method C:f(a: any, b: any) +``` + +--- + +```lua +async method C:f(a: any) +```]] +} |