Enum ast_grep_config::Rule
source · pub enum Rule<L: Language> {
Pattern(Pattern<L>),
Kind(KindMatcher<L>),
Regex(RegexMatcher<L>),
Inside(Box<Inside<L>>),
Has(Box<Has<L>>),
Precedes(Box<Precedes<L>>),
Follows(Box<Follows<L>>),
All(All<L, Rule<L>>),
Any(Any<L, Rule<L>>),
Not(Box<Not<L, Rule<L>>>),
Matches(ReferentRule<L>),
}Variants§
Pattern(Pattern<L>)
Kind(KindMatcher<L>)
Regex(RegexMatcher<L>)
Inside(Box<Inside<L>>)
Has(Box<Has<L>>)
Precedes(Box<Precedes<L>>)
Follows(Box<Follows<L>>)
All(All<L, Rule<L>>)
Any(Any<L, Rule<L>>)
Not(Box<Not<L, Rule<L>>>)
Matches(ReferentRule<L>)
Implementations§
source§impl<L: Language> Rule<L>
impl<L: Language> Rule<L>
pub fn is_atomic(&self) -> bool
pub fn is_relational(&self) -> bool
pub fn is_composite(&self) -> bool
pub fn defined_vars(&self) -> HashSet<&str>
sourcepub fn verify_util(&self) -> Result<(), RuleSerializeError>
pub fn verify_util(&self) -> Result<(), RuleSerializeError>
check if util rules used are defined
Trait Implementations§
source§impl<L: Language> Default for Rule<L>
impl<L: Language> Default for Rule<L>
Rule matches nothing by default. In Math jargon, Rule is vacuously false.
source§impl<L: Language> Matcher<L> for Rule<L>
impl<L: Language> Matcher<L> for Rule<L>
source§fn match_node_with_env<'tree, D: Doc<Lang = L>>(
&self,
node: Node<'tree, D>,
env: &mut Cow<'_, MetaVarEnv<'tree, D>>
) -> Option<Node<'tree, D>>
fn match_node_with_env<'tree, D: Doc<Lang = L>>( &self, node: Node<'tree, D>, env: &mut Cow<'_, MetaVarEnv<'tree, D>> ) -> Option<Node<'tree, D>>
Returns the node why the input is matched or None if not matched.
The return value is usually input node itself, but it can be different node.
For example
Has matcher can return the child or descendant node.source§fn potential_kinds(&self) -> Option<BitSet>
fn potential_kinds(&self) -> Option<BitSet>
Returns a bitset for all possible target node kind ids.
Returns None if the matcher needs to try against all node kind.
source§fn get_match_len<D>(&self, _node: Node<'_, D>) -> Option<usize>where
D: Doc<Lang = L>,
fn get_match_len<D>(&self, _node: Node<'_, D>) -> Option<usize>where
D: Doc<Lang = L>,
get_match_len will skip trailing anonymous child node to exclude punctuation.
fn match_node<'tree, D>(
&self,
node: Node<'tree, D>
) -> Option<NodeMatch<'tree, D>>where
D: Doc<Lang = L>,
fn find_node<'tree, D>(
&self,
node: Node<'tree, D>
) -> Option<NodeMatch<'tree, D>>where
D: Doc<Lang = L>,
Auto Trait Implementations§
impl<L> Freeze for Rule<L>
impl<L> RefUnwindSafe for Rule<L>where
L: RefUnwindSafe,
impl<L> Send for Rule<L>
impl<L> Sync for Rule<L>
impl<L> Unpin for Rule<L>where
L: Unpin,
impl<L> UnwindSafe for Rule<L>where
L: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more