2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-06-08 01:01:27 -07:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2022-02-01 19:16:35 -08:00
|
|
|
pub(crate) enum Warning {}
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-03-28 23:39:23 -07:00
|
|
|
impl Warning {
|
2022-02-01 19:16:35 -08:00
|
|
|
#[allow(clippy::unused_self)]
|
2021-03-28 23:39:23 -07:00
|
|
|
fn context(&self) -> Option<&Token> {
|
2022-02-01 19:16:35 -08:00
|
|
|
None
|
2019-09-21 18:53:30 -07:00
|
|
|
}
|
2021-07-28 18:06:57 -07:00
|
|
|
}
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-07-28 18:06:57 -07:00
|
|
|
impl ColorDisplay for Warning {
|
|
|
|
fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result {
|
2021-07-26 01:26:06 -07:00
|
|
|
let warning = color.warning();
|
|
|
|
let message = color.message();
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-07-28 18:06:57 -07:00
|
|
|
write!(f, "{} {}", warning.paint("warning:"), message.prefix())?;
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-07-28 18:06:57 -07:00
|
|
|
write!(f, "{}", message.suffix())?;
|
2019-09-21 18:53:30 -07:00
|
|
|
|
|
|
|
if let Some(token) = self.context() {
|
2021-07-28 18:06:57 -07:00
|
|
|
writeln!(f)?;
|
|
|
|
write!(f, "{}", token.color_display(color))?;
|
2019-09-21 18:53:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
2021-11-17 00:07:48 -08:00
|
|
|
|
|
|
|
impl Serialize for Warning {
|
|
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
|
|
where
|
|
|
|
S: Serializer,
|
|
|
|
{
|
|
|
|
let mut map = serializer.serialize_map(None)?;
|
|
|
|
|
|
|
|
map.serialize_entry("message", &self.color_display(Color::never()).to_string())?;
|
|
|
|
|
|
|
|
map.end()
|
|
|
|
}
|
|
|
|
}
|