diff options
Diffstat (limited to 'server-beta/src')
-rw-r--r-- | server-beta/src/core/diagnostics/duplicate-method.lua | 3 | ||||
-rw-r--r-- | server-beta/src/core/diagnostics/newfield-call.lua | 36 | ||||
-rw-r--r-- | server-beta/src/core/diagnostics/set-const.lua | 3 | ||||
-rw-r--r-- | server-beta/src/proto/define.lua | 2 |
4 files changed, 34 insertions, 10 deletions
diff --git a/server-beta/src/core/diagnostics/duplicate-method.lua b/server-beta/src/core/diagnostics/duplicate-method.lua deleted file mode 100644 index b3d19c21..00000000 --- a/server-beta/src/core/diagnostics/duplicate-method.lua +++ /dev/null @@ -1,3 +0,0 @@ -return function () - -end diff --git a/server-beta/src/core/diagnostics/newfield-call.lua b/server-beta/src/core/diagnostics/newfield-call.lua index b3d19c21..87ece955 100644 --- a/server-beta/src/core/diagnostics/newfield-call.lua +++ b/server-beta/src/core/diagnostics/newfield-call.lua @@ -1,3 +1,35 @@ -return function () - +local files = require 'files' +local guide = require 'parser.guide' +local lang = require 'language' + +return function (uri, callback) + local ast = files.getAst(uri) + if not ast then + return + end + + local lines = files.getLines(uri) + local text = files.getText(uri) + + guide.eachSourceType(ast.ast, 'table', function (source) + for i = 1, #source do + local field = source[i] + if field.type == 'call' then + local func = field.node + local args = field.args + local funcLine = guide.positionOf(lines, func.finish) + local argsLine = guide.positionOf(lines, args.start) + if argsLine > funcLine then + callback { + start = field.start, + finish = field.finish, + message = lang.script('DIAG_PREFIELD_CALL' + , text:sub(func.start, func.finish) + , text:sub(args.start, args.finish) + ) + } + end + end + end + end) end diff --git a/server-beta/src/core/diagnostics/set-const.lua b/server-beta/src/core/diagnostics/set-const.lua deleted file mode 100644 index b3d19c21..00000000 --- a/server-beta/src/core/diagnostics/set-const.lua +++ /dev/null @@ -1,3 +0,0 @@ -return function () - -end diff --git a/server-beta/src/proto/define.lua b/server-beta/src/proto/define.lua index 9401e9e5..6acd2348 100644 --- a/server-beta/src/proto/define.lua +++ b/server-beta/src/proto/define.lua @@ -93,11 +93,9 @@ m.DiagnosticDefaultSeverity = { ['lowercase-global'] = 'Information', ['undefined-env-child'] = 'Information', ['duplicate-index'] = 'Warning', - ['duplicate-method'] = 'Warning', ['empty-block'] = 'Hint', ['redundant-value'] = 'Hint', ['emmy-lua'] = 'Warning', - ['set-const'] = 'Error', } --- 诊断报告标签 |