summaryrefslogtreecommitdiff
path: root/test/definition
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-20 17:25:07 +0800
committerGitHub <noreply@github.com>2021-01-20 17:25:07 +0800
commit924aa359e0dd426013dff07df9d8be8cc2d95818 (patch)
treeb44c30f65b1e94f83aedb0579257243ace89f4eb /test/definition
parent2fac2371d904d03a46092602ece92dceb22844e3 (diff)
parent217aa4e586b1786bc6b82828279b745a29290f4d (diff)
downloadlua-language-server-924aa359e0dd426013dff07df9d8be8cc2d95818.zip
Merge pull request #340 from uhziel/doc-type-table
添加对 EmmyLua table type 的支持
Diffstat (limited to 'test/definition')
-rw-r--r--test/definition/luadoc.lua88
1 files changed, 88 insertions, 0 deletions
diff --git a/test/definition/luadoc.lua b/test/definition/luadoc.lua
index 1f3dae00..5315b5fd 100644
--- a/test/definition/luadoc.lua
+++ b/test/definition/luadoc.lua
@@ -253,3 +253,91 @@ function Generic(arg1) print(arg1) end
local v1 = Generic("Foo")
print(v1.<?bar1?>)
]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:<!bar1!>() end
+
+---@type table<number, Foo>
+local v1
+print(v1[1].<?bar1?>)
+]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:<!bar1!>() end
+
+---@class Foo2
+local Foo2 = {}
+function Foo2:bar1() end
+
+---@type Foo2<number, Foo>
+local v1
+print(v1[1].<?bar1?>)
+]]
+
+--TODO 得扩展 simple 的信息才能识别这种情况了
+--TEST [[
+-----@class Foo
+--local Foo = {}
+--function Foo:bar1() end
+--
+-----@class Foo2
+--local Foo2 = {}
+--function Foo2:<!bar1!>() end
+--
+-----@type Foo2<number, Foo>
+--local v1
+--print(v1.<?bar1?>)
+--]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:<!bar1!>() end
+
+---@type table<number, Foo>
+local v1
+local ipairs = ipairs
+for i, v in ipairs(v1) do
+ print(v.<?bar1?>)
+end
+]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:<!bar1!>() end
+
+---@type table<Foo, Foo>
+local v1
+for k, v in pairs(v1) do
+ print(k.<?bar1?>)
+ print(v.bar1)
+end
+]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:<!bar1!>() end
+
+---@type table<number, table<number, Foo>>
+local v1
+for i, v in ipairs(v1) do
+ local v2 = v[1]
+ print(v2.<?bar1?>)
+end
+]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:<!bar1!>() end
+
+---@type table<number, table<number, Foo>>
+local v1
+print(v1[1][1].<?bar1?>)
+]]