style(xatu): format source ranges

This commit is contained in:
2026-09-18 22:33:56 -04:00
parent 9d117cc2a4
commit efc7f9513e
2 changed files with 11 additions and 6 deletions

View File

@@ -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,

View File

@@ -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,
)
}
}