diff options
m--------- | 3rd/EmmyLuaCodeStyle | 0 | ||||
-rw-r--r-- | script/core/diagnostics/codestyle-check.lua | 34 | ||||
-rw-r--r-- | script/proto/define.lua | 1 | ||||
-rw-r--r-- | test/crossfile/diagnostic.lua | 2 |
4 files changed, 37 insertions, 0 deletions
diff --git a/3rd/EmmyLuaCodeStyle b/3rd/EmmyLuaCodeStyle -Subproject f14bdcdd347b331bef03f6e997d0e75e7a59227 +Subproject dd3dae0661efc8096be4755b00ecb8210d5ee83 diff --git a/script/core/diagnostics/codestyle-check.lua b/script/core/diagnostics/codestyle-check.lua new file mode 100644 index 00000000..16623eca --- /dev/null +++ b/script/core/diagnostics/codestyle-check.lua @@ -0,0 +1,34 @@ +local files = require("files") +local codeFormat = require "code_format" +local converter = require("proto.converter") +local log = require("log") +local config = require("config") + + +---@async +return function(uri, callback) + local text = files.getText(uri) + if not text then + return + end + + local status, diagnosticInfos = codeFormat.diagnose_file(uri, text) + + if not status then + if diagnosticInfos ~= nil then + log.error(diagnosticInfos) + end + + return + end + + if diagnosticInfos then + for _, diagnosticInfo in pairs(diagnosticInfos) do + callback { + start = converter.unpackPosition(uri, diagnosticInfo.range.start), + finish = converter.unpackPosition(uri, diagnosticInfo.range["end"]), + message = diagnosticInfo.message + } + end + end +end diff --git a/script/proto/define.lua b/script/proto/define.lua index dbb6ba85..b4a0da0c 100644 --- a/script/proto/define.lua +++ b/script/proto/define.lua @@ -58,6 +58,7 @@ m.DiagnosticDefaultSeverity = { ['doc-field-no-class'] = 'Warning', ['duplicate-doc-field'] = 'Warning', ['unknown-diag-code'] = 'Waiting', + ['codestyle-check'] = "Warning", } ---@alias DiagnosticDefaultNeededFileStatus diff --git a/test/crossfile/diagnostic.lua b/test/crossfile/diagnostic.lua index 43028744..dd06351f 100644 --- a/test/crossfile/diagnostic.lua +++ b/test/crossfile/diagnostic.lua @@ -5,8 +5,10 @@ local config = require 'config' local platform = require 'bee.platform' local catch = require 'catch' + config.get(nil, 'Lua.diagnostics.neededFileStatus')['deprecated'] = 'Any' config.get(nil, 'Lua.diagnostics.neededFileStatus')['type-check'] = 'Any' +config.get(nil, 'Lua.diagnostics.neededFileStatus')['codestyle-check'] = 'None' rawset(_G, 'TEST', true) |