Skip to main content

perl_diagnostics/codes/
tag.rs

1use std::fmt;
2
3/// Diagnostic tags for additional classification.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum DiagnosticTag {
7    /// Code that can be safely removed (unused variables, imports).
8    Unnecessary = 1,
9    /// Code using deprecated features.
10    Deprecated = 2,
11}
12
13impl DiagnosticTag {
14    /// Get the LSP numeric value for this tag.
15    pub fn to_lsp_value(self) -> u8 {
16        self as u8
17    }
18}
19
20impl fmt::Display for DiagnosticTag {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        match self {
23            Self::Unnecessary => write!(f, "unnecessary"),
24            Self::Deprecated => write!(f, "deprecated"),
25        }
26    }
27}