From 9a24fa993879985468c291eb9f1003e8b8f5b4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 14 Dec 2020 15:47:43 +0800 Subject: `undefined-field` select field only --- script/core/diagnostics/undefined-field.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'script') diff --git a/script/core/diagnostics/undefined-field.lua b/script/core/diagnostics/undefined-field.lua index 67208e35..04ae95dd 100644 --- a/script/core/diagnostics/undefined-field.lua +++ b/script/core/diagnostics/undefined-field.lua @@ -94,11 +94,19 @@ return function (uri, callback) if not fields[fieldName] then local message = lang.script('DIAG_UNDEF_FIELD', fieldName) - callback { - start = src.start, - finish = src.finish, - message = message, - } + if src.type == 'getfield' then + callback { + start = src.field.start, + finish = src.field.finish, + message = message, + } + elseif src.type == 'getmethod' then + callback { + start = src.method.start, + finish = src.method.finish, + message = message, + } + end end end guide.eachSourceType(ast.ast, 'getfield', checkUndefinedField); -- cgit v1.2.3