Enum ast_grep_config::Rule

source ·
pub enum Rule<L: Language> {
    Pattern(Pattern<L>),
    Kind(KindMatcher<L>),
    Regex(RegexMatcher<L>),
    NthChild(NthChild<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>)

§

NthChild(NthChild<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>

source

pub fn is_atomic(&self) -> bool

source

pub fn is_relational(&self) -> bool

source

pub fn is_composite(&self) -> bool

source

pub fn defined_vars(&self) -> HashSet<&str>

source

pub fn verify_util(&self) -> Result<(), RuleSerializeError>

check if util rules used are defined

Trait Implementations§

source§

impl<L: Language> Default for Rule<L>

Rule matches nothing by default. In Math jargon, Rule is vacuously false.

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

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>>

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>

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>,

get_match_len will skip trailing anonymous child node to exclude punctuation.
source§

fn match_node<'tree, D>( &self, node: Node<'tree, D>, ) -> Option<NodeMatch<'tree, D>>
where D: Doc<Lang = L>,

source§

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>
where L: Send + Sync,

§

impl<L> Sync for Rule<L>
where L: Sync + Send,

§

impl<L> Unpin for Rule<L>
where L: Unpin,

§

impl<L> UnwindSafe for Rule<L>
where L: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.