use alloc::string::String;
use crate::span::Span;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum DiagnosticSeverity {
Warning,
Error,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum DiagnosticCode {
InvalidDirectiveName,
UnclosedDirectiveContainer,
InvalidMdx,
StrictParse,
InvalidDocument,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Diagnostic {
pub severity: DiagnosticSeverity,
pub code: DiagnosticCode,
pub span: Option<Span>,
pub message: String,
}
impl Diagnostic {
pub fn new(
severity: DiagnosticSeverity,
code: DiagnosticCode,
span: Span,
message: impl Into<String>,
) -> Self {
Self {
severity,
code,
span: Some(span),
message: message.into(),
}
}
pub fn invalid(span: Option<Span>, message: impl Into<String>) -> Self {
Self {
severity: DiagnosticSeverity::Error,
code: DiagnosticCode::InvalidDocument,
span,
message: message.into(),
}
}
}