diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-20 17:40:38 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-20 17:40:38 +0800 |
commit | 98dc89fb24baa919c701313c8546cd4a06c643b9 (patch) | |
tree | 159dc54ae08a05f98c36183ab4c5055eb3a4a1a0 /tools/love-api.lua | |
parent | bd51baa6d764293a83d4e955b533e55b57e8e147 (diff) | |
download | lua-language-server-98dc89fb24baa919c701313c8546cd4a06c643b9.zip |
update
Diffstat (limited to 'tools/love-api.lua')
-rw-r--r-- | tools/love-api.lua | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tools/love-api.lua b/tools/love-api.lua index 5aec88e0..e4227d65 100644 --- a/tools/love-api.lua +++ b/tools/love-api.lua @@ -26,15 +26,19 @@ local knownTypes = { ['light userdata'] = 'lightuserdata' } -local function getTypeName(name) - if knownTypes[name] then - return knownTypes[name] +local function getTypeName(names) + local types = {} + for name in names:gmatch '[%a_][%w_]+' do + if name ~= 'or' then + types[#types+1] = knownTypes[name] or ('love.' .. name) + end end - return 'love.' .. name + return table.concat(types, '|') end local function buildType(param) if param.table then + -- TODO getTypeName(param.type) end return getTypeName(param.type) @@ -103,15 +107,20 @@ local function buildFile(class, defs) end for _, tp in ipairs(defs.types or {}) do + local mark = {} text[#text+1] = '' text[#text+1] = ('---@class %s%s'):format(getTypeName(tp.name), buildSuper(tp)) text[#text+1] = ('local %s = {}'):format(tp.name) for _, func in ipairs(tp.functions or {}) do - text[#text+1] = '' - text[#text+1] = buildFunction(class, func, tp.name .. ':') + if not mark[func.name] then + mark[func.name] = true + text[#text+1] = '' + text[#text+1] = buildFunction(class, func, tp.name .. ':') + end end end + -- TODO for _, tp in ipairs(defs.callbacks or {}) do text[#text+1] = '' text[#text+1] = ('---@type %s'):format(getTypeName(tp.name)) |