diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-08-22 17:08:39 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-08-22 17:08:39 +0800 |
commit | cb16010fbb4128e2a5a31013e02b8cc4a4318be8 (patch) | |
tree | 0be2ac73f9bf987ea33fc070201d1eb238839dc3 /script | |
parent | a5c3b64c217fb2691a23ca3b849567474b653ddf (diff) | |
download | lua-language-server-cb16010fbb4128e2a5a31013e02b8cc4a4318be8.zip |
fix wrong `missing-fields` with union types
fix #2252
Diffstat (limited to 'script')
-rw-r--r-- | script/core/diagnostics/missing-fields.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/script/core/diagnostics/missing-fields.lua b/script/core/diagnostics/missing-fields.lua index 6e02f638..210920fd 100644 --- a/script/core/diagnostics/missing-fields.lua +++ b/script/core/diagnostics/missing-fields.lua @@ -27,6 +27,7 @@ return function (uri, callback) return end end + local warnings = {} for _, def in ipairs(defs) do if def.type == 'doc.class' then if not def.fields then @@ -67,12 +68,17 @@ return function (uri, callback) return end - callback { - start = src.start, - finish = src.finish, - message = lang.script('DIAG_MISSING_FIELDS', table.concat(missedKeys, ', ')), - } + warnings[#warnings+1] = lang.script('DIAG_MISSING_FIELDS', def.class[1], table.concat(missedKeys, ', ')) end end + + if #warnings == 0 then + return + end + callback { + start = src.start, + finish = src.finish, + message = table.concat(warnings, '\n') + } end) end |