summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/await-in-sync.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-02 17:59:54 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-02 17:59:54 +0800
commitc16264eac3b25f6f2bce14b0504071787bd2bc54 (patch)
tree25a76c376b0bcb244e1281ff89afd5aa55600615 /script/core/diagnostics/await-in-sync.lua
parenta1fc6ac2f84804d3dbbde2ce5df02907f496ce7f (diff)
downloadlua-language-server-c16264eac3b25f6f2bce14b0504071787bd2bc54.zip
#687 await-in-sync
Diffstat (limited to 'script/core/diagnostics/await-in-sync.lua')
-rw-r--r--script/core/diagnostics/await-in-sync.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/script/core/diagnostics/await-in-sync.lua b/script/core/diagnostics/await-in-sync.lua
new file mode 100644
index 00000000..5fb6467d
--- /dev/null
+++ b/script/core/diagnostics/await-in-sync.lua
@@ -0,0 +1,26 @@
+local files = require 'files'
+local guide = require 'parser.guide'
+local vm = require 'vm'
+local lang = require 'language'
+
+return function (uri, callback)
+ local state = files.getState(uri)
+ if not state then
+ return
+ end
+
+ 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
+ return
+ end
+ callback {
+ start = source.node.start,
+ finish = source.node.finish,
+ message = lang.script('DIAG_AWAIT_IN_SYNC'),
+ }
+ end)
+end