diff options
author | arthur <1348392749@qq.com> | 2021-10-08 15:10:23 +0800 |
---|---|---|
committer | arthur <1348392749@qq.com> | 2021-10-08 15:10:23 +0800 |
commit | 21d92f73c1236ffce188efa043f54184714cafa4 (patch) | |
tree | cac2218b65c1d20c21e173e1f57aa4c9dafa2752 /test/diagnostics/init.lua | |
parent | 842f738db5ccdce6f470a9c729287cb81796594d (diff) | |
download | lua-language-server-21d92f73c1236ffce188efa043f54184714cafa4.zip |
优化代码结构,修复了一些bug
Diffstat (limited to 'test/diagnostics/init.lua')
-rw-r--r-- | test/diagnostics/init.lua | 96 |
1 files changed, 93 insertions, 3 deletions
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua index 574d93f9..c526560a 100644 --- a/test/diagnostics/init.lua +++ b/test/diagnostics/init.lua @@ -1152,9 +1152,6 @@ TEST [[ local emit = {} ]] --- TODO -do return end - TEST [[ ---@param table table ---@param metatable table @@ -1230,3 +1227,96 @@ f(true, true) -- OK f(0, 0) -- OK ]] + +TEST [[ +---@class bird +local m = {} +setmetatable(m, {}) -- OK +]] + +TEST [[ +---@class childString: string +local s +---@param name string +local function f(name) end +f(s) +]] + +TEST [[ +---@class childString: string + +---@type string +local s +---@param name childString +local function f(name) end +f(<!s!>) +]] + +TEST [[ +---@alias searchmode '"ref"'|'"def"'|'"field"'|'"allref"'|'"alldef"'|'"allfield"' + +---@param mode searchmode +local function searchRefs(mode)end +searchRefs('ref') +]] + +TEST [[ +---@class markdown +local mt = {} +---@param language string +---@param text string|markdown +function mt:add(language, text) + if not text then + return + end +end +---@type markdown +local desc + +desc:add('md', 'hover') +]] + +---可选参数和枚举 +TEST [[ +---@param str string +---@param mode? '"left"'|'"right"' +---@return string +local function trim(str, mode) + if mode == "left" then + print(1) + end +end +trim('str', 'left') +trim('str', nil) +]] + +---不完整的函数参数定义,会跳过检查 +TEST [[ +---@param mode string +local function status(source, field, mode) + print(source, field, mode) +end +status(1, 2, 'name') +]] + + +TEST [[ +---@alias range {start: number, end: number} +---@param uri string +---@param range range +local function location(uri, range) + print(uri, range) +end +---@type range +local val = {} +location('uri', val) +]] +---TODO(arthur) +do return end + +TEST [[ +---@type file* +local f +f:read '*a' +f:read('*a') +]] |