summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-08-22 17:08:39 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-08-22 17:08:39 +0800
commitcb16010fbb4128e2a5a31013e02b8cc4a4318be8 (patch)
tree0be2ac73f9bf987ea33fc070201d1eb238839dc3 /script
parenta5c3b64c217fb2691a23ca3b849567474b653ddf (diff)
downloadlua-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.lua16
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