Make lint groups work correctly with warningsAsInfo and warningsAsHint

This commit is contained in:
Emil Gardström
2021-11-22 14:14:21 +01:00
parent b69eee6487
commit 3dc898389f
4 changed files with 1042 additions and 94 deletions

View File

@@ -21,10 +21,20 @@ fn diagnostic_severity(
DiagnosticLevel::Ice => lsp_types::DiagnosticSeverity::ERROR,
DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::ERROR,
DiagnosticLevel::Warning => match &code {
Some(code) if config.warnings_as_hint.contains(&code.code) => {
// HACK: special case for `warnings` rustc lint.
Some(code)
if config.warnings_as_hint.iter().any(|lint| {
lint == "warnings" || ide_db::helpers::lint_eq_or_in_group(&code.code, &lint)
}) =>
{
lsp_types::DiagnosticSeverity::HINT
}
Some(code) if config.warnings_as_info.contains(&code.code) => {
// HACK: special case for `warnings` rustc lint.
Some(code)
if config.warnings_as_info.iter().any(|lint| {
lint == "warnings" || ide_db::helpers::lint_eq_or_in_group(&code.code, &lint)
}) =>
{
lsp_types::DiagnosticSeverity::INFORMATION
}
_ => lsp_types::DiagnosticSeverity::WARNING,