oxc_markdown_parser/
diagnostic.rs1use crate::pos::Span;
9use std::fmt::Display;
10
11#[derive(Clone, Debug)]
12pub struct Diagnostic {
13 pub kind: DiagnosticKind,
14 pub span: Span,
15}
16
17impl Diagnostic {
18 pub(crate) fn new(kind: DiagnosticKind, span: Span) -> Self {
19 Self { kind, span }
20 }
21}
22
23#[derive(Clone, Debug, PartialEq, Eq)]
26#[non_exhaustive]
27pub enum DiagnosticKind {
28 SourceTooLong,
30}
31
32impl Display for Diagnostic {
33 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34 let message = match &self.kind {
35 DiagnosticKind::SourceTooLong => "source exceeds the maximum supported size (4 GiB)",
36 };
37 write!(f, "{message} at {}..{}", self.span.start, self.span.end)
38 }
39}