perl_diagnostics/types/mod.rs
1//! Diagnostic types: Diagnostic and RelatedInformation.
2//!
3//! This module contains the diagnostic message types used by LSP.
4//!
5//! Type unification: `DiagnosticSeverity` and `DiagnosticTag` are re-exported
6//! from the `codes` module, ensuring a single canonical type that can be used
7//! from either module path.
8
9// Unified types — canonical definitions are in codes module
10pub use crate::codes::{DiagnosticSeverity, DiagnosticTag};
11
12/// A diagnostic message with location and metadata.
13#[derive(Debug, Clone, Default, PartialEq, Eq)]
14#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15pub struct Diagnostic {
16 /// The diagnostic code (e.g., PL001).
17 pub code: crate::codes::DiagnosticCode,
18 /// Severity level.
19 pub severity: DiagnosticSeverity,
20 /// Location of the diagnostic.
21 pub range: (usize, usize),
22 /// The message text.
23 pub message: String,
24 /// Optional related information.
25 pub related_information: Option<Vec<RelatedInformation>>,
26 /// Optional tags (Unnecessary, Deprecated, etc.).
27 pub tags: Option<Vec<DiagnosticTag>>,
28}
29
30/// Information related to a diagnostic.
31#[derive(Debug, Clone, Default, PartialEq, Eq)]
32#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
33pub struct RelatedInformation {
34 /// The message text.
35 pub message: String,
36 /// Location of the related information.
37 pub location: (usize, usize),
38}