summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta/template/coroutine.lua4
-rw-r--r--script/await.lua1
-rw-r--r--script/core/completion.lua4
-rw-r--r--script/filewatch.lua1
-rw-r--r--script/glob/gitignore.lua1
-rw-r--r--script/proto/proto.lua1
-rw-r--r--script/provider/provider.lua1
-rw-r--r--script/vm/getDocs.lua3
-rw-r--r--test/diagnostics/init.lua6
9 files changed, 20 insertions, 2 deletions
diff --git a/meta/template/coroutine.lua b/meta/template/coroutine.lua
index a9dd40cf..390be21b 100644
--- a/meta/template/coroutine.lua
+++ b/meta/template/coroutine.lua
@@ -5,7 +5,7 @@
coroutine = {}
---#DES 'coroutine.create'
----@param f function
+---@param f async fun(...):...
---@return thread
---@nodiscard
function coroutine.create(f) end
@@ -55,7 +55,7 @@ function coroutine.running() end
function coroutine.status(co) end
---#DES 'coroutine.wrap'
----@param f function
+---@param f async fun(...):...
---@return fun(...):...
---@nodiscard
function coroutine.wrap(f) end
diff --git a/script/await.lua b/script/await.lua
index cea5667b..d8b9ef38 100644
--- a/script/await.lua
+++ b/script/await.lua
@@ -39,6 +39,7 @@ function m.checkResult(co, ...)
end
--- 创建一个任务
+---@param callback async fun()
function m.call(callback, ...)
local co = coroutine.create(callback)
local closers = {}
diff --git a/script/core/completion.lua b/script/core/completion.lua
index b7de7578..e67ca168 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -31,6 +31,8 @@ local DiagnosticModes = {
local stackID = 0
local stacks = {}
+
+---@param callback async fun()
local function stack(callback)
stackID = stackID + 1
stacks[stackID] = callback
@@ -41,6 +43,7 @@ local function clearStack()
stacks = {}
end
+---@async
local function resolveStack(id)
local callback = stacks[id]
if not callback then
@@ -2118,6 +2121,7 @@ local function completion(uri, position, triggerCharacter)
return results
end
+---@async
local function resolve(id)
local item = resolveStack(id)
local cache = workspace.getCache 'completion'
diff --git a/script/filewatch.lua b/script/filewatch.lua
index 17a0548b..28f7376f 100644
--- a/script/filewatch.lua
+++ b/script/filewatch.lua
@@ -27,6 +27,7 @@ function m.watch(path)
end
end
+---@param callback async fun()
function m.event(callback)
m._eventList[#m._eventList+1] = callback
end
diff --git a/script/glob/gitignore.lua b/script/glob/gitignore.lua
index 73e20cbf..3f7c564f 100644
--- a/script/glob/gitignore.lua
+++ b/script/glob/gitignore.lua
@@ -163,6 +163,7 @@ function mt:getRelativePath(path)
return path
end
+---@param callback async fun()
function mt:scan(path, callback)
local files = {}
if type(callback) ~= 'function' then
diff --git a/script/proto/proto.lua b/script/proto/proto.lua
index d54c902f..66f7d810 100644
--- a/script/proto/proto.lua
+++ b/script/proto/proto.lua
@@ -22,6 +22,7 @@ function m.getMethodName(proto)
end
end
+---@param callback async fun()
function m.on(method, callback)
m.ability[method] = callback
end
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 36752d88..e7c493b4 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -489,6 +489,7 @@ proto.on('textDocument/completion', function (params) ---@async
}
end)
+---@async
proto.on('completionItem/resolve', function (item)
local core = require 'core.completion'
if not item.data then
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua
index 748d17c2..ff6e6ba3 100644
--- a/script/vm/getDocs.lua
+++ b/script/vm/getDocs.lua
@@ -257,6 +257,9 @@ function vm.isNoDiscard(value, deep)
end
local function isCalledInFunction(param)
+ if not param.ref then
+ return false
+ end
local func = guide.getParentFunction(param)
for _, ref in ipairs(param.ref) do
if ref.type == 'getlocal' then
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index e8e24141..4fcf38ab 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -1483,3 +1483,9 @@ end
return af
]]
+
+TEST [[
+local _ = type(function () ---@async
+ return nil
+end)
+]]