in src/models/filter.rs [334:375]
fn _check(
&self, filter: Filter, node: Node, rule_store: &mut RuleStore,
substitutions: &HashMap<String, String>,
) -> bool {
let mut node_to_check = node;
let instantiated_filter = filter.instantiate(substitutions);
if *filter.child_count() != default_child_count() {
return node.named_child_count() == (*filter.child_count() as usize);
}
if *filter.sibling_count() != default_sibling_count() {
return node.parent().unwrap().named_child_count() == (*filter.sibling_count() as usize);
}
// Check if no ancestor matches the query for not_enclosing_node
if !self._check_not_enclosing_node(rule_store, node_to_check, &instantiated_filter) {
return false;
}
// If an enclosing node is provided
let query = instantiated_filter.enclosing_node();
if !query.pattern().is_empty() {
if let Some(result) = self._match_ancestor(rule_store, node_to_check, query) {
node_to_check = result;
} else {
return false;
}
}
// If an outermost enclosing node is provided
let query = instantiated_filter.outermost_enclosing_node();
if !query.pattern().is_empty() {
if let Some(result) = self._match_outermost_ancestor(rule_store, node_to_check, query) {
node_to_check = result;
} else {
return false;
}
}
self._check_filter_not_contains(&instantiated_filter, rule_store, &node_to_check)
&& self._check_filter_contains(&instantiated_filter, rule_store, &node_to_check)
}