chappi_syntax/
diagnostic.rs1use serde::{Deserialize, Serialize};
2
3use crate::Span;
4
5#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
7pub enum Severity {
8 Error,
9 Warning,
10}
11
12#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
14pub struct Diagnostic {
15 pub code: String,
16 pub severity: Severity,
17 pub span: Span,
18 pub semantic_path: Vec<String>,
19 pub message: String,
20 pub hint: Option<String>,
21}
22
23impl Diagnostic {
24 pub(crate) fn error(code: &str, span: Span, message: impl Into<String>) -> Self {
25 Self {
26 code: code.to_owned(),
27 severity: Severity::Error,
28 span,
29 semantic_path: Vec::new(),
30 message: message.into(),
31 hint: None,
32 }
33 }
34}