summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/spell-check.lua
diff options
context:
space:
mode:
authorCppCXY <812125110@qq.com>2022-05-24 11:57:39 +0800
committerCppCXY <812125110@qq.com>2022-05-24 11:57:39 +0800
commitb51c930f3cca060b10ab724666c9f5265cefd517 (patch)
treebdc5296f83672c9694bc5d113c0202e126442e05 /script/core/diagnostics/spell-check.lua
parentf0f80fdf1b5c83467687541ffda36cabb8f9bd62 (diff)
downloadlua-language-server-b51c930f3cca060b10ab724666c9f5265cefd517.zip
重置代码,取消多余的提交
Diffstat (limited to 'script/core/diagnostics/spell-check.lua')
-rw-r--r--script/core/diagnostics/spell-check.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/script/core/diagnostics/spell-check.lua b/script/core/diagnostics/spell-check.lua
new file mode 100644
index 00000000..ebdb0245
--- /dev/null
+++ b/script/core/diagnostics/spell-check.lua
@@ -0,0 +1,34 @@
+local files = require 'files'
+local converter = require 'proto.converter'
+local log = require 'log'
+local spell = require 'provider.spell'
+
+
+---@async
+return function(uri, callback)
+ local text = files.getText(uri)
+ if not text then
+ return
+ end
+
+ local status, diagnosticInfos = spell.spellCheck(uri, text)
+
+ if not status then
+ if diagnosticInfos ~= nil then
+ log.error(diagnosticInfos)
+ end
+
+ return
+ end
+
+ if diagnosticInfos then
+ for _, diagnosticInfo in ipairs(diagnosticInfos) do
+ callback {
+ start = converter.unpackPosition(uri, diagnosticInfo.range.start),
+ finish = converter.unpackPosition(uri, diagnosticInfo.range["end"]),
+ message = diagnosticInfo.message,
+ data = diagnosticInfo.data
+ }
+ end
+ end
+end