grit_pattern_matcher/pattern/
ast_node_pattern.rs1use super::{
2 iter_pattern::PatternOrPredicate,
3 patterns::{Matcher, PatternName},
4};
5use crate::context::{QueryContext, StaticDefinitions};
6
7pub trait AstNodePattern<Q: QueryContext>:
9 Clone + std::fmt::Debug + Matcher<Q> + PatternName + Sized
10{
11 const INCLUDES_TRIVIA: bool;
14
15 fn children<'a>(
16 &'a self,
17 definitions: &'a StaticDefinitions<Q>,
18 ) -> Vec<PatternOrPredicate<'a, Q>>;
19
20 fn matches_kind_of(&self, node: &Q::Node<'_>) -> bool;
21}
22
23pub trait AstLeafNodePattern<Q: QueryContext>:
25 Clone + std::fmt::Debug + Matcher<Q> + PatternName + Sized
26{
27 fn text(&self) -> Option<&str> {
30 None
31 }
32}