diff options
author | Lei Zhu <uhziel@gmail.com> | 2021-01-04 12:01:21 +0800 |
---|---|---|
committer | Lei Zhu <uhziel@gmail.com> | 2021-01-04 12:01:21 +0800 |
commit | 573db3376fa2972cb7d9af0fa560d4e0395ce191 (patch) | |
tree | 6081c7fcf77b6e5ae85883d9014a364c5b649da8 /test/definition/luadoc.lua | |
parent | 42f9c7d02d6062ce7216abc1489f7a48761cd574 (diff) | |
download | lua-language-server-573db3376fa2972cb7d9af0fa560d4e0395ce191.zip |
@type table 支持 for pairs()、ipairs()
Diffstat (limited to 'test/definition/luadoc.lua')
-rw-r--r-- | test/definition/luadoc.lua | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/definition/luadoc.lua b/test/definition/luadoc.lua index 469c790d..3a6ff15d 100644 --- a/test/definition/luadoc.lua +++ b/test/definition/luadoc.lua @@ -263,3 +263,57 @@ function Foo:<!bar1!>() end 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 +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 +]] |