use solar_ast::visit::Visit;
use solar_interface::{Session, Span};
use std::ops::ControlFlow;
pub(crate) struct SpanVisitor<'sess> {
sess: &'sess Session,
count: usize,
}
impl<'sess> SpanVisitor<'sess> {
pub(crate) fn new(sess: &'sess Session) -> Self {
Self { sess, count: 0 }
}
pub(crate) fn count(&self) -> usize {
self.count
}
}
impl<'ast, 'sess> Visit<'ast> for SpanVisitor<'sess> {
type BreakValue = solar_data_structures::Never;
fn visit_span(&mut self, span: &'ast Span) -> ControlFlow<Self::BreakValue> {
self.count += 1;
self.sess.dcx.note(format!("span #{}", self.count)).span(*span).emit();
ControlFlow::Continue(())
}
}