Skip to content

Commit ec20a72

Browse files
committed
stash
1 parent 87673cf commit ec20a72

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

script/core/completion.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,15 @@ local function getCallEnums(source, index)
11671167
kind = define.CompletionItemKind.EnumMember,
11681168
}
11691169
end
1170+
for _, unit in ipairs(vm.getDocTypes(doc.extends)) do
1171+
if unit.type == 'doc.type.function' then
1172+
enums[#enums+1] = {
1173+
label = guide.getDocTypeUnitName(nil, unit),
1174+
description = doc.comment,
1175+
kind = define.CompletionItemKind.Function,
1176+
}
1177+
end
1178+
end
11701179
return enums
11711180
elseif doc.type == 'doc.vararg'
11721181
and arg.type == '...' then

script/parser/guide.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,17 +2941,17 @@ local function getDocAliasExtends(status, typeUnit)
29412941
return nil
29422942
end
29432943

2944-
local function getDocTypeUnitName(status, unit)
2944+
function m.getDocTypeUnitName(status, unit)
29452945
local typeName
29462946
if unit.type == 'doc.type.name' then
29472947
typeName = unit[1]
29482948
elseif unit.type == 'doc.type.function' then
29492949
typeName = 'function'
29502950
elseif unit.type == 'doc.type.array' then
2951-
typeName = getDocTypeUnitName(status, unit.node) .. '[]'
2951+
typeName = m.getDocTypeUnitName(status, unit.node) .. '[]'
29522952
elseif unit.type == 'doc.type.generic' then
29532953
typeName = ('%s<%s, %s>'):format(
2954-
getDocTypeUnitName(status, unit.node),
2954+
m.getDocTypeUnitName(status, unit.node),
29552955
m.viewInferType(m.getDocTypeNames(status, unit.key)),
29562956
m.viewInferType(m.getDocTypeNames(status, unit.value))
29572957
)
@@ -2975,7 +2975,7 @@ function m.getDocTypeNames(status, doc)
29752975
results[#results+1] = res
29762976
end
29772977
else
2978-
local typeName = getDocTypeUnitName(status, unit)
2978+
local typeName = m.getDocTypeUnitName(status, unit)
29792979
results[#results+1] = {
29802980
type = typeName,
29812981
source = unit,

test/completion/init.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,3 +1952,18 @@ vvv$
19521952
description = EXISTS,
19531953
},
19541954
}
1955+
1956+
--TEST [[
1957+
-----@param callback fun(x: number, y: number):string
1958+
--local function f(callback)
1959+
--
1960+
--f($)
1961+
--]]
1962+
--{
1963+
-- {
1964+
-- label = 'fun(x: number, y: number):string',
1965+
-- detail = 'function',
1966+
-- kind = define.CompletionItemKind.Function,
1967+
-- description = EXISTS,
1968+
-- },
1969+
--}

0 commit comments

Comments
 (0)