summaryrefslogtreecommitdiff
path: root/test/diagnostics/init.lua
diff options
context:
space:
mode:
authoruhziel <uhziel@gmail.com>2020-12-11 16:12:56 +0800
committeruhziel <uhziel@gmail.com>2020-12-11 16:12:56 +0800
commit93cdf898f5eb8282dba0d684f926e26c6a9f7dbd (patch)
tree1479b7923cf7afdba0b792bda824165d1bfa3fd2 /test/diagnostics/init.lua
parent64e62cfefbeff094b2d168ed5d0d31d48736c89b (diff)
downloadlua-language-server-93cdf898f5eb8282dba0d684f926e26c6a9f7dbd.zip
通过不向前推断、在vm缓存doc.class查询fields来加快分析速度
Diffstat (limited to 'test/diagnostics/init.lua')
-rw-r--r--test/diagnostics/init.lua57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index 27a7e5f5..b923b8b6 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -824,6 +824,7 @@ TEST [[
local t
]]
+-- checkUndefinedField 通用
TEST [[
---@class Foo
---@field field1 integer
@@ -865,3 +866,59 @@ local mt3
function mt3:method() return 1 end
print(mt3:method())
]]
+
+-- checkUndefinedField 通过type找到class
+TEST [[
+---@class Foo
+local Foo
+function Foo:method1() end
+
+---@type Foo
+local v
+v:method1()
+<!v:method2!>() -- doc.class.name
+]]
+
+-- checkUndefinedField 通过type找到class,涉及到 class 继承版
+TEST [[
+---@class Foo
+local Foo
+function Foo:method1() end
+---@class Bar: Foo
+local Bar
+function Bar:method3() end
+
+---@type Bar
+local v
+v:method1()
+<!v:method2!>() -- doc.class.name
+v:method3()
+]]
+
+-- checkUndefinedField 类名和类变量同名,类变量被直接使用
+TEST [[
+---@class Foo
+local Foo
+function Foo:method1() end
+<!Foo:method2!>() -- doc.class
+<!Foo:method2!>() -- doc.class
+]]
+
+-- checkUndefinedField 没有@class的不检测
+TEST [[
+local Foo
+function Foo:method1()
+ return Foo:method2() -- table
+end
+]]
+
+-- checkUndefinedField 类名和类变量不同名,类变量被直接使用、使用self
+TEST [[
+---@class Foo
+local mt
+function mt:method1()
+ <!mt.method2!>() -- doc.class
+ self.method1()
+ return <!self.method2!>() -- doc.class.name
+end
+]]