use proc_macro2::Span;
use crate::diagnostic::{Level, Diagnostic};
macro_rules! diagnostic_def {
($name:ident) => (
fn $name<T: Into<String>>(self, message: T) -> Diagnostic;
)
}
pub trait SpanDiagnosticExt {
diagnostic_def!(error);
diagnostic_def!(warning);
diagnostic_def!(note);
diagnostic_def!(help);
}
macro_rules! diagnostic_method {
($name:ident, $level:expr) => (
fn $name<T: Into<String>>(self, message: T) -> Diagnostic {
Diagnostic::spanned(self, $level, message)
}
)
}
impl SpanDiagnosticExt for Span {
diagnostic_method!(error, Level::Error);
diagnostic_method!(warning, Level::Warning);
diagnostic_method!(note, Level::Note);
diagnostic_method!(help, Level::Help);
}