use crate::checkstyle::api::config::{Configurable, Contextualizable};
use crate::checkstyle::api::error::CheckstyleResult;
use crate::checkstyle::api::file::FileText;
use crate::checkstyle::api::violation::Violation;
use std::collections::BTreeSet;
use std::path::PathBuf;
pub trait MessageDispatcher: Send + Sync {
fn fire_audit_event(&self, event: &crate::checkstyle::api::event::AuditEvent) -> CheckstyleResult<()>;
}
pub trait FileSetCheck: Configurable + Contextualizable + Send + Sync {
fn set_message_dispatcher(&mut self, dispatcher: Box<dyn MessageDispatcher>);
fn init(&mut self) -> CheckstyleResult<()>;
fn destroy(&mut self) -> CheckstyleResult<()>;
fn begin_processing(&mut self, charset: &str) -> CheckstyleResult<()>;
fn process(
&mut self,
file: &PathBuf,
file_text: &FileText,
) -> CheckstyleResult<BTreeSet<Violation>>;
fn finish_processing(&mut self) -> CheckstyleResult<()>;
}
pub trait Check: Configurable + Contextualizable + Send + Sync {
fn get_default_tokens(&self) -> Vec<i32>;
fn get_acceptable_tokens(&self) -> Vec<i32>;
fn get_required_tokens(&self) -> Vec<i32>;
fn is_comment_nodes_required(&self) -> bool {
false
}
fn init(&mut self) -> CheckstyleResult<()> {
Ok(())
}
fn visit_token(&mut self, ast: &dyn crate::checkstyle::api::ast::DetailAst) -> CheckstyleResult<()> {
let _ = ast;
Ok(())
}
fn leave_token(&mut self, ast: &dyn crate::checkstyle::api::ast::DetailAst) -> CheckstyleResult<()> {
let _ = ast;
Ok(())
}
fn begin_tree(&mut self, _ast: &dyn crate::checkstyle::api::ast::DetailAst) -> CheckstyleResult<()> {
Ok(())
}
fn finish_tree(&mut self, _ast: &dyn crate::checkstyle::api::ast::DetailAst) -> CheckstyleResult<()> {
Ok(())
}
fn get_violations(&self) -> BTreeSet<Violation>;
fn clear_violations(&mut self);
}