summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-02 19:25:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-02 19:25:37 +0800
commit36a5c10b00160c85a8c29170b5d5de8b27b4a5c9 (patch)
treef6db7d3d69bc24fecf16f3a3439d489dc5c43bf9 /script/core
parentc16264eac3b25f6f2bce14b0504071787bd2bc54 (diff)
downloadlua-language-server-36a5c10b00160c85a8c29170b5d5de8b27b4a5c9.zip
mark async
Diffstat (limited to 'script/core')
-rw-r--r--script/core/command/autoRequire.lua2
-rw-r--r--script/core/command/jsonToLua.lua1
-rw-r--r--script/core/command/removeSpace.lua1
-rw-r--r--script/core/command/solve.lua1
-rw-r--r--script/core/completion.lua22
-rw-r--r--script/core/diagnostics/deprecated.lua2
-rw-r--r--script/core/diagnostics/init.lua1
-rw-r--r--script/core/diagnostics/redundant-value.lua2
-rw-r--r--script/core/diagnostics/type-check.lua2
-rw-r--r--script/core/diagnostics/undefined-field.lua1
-rw-r--r--script/core/diagnostics/undefined-global.lua2
-rw-r--r--script/core/diagnostics/unused-function.lua3
-rw-r--r--script/core/document-symbol.lua5
-rw-r--r--script/core/folding.lua3
-rw-r--r--script/core/hint.lua8
-rw-r--r--script/core/hover/init.lua3
-rw-r--r--script/core/hover/label.lua5
-rw-r--r--script/core/hover/table.lua1
-rw-r--r--script/core/semantic-tokens.lua2
-rw-r--r--script/core/signature.lua3
-rw-r--r--script/core/workspace-symbol.lua1
21 files changed, 52 insertions, 19 deletions
diff --git a/script/core/command/autoRequire.lua b/script/core/command/autoRequire.lua
index ca8826d7..30bd13a1 100644
--- a/script/core/command/autoRequire.lua
+++ b/script/core/command/autoRequire.lua
@@ -63,6 +63,7 @@ local function findInsertRow(uri)
return row or 0, fmt
end
+---@async
local function askAutoRequire(visiblePaths)
local selects = {}
local nameMap = {}
@@ -125,6 +126,7 @@ local function applyAutoRequire(uri, row, name, result, fmt)
})
end
+---@async
return function (data)
local uri = data.uri
local target = data.target
diff --git a/script/core/command/jsonToLua.lua b/script/core/command/jsonToLua.lua
index 6aecee2c..d29ad608 100644
--- a/script/core/command/jsonToLua.lua
+++ b/script/core/command/jsonToLua.lua
@@ -7,6 +7,7 @@ local lang = require 'language'
local converter = require 'proto.converter'
local guide = require 'parser.guide'
+---@async
return function (data)
local state = files.getState(data.uri)
local text = files.getText(data.uri)
diff --git a/script/core/command/removeSpace.lua b/script/core/command/removeSpace.lua
index 3021d4a4..aa565f7f 100644
--- a/script/core/command/removeSpace.lua
+++ b/script/core/command/removeSpace.lua
@@ -12,6 +12,7 @@ local function isInString(ast, offset)
end) or false
end
+---@async
return function (data)
local uri = data.uri
local text = files.getText(uri)
diff --git a/script/core/command/solve.lua b/script/core/command/solve.lua
index 9428d065..19148092 100644
--- a/script/core/command/solve.lua
+++ b/script/core/command/solve.lua
@@ -27,6 +27,7 @@ local literalMap = {
['table'] = true,
}
+---@async
return function (data)
local uri = data.uri
local text = files.getText(uri)
diff --git a/script/core/completion.lua b/script/core/completion.lua
index afa54221..e30c9c91 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -203,6 +203,7 @@ local function getSnip(source)
end
end
+---@async
local function buildDesc(source)
if source.type == 'dummy' then
return
@@ -229,7 +230,7 @@ local function buildFunction(results, source, value, oop, data)
title = 'trigger signature',
command = 'editor.action.triggerParameterHints',
}
- snipData.id = stack(function ()
+ snipData.id = stack(function () ---@async
return {
detail = buildDetail(source),
description = buildDesc(source),
@@ -292,7 +293,7 @@ local function checkLocal(state, word, position, results)
match = name,
insertText = name,
kind = define.CompletionItemKind.Function,
- id = stack(function ()
+ id = stack(function () ---@async
return {
detail = buildDetail(source),
description = buildDesc(source),
@@ -305,7 +306,7 @@ local function checkLocal(state, word, position, results)
results[#results+1] = {
label = name,
kind = define.CompletionItemKind.Variable,
- id = stack(function ()
+ id = stack(function () ---@async
return {
detail = buildDetail(source),
description = buildDesc(source),
@@ -370,7 +371,7 @@ local function checkModule(state, word, position, results)
},
},
},
- id = stack(function ()
+ id = stack(function () ---@async
local md = markdown()
md:add('md', lang.script('COMPLETION_IMPORT_FROM', ('[%s](%s)'):format(
workspace.getRelativePath(uri),
@@ -471,7 +472,7 @@ local function checkFieldThen(name, src, word, startPos, position, parent, oop,
match = name:match '^[^(]+',
insertText = name:match '^[^(]+',
deprecated = vm.isDeprecated(src) or nil,
- id = stack(function ()
+ id = stack(function () ---@async
return {
detail = buildDetail(src),
description = buildDesc(src),
@@ -504,7 +505,7 @@ local function checkFieldThen(name, src, word, startPos, position, parent, oop,
deprecated = vm.isDeprecated(src) or nil,
textEdit = textEdit,
additionalTextEdits = additionalTextEdits,
- id = stack(function ()
+ id = stack(function () ---@async
return {
detail = buildDetail(src),
description = buildDesc(src),
@@ -513,6 +514,7 @@ local function checkFieldThen(name, src, word, startPos, position, parent, oop,
}
end
+---@async
local function checkFieldOfRefs(refs, state, word, startPos, position, parent, oop, results, locals, isGlobal)
local fields = {}
local funcs = {}
@@ -577,12 +579,14 @@ local function checkFieldOfRefs(refs, state, word, startPos, position, parent, o
end
end
+---@async
local function checkGlobal(state, word, startPos, position, parent, oop, results)
local locals = guide.getVisibleLocals(state.ast, position)
local globals = vm.getGlobalSets '*'
checkFieldOfRefs(globals, state, word, startPos, position, parent, oop, results, locals, 'global')
end
+---@async
local function checkField(state, word, start, position, parent, oop, results)
if parent.tag == '_ENV' or parent.special == '_G' then
local globals = vm.getGlobalSets '*'
@@ -1204,6 +1208,7 @@ local function trySpecial(state, text, position, results)
checkEqualEnum(state, text, position, results)
end
+---@async
local function tryIndex(state, text, position, results)
local parent, oop = findParentInStringIndex(state, text, position)
if not parent then
@@ -1213,6 +1218,7 @@ local function tryIndex(state, text, position, results)
checkField(state, word, position, position, parent, oop, results)
end
+---@async
local function tryWord(state, text, position, triggerCharacter, results)
local offset = guide.positionToOffset(state, position)
local finish = lookBackward.skipSpace(text, offset)
@@ -1268,6 +1274,7 @@ local function tryWord(state, text, position, triggerCharacter, results)
end
end
+---@async
local function trySymbol(state, text, position, results)
local symbol, start = lookBackward.findSymbol(text, guide.positionToOffset(state, position))
if not symbol then
@@ -1486,7 +1493,7 @@ local function checkTableLiteralField(state, text, position, tbl, fields, result
label = guide.getKeyName(field),
kind = define.CompletionItemKind.Property,
insertText = ('%s = $0'):format(guide.getKeyName(field)),
- id = stack(function ()
+ id = stack(function () ---@async
return {
detail = buildDetail(field),
description = buildDesc(field),
@@ -2061,6 +2068,7 @@ local function clearCache()
cache.results = nil
end
+---@async
local function completion(uri, position, triggerCharacter)
tracy.ZoneBeginN 'completion cache'
local results = getCache(uri, position)
diff --git a/script/core/diagnostics/deprecated.lua b/script/core/diagnostics/deprecated.lua
index 0aeac9e9..7cd9e00f 100644
--- a/script/core/diagnostics/deprecated.lua
+++ b/script/core/diagnostics/deprecated.lua
@@ -16,7 +16,7 @@ return function (uri, callback)
local cache = {}
- guide.eachSourceTypes(ast.ast, types, function (src)
+ guide.eachSourceTypes(ast.ast, types, function (src) ---@async
if src.type == 'getglobal' then
local key = src[1]
if not key then
diff --git a/script/core/diagnostics/init.lua b/script/core/diagnostics/init.lua
index 63a1bcf0..4950900b 100644
--- a/script/core/diagnostics/init.lua
+++ b/script/core/diagnostics/init.lua
@@ -64,6 +64,7 @@ local function check(uri, name, results)
end
end
+---@async
return function (uri, response)
local ast = files.getState(uri)
if not ast then
diff --git a/script/core/diagnostics/redundant-value.lua b/script/core/diagnostics/redundant-value.lua
index 4c913330..edead570 100644
--- a/script/core/diagnostics/redundant-value.lua
+++ b/script/core/diagnostics/redundant-value.lua
@@ -10,7 +10,7 @@ return function (uri, callback)
return
end
- guide.eachSource(state.ast, function (src)
+ guide.eachSource(state.ast, function (src) ---@async
await.delay()
if src.redundant then
callback {
diff --git a/script/core/diagnostics/type-check.lua b/script/core/diagnostics/type-check.lua
index bbed30d8..3fa5050c 100644
--- a/script/core/diagnostics/type-check.lua
+++ b/script/core/diagnostics/type-check.lua
@@ -417,7 +417,7 @@ return function (uri, callback)
if not ast then
return
end
- guide.eachSourceType(ast.ast, 'call', function (source)
+ guide.eachSourceType(ast.ast, 'call', function (source) ---@async
if not source.args then
return
end
diff --git a/script/core/diagnostics/undefined-field.lua b/script/core/diagnostics/undefined-field.lua
index ff02728f..66b1f8c5 100644
--- a/script/core/diagnostics/undefined-field.lua
+++ b/script/core/diagnostics/undefined-field.lua
@@ -26,6 +26,7 @@ return function (uri, callback)
local cache = {}
+ ---@async
local function checkUndefinedField(src)
local id = noder.getID(src)
if not id then
diff --git a/script/core/diagnostics/undefined-global.lua b/script/core/diagnostics/undefined-global.lua
index 14754c16..640f521b 100644
--- a/script/core/diagnostics/undefined-global.lua
+++ b/script/core/diagnostics/undefined-global.lua
@@ -21,7 +21,7 @@ return function (uri, callback)
end
-- 遍历全局变量,检查所有没有 set 模式的全局变量
- guide.eachSourceType(ast.ast, 'getglobal', function (src)
+ guide.eachSourceType(ast.ast, 'getglobal', function (src) ---@async
local key = src[1]
if not key then
return
diff --git a/script/core/diagnostics/unused-function.lua b/script/core/diagnostics/unused-function.lua
index 8f6ccaac..ada4a23d 100644
--- a/script/core/diagnostics/unused-function.lua
+++ b/script/core/diagnostics/unused-function.lua
@@ -25,6 +25,7 @@ return function (uri, callback)
end
local cache = {}
+ ---@async
local function checkFunction(source)
if cache[source] ~= nil then
return cache[source]
@@ -81,7 +82,7 @@ return function (uri, callback)
end
-- 只检查局部函数
- guide.eachSourceType(ast.ast, 'function', function (source)
+ guide.eachSourceType(ast.ast, 'function', function (source) ---@async
checkFunction(source)
end)
end
diff --git a/script/core/document-symbol.lua b/script/core/document-symbol.lua
index cfabedab..00299867 100644
--- a/script/core/document-symbol.lua
+++ b/script/core/document-symbol.lua
@@ -219,6 +219,7 @@ local function buildAnonymousFunction(source, text, used, symbols)
}
end
+---@async
local function buildSource(source, text, used, symbols)
if source.type == 'local'
or source.type == 'setlocal'
@@ -243,7 +244,7 @@ local function makeSymbol(uri)
local symbols = {}
local used = {}
- guide.eachSource(ast.ast, function (source)
+ guide.eachSource(ast.ast, function (source) ---@async
buildSource(source, text, used, symbols)
end)
@@ -279,6 +280,7 @@ local function packChild(symbols)
return root
end
+---@async
local function packSymbols(symbols)
await.delay()
table.sort(symbols, function (a, b)
@@ -291,6 +293,7 @@ local function packSymbols(symbols)
return packChild(symbols)
end
+---@async
return function (uri)
local symbols = makeSymbol(uri)
if not symbols then
diff --git a/script/core/folding.lua b/script/core/folding.lua
index bd3ba5f3..2cf06d46 100644
--- a/script/core/folding.lua
+++ b/script/core/folding.lua
@@ -145,6 +145,7 @@ local Care = {
end,
}
+---@async
return function (uri)
local state = files.getState(uri)
local text = files.getText(uri)
@@ -154,7 +155,7 @@ return function (uri)
local regions = {}
local status = {}
- guide.eachSource(state.ast, function (source)
+ guide.eachSource(state.ast, function (source) ---@async
local tp = source.type
if Care[tp] then
await.delay()
diff --git a/script/core/hint.lua b/script/core/hint.lua
index 11559785..e094fc51 100644
--- a/script/core/hint.lua
+++ b/script/core/hint.lua
@@ -12,7 +12,7 @@ local function typeHint(uri, results, start, finish)
return
end
local mark = {}
- guide.eachSourceBetween(state.ast, start, finish, function (source)
+ guide.eachSourceBetween(state.ast, start, finish, function (source) ---@async
if source.type ~= 'local'
and source.type ~= 'setglobal'
and source.type ~= 'tablefield'
@@ -106,7 +106,7 @@ local function paramName(uri, results, start, finish)
return
end
local mark = {}
- guide.eachSourceBetween(state.ast, start, finish, function (source)
+ guide.eachSourceBetween(state.ast, start, finish, function (source) ---@async
if source.type ~= 'call' then
return
end
@@ -167,7 +167,7 @@ local function awaitHint(uri, results, start, finish)
if not state then
return
end
- guide.eachSourceBetween(state.ast, start, finish, function (source)
+ guide.eachSourceBetween(state.ast, start, finish, function (source) ---@async
if source.type ~= 'call' then
return
end
@@ -188,7 +188,7 @@ end
return function (uri, start, finish)
local results = {}
typeHint(uri, results, start, finish)
- paramName(uri, results, start, finish)
awaitHint(uri, results, start, finish)
+ paramName(uri, results, start, finish)
return results
end
diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua
index 784ef75d..f0160ab5 100644
--- a/script/core/hover/init.lua
+++ b/script/core/hover/init.lua
@@ -7,12 +7,14 @@ local findSource = require 'core.find-source'
local markdown = require 'provider.markdown'
local infer = require 'core.infer'
+---@async
local function getHover(source)
local md = markdown()
local defMark = {}
local labelMark = {}
local descMark = {}
+ ---@async
local function addHover(def, checkLable)
if defMark[def] then
return
@@ -74,6 +76,7 @@ local accept = {
['doc.module'] = true,
}
+---@async
local function getHoverByUri(uri, position)
local ast = files.getState(uri)
if not ast then
diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua
index 8906d54d..44459bb6 100644
--- a/script/core/hover/label.lua
+++ b/script/core/hover/label.lua
@@ -44,6 +44,7 @@ local function asDocTypeName(source)
end
end
+---@async
local function asValue(source, title)
local name = buildName(source, false) or ''
local type = infer.searchAndViewInfers(source)
@@ -76,10 +77,12 @@ local function asValue(source, title)
return table.concat(pack, ' ')
end
+---@async
local function asLocal(source)
return asValue(source, 'local')
end
+---@async
local function asGlobal(source)
return asValue(source, 'global')
end
@@ -111,6 +114,7 @@ local function isGlobalField(source)
end
end
+---@async
local function asField(source)
if isGlobalField(source) then
return asGlobal(source)
@@ -175,6 +179,7 @@ local function asNumber(source)
return formatNumber(num)
end
+---@async
return function (source, oop)
if source.type == 'function' then
return asFunction(source, oop)
diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua
index 68a04b40..285d5c02 100644
--- a/script/core/hover/table.lua
+++ b/script/core/hover/table.lua
@@ -134,6 +134,7 @@ local function getOptionalMap(fields)
return optionals
end
+---@async
return function (source)
local maxFields = config.get 'Lua.hover.previewFields'
if maxFields <= 0 then
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index dc0649d1..aef28aa6 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -381,7 +381,7 @@ return function (uri, start, finish)
end
local results = {}
- guide.eachSourceBetween(state.ast, start, finish, function (source)
+ guide.eachSourceBetween(state.ast, start, finish, function (source) ---@async
local method = Care[source.type]
if not method then
return
diff --git a/script/core/signature.lua b/script/core/signature.lua
index 007a3787..57483718 100644
--- a/script/core/signature.lua
+++ b/script/core/signature.lua
@@ -39,6 +39,7 @@ local function findNearCall(uri, ast, pos)
return nearCall
end
+---@async
local function makeOneSignature(source, oop, index)
local label = hoverLabel(source, oop)
-- 去掉返回值
@@ -77,6 +78,7 @@ local function makeOneSignature(source, oop, index)
}
end
+---@async
local function makeSignatures(text, call, pos)
local node = call.node
local oop = node.type == 'method'
@@ -136,6 +138,7 @@ local function makeSignatures(text, call, pos)
return signs
end
+---@async
return function (uri, pos)
local state = files.getState(uri)
if not state then
diff --git a/script/core/workspace-symbol.lua b/script/core/workspace-symbol.lua
index 265a8d92..5fb4a741 100644
--- a/script/core/workspace-symbol.lua
+++ b/script/core/workspace-symbol.lua
@@ -57,6 +57,7 @@ local function searchFile(uri, key, results)
end)
end
+---@async
return function (key)
local results = {}