style(xatu): format source ranges
This commit is contained in:
@@ -16,6 +16,12 @@ pub struct SourceRange {
|
||||
pub end: usize,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SourceRange {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(formatter, "{}..{}", self.start, self.end)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Node {
|
||||
pub range: SourceRange,
|
||||
|
||||
@@ -19,12 +19,11 @@ pub struct Diagnostic {
|
||||
|
||||
impl std::fmt::Display for Diagnostic {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let start = self.finding.range.start;
|
||||
let end = self.finding.range.end;
|
||||
let rule_id = self.finding.rule_id;
|
||||
let message = self.finding.message;
|
||||
|
||||
write!(formatter, "{start}..{end}: {rule_id}: {message}")
|
||||
write!(
|
||||
formatter,
|
||||
"{}: {}: {}",
|
||||
self.finding.range, self.finding.rule_id, self.finding.message,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user