diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/libs/lua53/basic.lni | 34 | ||||
-rw-r--r-- | server/src/matcher/hover.lua | 6 | ||||
-rw-r--r-- | server/src/matcher/vm.lua | 9 | ||||
-rw-r--r-- | server/test/hover/init.lua | 19 |
4 files changed, 61 insertions, 7 deletions
diff --git a/server/libs/lua53/basic.lni b/server/libs/lua53/basic.lni index 2b17eb06..3cd943f3 100644 --- a/server/libs/lua53/basic.lni +++ b/server/libs/lua53/basic.lni @@ -63,6 +63,11 @@ optional = 'self' type = 'table' [getmetatable] +[[.args]] +name = 'object' +[[.returns]] +name = 'metatable' +type = 'table' [ipairs] [[.args]] @@ -89,6 +94,35 @@ type = 'integer' default = 0 [load] +[[.args]] +name = 'chunk' +type = {'string', 'function'} +[[.args]] +name = 'chunkname' +type = 'string' +optional = 'after' +[[.args]] +name = 'mode' +type = 'string' +optional = 'after' +[[.args]] +name = 'env' +type = 'table' +optional = 'self' +[[.returns]] +type = 'function' +[[.returns]] +name = 'error_message' +type = 'string' +[[.enums]] +name = 'mode' +enum = 'b' +[[.enums]] +name = 'mode' +enum = 't' +[[.enums]] +name = 'mode' +enum = 'bt' [loadfile] diff --git a/server/src/matcher/hover.lua b/server/src/matcher/hover.lua index b997e8f8..af657225 100644 --- a/server/src/matcher/hover.lua +++ b/server/src/matcher/hover.lua @@ -40,7 +40,11 @@ local function buildLibArgs(lib, oo) if arg.name then strs[#strs+1] = ('%s: '):format(arg.name) end - strs[#strs+1] = arg.type or 'any' + if type(arg.type) == 'table' then + strs[#strs+1] = table.concat(arg.type, '/') + else + strs[#strs+1] = arg.type or 'any' + end if arg.default then strs[#strs+1] = ('(%q)'):format(arg.default) end diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 36634710..0700f640 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -486,13 +486,16 @@ function mt:inference(value, type) end end -function mt:createValue(type, source, v) +function mt:createValue(tp, source, v) + if type(tp) == 'table' then + tp = tp[1] + end local value = { - type = type, + type = tp, source = source or DefaultSource, value = v, } - local lib = library.object[type] + local lib = library.object[tp] if lib then self:getLibChild(value, lib, 'object') end diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua index 348b5c8c..870b4dc1 100644 --- a/server/test/hover/init.lua +++ b/server/test/hover/init.lua @@ -14,8 +14,8 @@ function TEST(script) assert(vm) local result = matcher.hover(vm, pos) assert(result) - expect = expect:gsub('^[\r\n]*(.-)[\r\n]*$', '%1') - result = result:gsub('```lua', ''):gsub('```', ''):gsub('^[\r\n]*(.-)[\r\n]*$', '%1') + expect = expect:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n') + result = result:gsub('```lua[\r\n]*', ''):gsub('[\r\n]*```', ''):gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n') assert(expect == result) end end @@ -155,7 +155,20 @@ local <?v?> = collectgarbage() "nil v" TEST [[ -local <!type!> +local type w2l:get_default()[<?type?>] ]] "any type" + +TEST [[ +<?load?>() +]] +[=[ +function load(chunk: string/function [, chunkname: string [, mode: string [, env: table]]]) + -> function, error_message: string + +mode: string + | "b" -- + | "t" -- + | "bt" -- +]=] |