summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
authorCppCXY <812125110@qq.com>2023-04-26 20:50:43 +0800
committerCppCXY <812125110@qq.com>2023-04-26 20:50:43 +0800
commitf6e103f10acd4b20fd73cd7a5b9b76fa0a676810 (patch)
tree6d5958fb51aaf543b72790c0610d05a26ee01ff9 /script/core
parent19906a977c517b1e6edfd3ada60e20b2f9179e43 (diff)
downloadlua-language-server-f6e103f10acd4b20fd73cd7a5b9b76fa0a676810.zip
complete namestyle provider
Diffstat (limited to 'script/core')
-rw-r--r--script/core/diagnostics/name-style.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/script/core/diagnostics/name-style.lua b/script/core/diagnostics/name-style.lua
new file mode 100644
index 00000000..4bdb068f
--- /dev/null
+++ b/script/core/diagnostics/name-style.lua
@@ -0,0 +1,35 @@
+local files = require 'files'
+local converter = require 'proto.converter'
+local log = require 'log'
+local nameStyle = require 'provider.name-style'
+
+
+---@async
+return function (uri, callback)
+ local state = files.getState(uri)
+ if not state then
+ return
+ end
+ local text = state.originText
+
+ local status, diagnosticInfos = nameStyle.nameStyleCheck(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(state, diagnosticInfo.range.start),
+ finish = converter.unpackPosition(state, diagnosticInfo.range["end"]),
+ message = diagnosticInfo.message,
+ data = diagnosticInfo.data
+ }
+ end
+ end
+end