mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
[red-knot] Add support for the LSP diagnostic tag (#17657)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
b51c4f82ea
commit
8535af8516
3 changed files with 71 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
use std::fmt;
|
||||
|
||||
use drop_bomb::DebugDropBomb;
|
||||
use ruff_db::diagnostic::DiagnosticTag;
|
||||
use ruff_db::{
|
||||
diagnostic::{Annotation, Diagnostic, DiagnosticId, IntoDiagnosticMessage, Severity, Span},
|
||||
files::File,
|
||||
|
@ -259,6 +260,21 @@ impl LintDiagnosticGuard<'_, '_> {
|
|||
let ann = self.primary_annotation_mut().unwrap();
|
||||
ann.set_message(message);
|
||||
}
|
||||
|
||||
/// Adds a tag on the primary annotation for this diagnostic.
|
||||
///
|
||||
/// This tag is associated with the primary annotation created
|
||||
/// for every `Diagnostic` that uses the `LintDiagnosticGuard` API.
|
||||
/// Specifically, the annotation is derived from the `TextRange` given to
|
||||
/// the `InferContext::report_lint` API.
|
||||
///
|
||||
/// Callers can add additional primary or secondary annotations via the
|
||||
/// `DerefMut` trait implementation to a `Diagnostic`.
|
||||
#[expect(dead_code)]
|
||||
pub(super) fn add_primary_tag(&mut self, tag: DiagnosticTag) {
|
||||
let ann = self.primary_annotation_mut().unwrap();
|
||||
ann.push_tag(tag);
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for LintDiagnosticGuard<'_, '_> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue