diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-05-28 22:56:35 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-05-28 22:56:35 +0800 |
commit | 7eaec047d708e84a7c29dd9d70e306d90fac412d (patch) | |
tree | a79282766b8a472494d5ba1f2c65e025b39a66fb /tools/love-api.lua | |
parent | 9060bc4b2c3f40145b91fc0423de31b07161b5f5 (diff) | |
download | lua-language-server-7eaec047d708e84a7c29dd9d70e306d90fac412d.zip |
update meta files for `love2d` and `lovr`
Diffstat (limited to 'tools/love-api.lua')
-rw-r--r-- | tools/love-api.lua | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/love-api.lua b/tools/love-api.lua index 38653e68..31284cd6 100644 --- a/tools/love-api.lua +++ b/tools/love-api.lua @@ -51,13 +51,16 @@ local function formatIndex(key) end local function isTableOptional(tbl) - local optional = true - for _, field in ipairs(tbl) do - if field.default == nil then - optional = nil - end - end - return optional + if not tbl then + return false + end + local optional = true + for _, field in ipairs(tbl) do + if field.default == nil then + optional = nil + end + end + return optional end local buildType @@ -156,7 +159,7 @@ local function buildFunction(func, node, typeName) for _, param in ipairs(func.variants[1].arguments or {}) do for paramName in param.name:gmatch '[%a_][%w_]*' do params[#params+1] = paramName - local optional = param.type == 'table' and isTableOptional(param.table) or (param.default ~= nil) + local optional = param.type == 'table' and isTableOptional(param.table) or (param.default ~= nil) text[#text+1] = ('---@param %s%s %s # %s'):format( paramName, optional and '?' or '', |