refactor(xatu): return structured reports

This commit is contained in:
2026-09-18 22:27:18 -04:00
parent 113018a62c
commit 508f866f57
3 changed files with 59 additions and 13 deletions

View File

@@ -4,17 +4,37 @@ use crate::rules::empty_inherit::EmptyInherit;
pub mod empty_inherit;
#[derive(Debug)]
pub struct Finding {
/// Identifies the rule that produced this finding.
pub rule_id: &'static str,
/// Identifies the source range that triggered this finding.
pub range: ast::SourceRange,
/// Describes the finding for human-readable output.
pub message: &'static str,
}
#[derive(Debug)]
pub struct Diagnostic {
/// Identifies the file that contains this diagnostic.
pub file_id: FileId,
/// Contains the node-local rule finding.
pub finding: Finding,
}
impl std::fmt::Display for Diagnostic {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
formatter,
"{}..{}: {}: {}",
self.finding.range.start,
self.finding.range.end,
self.finding.rule_id,
self.finding.message,
)
}
}
pub trait NodeRule {
type Node;