diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/core/diagnostics/duplicate-index.lua | 5 | ||||
-rw-r--r-- | script/core/diagnostics/newfield-call.lua | 38 |
2 files changed, 25 insertions, 18 deletions
diff --git a/script/core/diagnostics/duplicate-index.lua b/script/core/diagnostics/duplicate-index.lua index 5d354329..d1141901 100644 --- a/script/core/diagnostics/duplicate-index.lua +++ b/script/core/diagnostics/duplicate-index.lua @@ -15,13 +15,14 @@ return function (uri, callback) local mark = {} for _, obj in ipairs(source) do if obj.type == 'tablefield' - or obj.type == 'tableindex' then + or obj.type == 'tableindex' + or obj.type == 'tableexp' then local name = noder.getID(obj) if name and name:sub(-1) ~= '*' then if not mark[name] then mark[name] = {} end - mark[name][#mark[name]+1] = obj.field or obj.index + mark[name][#mark[name]+1] = obj.field or obj.index or obj.value end end end diff --git a/script/core/diagnostics/newfield-call.lua b/script/core/diagnostics/newfield-call.lua index 2cbc13ee..27ac6fce 100644 --- a/script/core/diagnostics/newfield-call.lua +++ b/script/core/diagnostics/newfield-call.lua @@ -14,24 +14,30 @@ return function (uri, callback) 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 - if args then - 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 + if field.type ~= 'tableexp' then + goto CONTINUE + end + local call = field.value + if not call then + goto CONTINUE + end + local func = call.node + local args = call.args + if args then + local funcLine = guide.positionOf(lines, func.finish) + local argsLine = guide.positionOf(lines, args.start) + if argsLine > funcLine then + callback { + start = call.start, + finish = call.finish, + message = lang.script('DIAG_PREFIELD_CALL' + , text:sub(func.start, func.finish) + , text:sub(args.start, args.finish) + ) + } end end + ::CONTINUE:: end end) end |