use crate::span::Span;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Severity {
Error,
Warning,
Info,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum DiagnosticCode {
AmbiguousMatch,
ErrorFenceWithoutStep,
Drift,
ReferenceNotFound,
ReferenceEmpty,
ReferenceCycle,
AmbiguousAnchor,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Diagnostic {
pub code: DiagnosticCode,
pub severity: Severity,
pub span: Span,
}
pub fn ambiguous_match(span: Span) -> Diagnostic {
Diagnostic {
code: DiagnosticCode::AmbiguousMatch,
severity: Severity::Error,
span,
}
}
pub fn error_fence_without_step(span: Span) -> Diagnostic {
Diagnostic {
code: DiagnosticCode::ErrorFenceWithoutStep,
severity: Severity::Error,
span,
}
}
pub fn reference_not_found(span: Span) -> Diagnostic {
Diagnostic {
code: DiagnosticCode::ReferenceNotFound,
severity: Severity::Error,
span,
}
}
pub fn reference_empty(span: Span) -> Diagnostic {
Diagnostic {
code: DiagnosticCode::ReferenceEmpty,
severity: Severity::Error,
span,
}
}
pub fn reference_cycle(span: Span) -> Diagnostic {
Diagnostic {
code: DiagnosticCode::ReferenceCycle,
severity: Severity::Error,
span,
}
}
pub fn ambiguous_anchor(span: Span) -> Diagnostic {
Diagnostic {
code: DiagnosticCode::AmbiguousAnchor,
severity: Severity::Error,
span,
}
}