mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00
red_knot: use Diagnostic
inside of red knot
This replaces things like `TypeCheckDiagnostic` with the new Diagnostic` type. This is a "surgical" replacement where we retain the existing API of of diagnostic reporting such that _most_ of Red Knot doesn't need to be changed to support this update. But it will enable us to start using the new diagnostic renderer and to delete the old renderer. It also paves the path for exposing the new `Diagnostic` data model to the broader Red Knot codebase.
This commit is contained in:
parent
883b8e3870
commit
4e169e5f6c
18 changed files with 263 additions and 339 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::lint::{GetLintError, Level, LintMetadata, LintRegistry, LintStatus};
|
||||
use crate::types::{TypeCheckDiagnostic, TypeCheckDiagnostics};
|
||||
use crate::types::TypeCheckDiagnostics;
|
||||
use crate::{declare_lint, lint::LintId, Db};
|
||||
use ruff_db::diagnostic::DiagnosticId;
|
||||
use ruff_db::diagnostic::{Annotation, Diagnostic, DiagnosticId, Span};
|
||||
use ruff_db::{files::File, parsed::parsed_module, source::source_text};
|
||||
use ruff_python_parser::TokenKind;
|
||||
use ruff_python_trivia::Cursor;
|
||||
|
@ -319,14 +319,11 @@ impl<'a> CheckSuppressionsContext<'a> {
|
|||
return;
|
||||
};
|
||||
|
||||
self.diagnostics.push(TypeCheckDiagnostic {
|
||||
id: DiagnosticId::Lint(lint.name()),
|
||||
message: message.to_string(),
|
||||
range,
|
||||
severity,
|
||||
file: self.file,
|
||||
secondary_messages: vec![],
|
||||
});
|
||||
let id = DiagnosticId::Lint(lint.name());
|
||||
let mut diag = Diagnostic::new(id, severity, "");
|
||||
let span = Span::from(self.file).with_range(range);
|
||||
diag.annotate(Annotation::primary(span).message(message));
|
||||
self.diagnostics.push(diag);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue