1use std::path::Path;
2use std::sync::Arc;
3
4use crate::alterator::Alterator;
5use crate::checker::Checker;
6use crate::cognitive::Cognitive;
7use crate::cyclomatic::Cyclomatic;
8use crate::exit::Exit;
9use crate::getter::Getter;
10use crate::halstead::Halstead;
11use crate::langs::*;
12use crate::loc::Loc;
13use crate::mi::Mi;
14use crate::nargs::NArgs;
15use crate::node::Node;
16use crate::nom::Nom;
17use crate::parser::Filter;
18use crate::preproc::PreprocResults;
19
20pub trait Callback {
25 type Res;
27 type Cfg;
29
30 fn call<T: ParserTrait>(cfg: Self::Cfg, parser: &T) -> Self::Res;
32}
33
34pub trait LanguageInfo {
35 type BaseLang;
36
37 fn get_lang() -> LANG;
38 fn get_lang_name() -> &'static str;
39}
40
41#[doc(hidden)]
42pub trait ParserTrait {
43 type Checker: Alterator + Checker;
44 type Getter: Getter;
45 type Cognitive: Cognitive;
46 type Cyclomatic: Cyclomatic;
47 type Halstead: Halstead;
48 type Loc: Loc;
49 type Nom: Nom;
50 type Mi: Mi;
51 type NArgs: NArgs;
52 type Exit: Exit;
53
54 fn new(code: Vec<u8>, path: &Path, pr: Option<Arc<PreprocResults>>) -> Self;
55 fn get_language(&self) -> LANG;
56 fn get_root(&self) -> Node<'_>;
57 fn get_code(&self) -> &[u8];
58 fn get_filters(&self, filters: &[String]) -> Filter;
59}
60
61pub(crate) trait Search<'a> {
62 fn first_occurrence(&self, pred: fn(u16) -> bool) -> Option<Node<'a>>;
63 fn act_on_node(&self, pred: &mut dyn FnMut(&Node<'a>));
64 fn first_child(&self, pred: fn(u16) -> bool) -> Option<Node<'a>>;
65 fn act_on_child(&self, action: &mut dyn FnMut(&Node<'a>));
66}