summaryrefslogtreecommitdiff
path: root/server-beta/src/core/diagnostics/newfield-call.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/core/diagnostics/newfield-call.lua')
-rw-r--r--server-beta/src/core/diagnostics/newfield-call.lua36
1 files changed, 34 insertions, 2 deletions
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