diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-14 21:10:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-14 21:10:55 +0800 |
commit | 92a5388138c2d916eaa0160df1cebfbec70a6b16 (patch) | |
tree | 64592aef3c7deac08649e511d6fed1afcfb69c59 /script/core/diagnostics/newfield-call.lua | |
parent | 834d5e70092d38c884b23fe2bc176ed06f362c69 (diff) | |
download | lua-language-server-92a5388138c2d916eaa0160df1cebfbec70a6b16.zip |
diagnostic supporting `tableexp`
Diffstat (limited to 'script/core/diagnostics/newfield-call.lua')
-rw-r--r-- | script/core/diagnostics/newfield-call.lua | 38 |
1 files changed, 22 insertions, 16 deletions
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 |