diff options
-rw-r--r-- | script-beta/core/hover/label.lua | 2 | ||||
-rw-r--r-- | script-beta/core/hover/name.lua | 21 | ||||
-rw-r--r-- | test-beta/hover/init.lua | 15 |
3 files changed, 34 insertions, 4 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua index 7533d3f1..67faefe6 100644 --- a/script-beta/core/hover/label.lua +++ b/script-beta/core/hover/label.lua @@ -20,7 +20,7 @@ local function asFunction(source, oop) end local function asDocFunction(source) - local name = '' + local name = buildName(source) local arg = buildArg(source) local rtn = buildReturn(source) local lines = {} diff --git a/script-beta/core/hover/name.lua b/script-beta/core/hover/name.lua index a1c40771..c30cf554 100644 --- a/script-beta/core/hover/name.lua +++ b/script-beta/core/hover/name.lua @@ -1,6 +1,8 @@ local guide = require 'parser.guide' local vm = require 'vm' +local buildName + local function asLocal(source) local name = guide.getName(source) if not source.attrs then @@ -67,7 +69,21 @@ local function asLibrary(source, oop) end end -local function buildName(source, oop) +local function asDocFunction(source) + local doc = guide.getParentType(source, 'doc.type') + if not doc or not doc.bindSources then + return '' + end + for _, src in ipairs(doc.bindSources) do + local name = buildName(src) + if name ~= '' then + return name + end + end + return '' +end + +function buildName(source, oop) if oop == nil then oop = source.type == 'setmethod' or source.type == 'getmethod' @@ -97,6 +113,9 @@ local function buildName(source, oop) if source.type == 'tablefield' then return asTableField(source) or '' end + if source.type == 'doc.type.function' then + return asDocFunction(source) + end local parent = source.parent if parent then return buildName(parent, oop) diff --git a/test-beta/hover/init.lua b/test-beta/hover/init.lua index fa1edfa3..471ad2ce 100644 --- a/test-beta/hover/init.lua +++ b/test-beta/hover/init.lua @@ -1130,7 +1130,7 @@ TEST [[ local <?f?> ]] [[ -function (x: number, y: number) +function f(x: number, y: number) -> boolean ]] @@ -1159,7 +1159,7 @@ local t = {f = f} t:<?f?>() ]] [[ -function (a: any, b: any) +function f(a: any, b: any) ]] TEST [[ @@ -1198,6 +1198,17 @@ local <?x?> = f() local x: integer ]] +TEST [[ +---@overload fun(y: boolean) +---@param x number +---@param y boolean +---@param z string +function <?f?>(x, y, z) end +]] +[=[ +function f(x: number, y: boolean, z: string) +]=] + do return end TEST [[ ---@param x number {optional = 'after'} |