only_diagnostic/
diagnostic.rs1use text_size::TextRange;
2
3use crate::{DiagnosticCode, DiagnosticLabel, DiagnosticPhase, DiagnosticSeverity};
4
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct Diagnostic {
7 pub severity: DiagnosticSeverity,
8 pub message: String,
9 pub code: DiagnosticCode,
10 pub primary_range: TextRange,
11 pub secondary_ranges: Vec<TextRange>,
12 pub labels: Vec<DiagnosticLabel>,
13 pub phase: DiagnosticPhase,
14}
15
16impl Diagnostic {
17 pub fn new(
29 severity: DiagnosticSeverity,
30 code: DiagnosticCode,
31 message: impl Into<String>,
32 phase: DiagnosticPhase,
33 primary_range: TextRange,
34 ) -> Self {
35 Self {
36 severity,
37 message: message.into(),
38 code,
39 primary_range,
40 secondary_ranges: Vec::new(),
41 labels: Vec::new(),
42 phase,
43 }
44 }
45}