From fb5ce900c0f09f5de2e3d8251da6bde09d4a1c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 5 Nov 2019 21:55:17 +0800 Subject: =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=8A=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/core/diagnostics/init.lua | 2 +- .../src/core/diagnostics/redundant-value.lua | 24 +++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'server-beta/src/core') diff --git a/server-beta/src/core/diagnostics/init.lua b/server-beta/src/core/diagnostics/init.lua index 69815003..8b6167cc 100644 --- a/server-beta/src/core/diagnostics/init.lua +++ b/server-beta/src/core/diagnostics/init.lua @@ -11,7 +11,7 @@ local function check(uri, name, level, results) result.level = level or result.level result.code = name results[#results+1] = result - end) + end, name) end return function (uri) diff --git a/server-beta/src/core/diagnostics/redundant-value.lua b/server-beta/src/core/diagnostics/redundant-value.lua index 71749f56..be483448 100644 --- a/server-beta/src/core/diagnostics/redundant-value.lua +++ b/server-beta/src/core/diagnostics/redundant-value.lua @@ -1,14 +1,24 @@ -local files = require 'files' -local guide = require 'parser.guide' +local files = require 'files' +local define = require 'proto.define' +local lang = require 'language' -local function check(source) - -end - -return function (uri, callback) +return function (uri, callback, code) local ast = files.getAst(uri) if not ast then return end + local diags = ast.diags[code] + if not diags then + return + end + + for _, info in ipairs(diags) do + callback { + start = info.start, + finish = info.finish, + tags = { define.DiagnosticTag.Unnecessary }, + message = lang.script('DIAG_OVER_MAX_VALUES', info.max, info.passed) + } + end end -- cgit v1.2.3