diff --git a/crates/analysis/src/actions.rs b/crates/analysis/src/actions.rs index ff19023..ee2867c 100644 --- a/crates/analysis/src/actions.rs +++ b/crates/analysis/src/actions.rs @@ -7,7 +7,7 @@ use zerosyntax_schema::{RefKind, ValueType}; use zerosyntax_syntax::ast::{Field, Module}; use zerosyntax_syntax::{Parse, SyntaxErrorKind, SyntaxKind, SyntaxNode, SyntaxToken}; -use crate::diagnostics::{pragma_rest, pragma_words, Diagnostic, Severity}; +use crate::diagnostics::{pragma_rest, pragma_words, Diagnostic}; use crate::model::scope_schema; use crate::{nav, Analyzer, Span, WorkspaceIndex}; @@ -196,12 +196,8 @@ fn diagnostic_fixes( } _ => {} } - // Suppress pragma: warnings and hints only; never errors, never the - // misspelled-suppression hint (suppressing it is self-defeating). - if d.severity != Severity::Error - && d.code != "unknown-suppression" - && suppress_seen.insert(d.code) - { + // Suppressing the misspelled-suppression hint is self-defeating. + if d.code != "unknown-suppression" && suppress_seen.insert(d.code) { suppress_fix(parse, text, d.code, out); } } @@ -422,7 +418,7 @@ fn stub_keyword<'a>(analyzer: &'a Analyzer, kind: RefKind) -> Option<&'a str> { } /// Offer to add `; zerosyntax-disable: ` at the top of the file (or -/// append to an existing pragma line) for warning/hint diagnostics. +/// append to an existing pragma line) for a diagnostic. fn suppress_fix(parse: &Parse, text: &str, code: &'static str, out: &mut Vec) { let root = parse.syntax(); let mut first_pragma: Option<(u32, bool)> = None; // (insert offset, has_any_codes) @@ -916,17 +912,14 @@ mod tests { } #[test] - fn suppress_fix_severity_and_dedupe_rules() { - // bad-bool is Error severity → no Suppress action. + fn suppress_fix_errors_and_dedupes() { + // Error diagnostics get the same Suppress action as warnings. let src_err = "Weapon W\n ScaleWeaponSpeed = Maybe\nEnd\n"; let fx_err = all_fixes(src_err); let has_suppress_for_error = fx_err .iter() .any(|f| f.title.contains("Suppress") && f.title.contains("bad-bool")); - assert!( - !has_suppress_for_error, - "errors must not get suppress: {fx_err:?}" - ); + assert!(has_suppress_for_error, "error missing suppress: {fx_err:?}"); // Two unresolved references with the same code → only one Suppress action. let src_dup = "Weapon W\n FireFX = NoSuchFX\n FireFX = NoSuchFX2\nEnd\n"; diff --git a/crates/analysis/tests/spec/QuickfixSuppress.ini b/crates/analysis/tests/spec/QuickfixSuppress.ini index 9da9bdf..66f6183 100644 --- a/crates/analysis/tests/spec/QuickfixSuppress.ini +++ b/crates/analysis/tests/spec/QuickfixSuppress.ini @@ -1,6 +1,6 @@ ; Quickfix test: suppress-in-file pragma. -; bad-bool fires an Error on "Maybe" → no Suppress action. +; bad-bool fires an Error on "Maybe" → Suppress action offered. Weapon QFSuppressWeapon ScaleWeaponSpeed = Maybe FireFX = UnknownFXRef diff --git a/crates/analysis/tests/spec/QuickfixSuppress.spec.toml b/crates/analysis/tests/spec/QuickfixSuppress.spec.toml index 932233d..c0d0728 100644 --- a/crates/analysis/tests/spec/QuickfixSuppress.spec.toml +++ b/crates/analysis/tests/spec/QuickfixSuppress.spec.toml @@ -1,4 +1,4 @@ -# "Maybe" fires bad-bool (Error) → no Suppress quickfix +# "Maybe" fires bad-bool (Error) → Suppress quickfix offered [[diag]] severity = "error" code = "bad-bool" @@ -6,7 +6,7 @@ on = "Maybe" [[action]] on = "Maybe" -not_offers = ["Suppress"] +offers = ["Suppress"] # UnknownFXRef fires unresolved-reference (Warning) → Suppress quickfix offered [[diag]] diff --git a/docs/diagnostics.md b/docs/diagnostics.md index 9ebd112..6bb5081 100644 --- a/docs/diagnostics.md +++ b/docs/diagnostics.md @@ -15,8 +15,8 @@ Separate multiple codes with spaces or commas. Multiple file-scope pragma lines accumulate. A misspelled code produces `unknown-suppression` instead of silently hiding nothing. -Suppressions are intended for warnings and hints that are valid for a specific -file. Fix error-level syntax and schema problems rather than suppressing them. +Suppressions can hide any diagnostic code for a specific file. Prefer fixing +error-level syntax and schema problems when possible. ## Diagnostic codes @@ -64,4 +64,4 @@ available fix. | Create a stub definition | A reference points to a missing definition that can be scaffolded safely. | | Remove an unreachable `WeaponSet` or `ArmorSet` | An upgrade-conditioned set can never activate. | | Insert a matching upgrade module or set | An object has only one side of an upgrade-conditioned weapon or armor setup. | -| Suppress a code in this file | A warning or hint is intentional for the current file. | +| Suppress a code in this file | A diagnostic is intentional for the current file. |