diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-08-14 15:07:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-08-14 15:07:49 +0800 |
commit | 01a741f8416f074199303235eb533b8f3446e85b (patch) | |
tree | f2822f3f76500855879ba2515b097405df5a2327 /script/core | |
parent | 63edb992a363a97dfa3f02a988f5f7771d5b0b03 (diff) | |
download | lua-language-server-01a741f8416f074199303235eb533b8f3446e85b.zip |
also check `doc.type.table`
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/diagnostics/inject-field.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/script/core/diagnostics/inject-field.lua b/script/core/diagnostics/inject-field.lua index 2e1fc93c..139b8636 100644 --- a/script/core/diagnostics/inject-field.lua +++ b/script/core/diagnostics/inject-field.lua @@ -47,12 +47,28 @@ return function (uri, callback) if dnode and vm.getDefinedClass(uri, dnode) then return end + if def.type == 'doc.type.field' then + return + end + end + + local howToFix = lang.script('DIAG_INJECT_FIELD_FIX_CLASS', { + node = hname(node), + fix = '---@class', + }) + for _, ndef in ipairs(vm.getDefs(node)) do + if ndef.type == 'doc.type.table' then + howToFix = lang.script('DIAG_INJECT_FIELD_FIX_TABLE', { + fix = '[any]: any', + }) + break + end end local message = lang.script('DIAG_INJECT_FIELD', { class = vm.getInfer(node):view(uri), field = guide.getKeyName(src), - node = hname(node), + fix = howToFix, }) if src.type == 'setfield' and src.field then callback { |