extern crate term;
extern crate codemap;
extern crate isatty;
use codemap::Span;
mod lock;
mod snippet;
mod styled_buffer;
mod emitter;
pub use emitter::{ ColorConfig, Emitter };
#[derive(Clone, Debug)]
pub struct Diagnostic {
pub level: Level,
pub message: String,
pub code: Option<String>,
pub spans: Vec<SpanLabel>,
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Level {
Bug,
Error,
Warning,
Note,
Help,
}
impl ::std::fmt::Display for Level {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
self.to_str().fmt(f)
}
}
impl Level {
fn color(self) -> term::color::Color {
use self::Level::*;
match self {
Bug | Error => term::color::BRIGHT_RED,
Warning => {
if cfg!(windows) {
term::color::BRIGHT_YELLOW
} else {
term::color::YELLOW
}
}
Note => term::color::BRIGHT_GREEN,
Help => term::color::BRIGHT_CYAN,
}
}
pub fn to_str(self) -> &'static str {
use self::Level::*;
match self {
Bug => "error: internal compiler error",
Error => "error",
Warning => "warning",
Note => "note",
Help => "help",
}
}
}
#[derive(Clone, Debug)]
pub struct SpanLabel {
pub span: Span,
pub label: Option<String>,
pub style: SpanStyle,
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum SpanStyle {
Primary,
Secondary,
}