diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-11-03 16:15:45 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-11-03 16:15:45 +0800 |
commit | 5cd171f682ec7f80459741c381a7ca52c1ea1aaf (patch) | |
tree | 7ae741641ca66e51ca66fa109d39274ae187e065 /script/core | |
parent | f1ced65b41bd764c9656a9523ddfd3d43aa2cfb1 (diff) | |
download | lua-language-server-5cd171f682ec7f80459741c381a7ca52c1ea1aaf.zip |
check await cross linked callback
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/diagnostics/await-in-sync.lua | 15 | ||||
-rw-r--r-- | script/core/hint.lua | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/script/core/diagnostics/await-in-sync.lua b/script/core/diagnostics/await-in-sync.lua index 5fb6467d..dffb994d 100644 --- a/script/core/diagnostics/await-in-sync.lua +++ b/script/core/diagnostics/await-in-sync.lua @@ -2,6 +2,7 @@ local files = require 'files' local guide = require 'parser.guide' local vm = require 'vm' local lang = require 'language' +local await = require 'await' return function (uri, callback) local state = files.getState(uri) @@ -9,18 +10,20 @@ return function (uri, callback) return end + ---@async guide.eachSourceType(state.ast, 'call', function (source) local currentFunc = guide.getParentFunction(source) if currentFunc and vm.isAsync(currentFunc) then return end - if not vm.isAsync(source.node, true) then + await.delay() + if vm.isAsyncCall(source) then + callback { + start = source.node.start, + finish = source.node.finish, + message = lang.script('DIAG_AWAIT_IN_SYNC'), + } return end - callback { - start = source.node.start, - finish = source.node.finish, - message = lang.script('DIAG_AWAIT_IN_SYNC'), - } end) end diff --git a/script/core/hint.lua b/script/core/hint.lua index e094fc51..e0f5ad8d 100644 --- a/script/core/hint.lua +++ b/script/core/hint.lua @@ -173,7 +173,7 @@ local function awaitHint(uri, results, start, finish) end await.delay() local node = source.node - if not vm.isAsync(node, true) then + if not vm.isAsyncCall(source) then return end results[#results+1] = { |