summaryrefslogtreecommitdiff
path: root/server-beta/src/core/diagnostics/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/core/diagnostics/init.lua')
-rw-r--r--server-beta/src/core/diagnostics/init.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/server-beta/src/core/diagnostics/init.lua b/server-beta/src/core/diagnostics/init.lua
new file mode 100644
index 00000000..69815003
--- /dev/null
+++ b/server-beta/src/core/diagnostics/init.lua
@@ -0,0 +1,29 @@
+local files = require 'files'
+local define = require 'proto.define'
+local config = require 'config'
+
+local function check(uri, name, level, results)
+ if config.config.diagnostics.disable[name] then
+ return
+ end
+ level = config.config.diagnostics.severity[name] or level
+ require('core.diagnostics.' .. name)(uri, function (result)
+ result.level = level or result.level
+ result.code = name
+ results[#results+1] = result
+ end)
+end
+
+return function (uri)
+ local ast = files.getAst(uri)
+ if not ast then
+ return nil
+ end
+ local results = {}
+
+ for name, level in pairs(define.DiagnosticDefaultSeverity) do
+ check(uri, name, level, results)
+ end
+
+ return results
+end