diff options
author | C3pa <41503714+C3pa@users.noreply.github.com> | 2022-05-28 09:22:34 +0200 |
---|---|---|
committer | C3pa <41503714+C3pa@users.noreply.github.com> | 2022-05-28 09:22:34 +0200 |
commit | 9f546bac3dc4327650711929765981c0877c291f (patch) | |
tree | 4bf9232710a6eefdb09d92d5c3300cb1b39332d8 /tools/love-api.lua | |
parent | e069d28762467969596a66ace8b5cde34427c8a0 (diff) | |
download | lua-language-server-9f546bac3dc4327650711929765981c0877c291f.zip |
Update love-api builder
Diffstat (limited to 'tools/love-api.lua')
-rw-r--r-- | tools/love-api.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/love-api.lua b/tools/love-api.lua index 54369acb..6a0f1f01 100644 --- a/tools/love-api.lua +++ b/tools/love-api.lua @@ -50,6 +50,16 @@ local function formatIndex(key) return ('[%q]'):format(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 +end + local buildType local function buildDocTable(tbl) @@ -146,6 +156,9 @@ 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 + if param.type == 'table' then + param.default = isTableOptional(param.table) + end text[#text+1] = ('---@param %s%s %s # %s'):format( paramName, param.default == nil and '' or '?', |