From 95437dacc0ecfdf7ee6c4b158fbba6dbc21aecd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 2 Nov 2021 19:44:35 +0800 Subject: update hover of async --- script/await.lua | 2 +- script/core/hover/label.lua | 6 +++++- test/hover/init.lua | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/script/await.lua b/script/await.lua index a887664a..cea5667b 100644 --- a/script/await.lua +++ b/script/await.lua @@ -25,7 +25,7 @@ local function setID(id, co, callback) end --- 设置错误处理器 ----@param errHandle function {comment = '当有错误发生时,会以错误堆栈为参数调用该函数'} +---@param errHandle function # 当有错误发生时,会以错误堆栈为参数调用该函数 function m.setErrorHandle(errHandle) m.errorHandle = errHandle end diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua index 44459bb6..803b9596 100644 --- a/script/core/hover/label.lua +++ b/script/core/hover/label.lua @@ -16,7 +16,11 @@ local function asFunction(source, oop) local arg = buildArg(source, oop) local rtn = buildReturn(source) local lines = {} - lines[1] = ('%s %s(%s)'):format(oop and 'method' or 'function', name or '', arg) + lines[1] = ('%s%s %s(%s)'):format( + vm.isAsync(source) and 'async ' or '', + oop and 'method' or 'function', + name or '', arg + ) lines[2] = rtn return table.concat(lines, '\n') end diff --git a/test/hover/init.lua b/test/hover/init.lua index 54fab5fc..404adb44 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -1724,3 +1724,11 @@ local function () end function f() -> nil ]] + +TEST [[ +---@async +local function () end +]] +[[ +async function f() +]] -- cgit v1.2.3