summaryrefslogtreecommitdiff
path: root/tools/love-api.lua
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2022-02-08 21:57:56 +0800
committersumneko <sumneko@hotmail.com>2022-02-08 21:57:56 +0800
commit007e8637827b75d95f188df0f1c3173cabc53a8b (patch)
tree69fd9f98ba75099b97080c95001f3d6452de49d3 /tools/love-api.lua
parentee476c7f4fb29ab6cf6e77205745428c0e2a8601 (diff)
downloadlua-language-server-007e8637827b75d95f188df0f1c3173cabc53a8b.zip
fix #941
Diffstat (limited to 'tools/love-api.lua')
-rw-r--r--tools/love-api.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/love-api.lua b/tools/love-api.lua
index 030439fd..8b7ba346 100644
--- a/tools/love-api.lua
+++ b/tools/love-api.lua
@@ -88,9 +88,12 @@ local function buildDescription(desc)
end
end
-local function buildDocFunc(variant)
+local function buildDocFunc(variant, overload)
local params = {}
local returns = {}
+ if overload then
+ params[1] = ('self: %s'):format(overload)
+ end
for _, param in ipairs(variant.arguments or {}) do
if param.name == '...' then
params[#params+1] = '...'
@@ -119,12 +122,12 @@ local function buildMultiDocFunc(tp)
return table.concat(cbs, '|')
end
-local function buildFunction(func, node)
+local function buildFunction(func, node, typeName)
local text = {}
text[#text+1] = buildDescription(func.description)
for i = 2, #func.variants do
local variant = func.variants[i]
- text[#text+1] = ('---@overload %s'):format(buildDocFunc(variant))
+ text[#text+1] = ('---@overload %s'):format(buildDocFunc(variant, typeName))
end
local params = {}
for _, param in ipairs(func.variants[1].arguments or {}) do
@@ -183,7 +186,7 @@ local function buildFile(class, defs)
if not mark[func.name] then
mark[func.name] = true
text[#text+1] = ''
- text[#text+1] = buildFunction(func, tp.name .. ':')
+ text[#text+1] = buildFunction(func, tp.name .. ':', getTypeName(tp.name))
end
end
end