Struct ast_grep_core::KindMatcher
source · pub struct KindMatcher<L: Language> { /* private fields */ }Implementations
sourceimpl<L: Language> KindMatcher<L>
impl<L: Language> KindMatcher<L>
pub fn new(node_kind: &str, lang: L) -> Self
pub fn from_id(kind: u16) -> Self
sourcepub fn is_invalid(&self) -> bool
pub fn is_invalid(&self) -> bool
Whether the kind matcher contains undefined tree-sitter kind.
sourcepub fn is_error_matcher(&self) -> bool
pub fn is_error_matcher(&self) -> bool
Whether the kind will match parsing error occurred in the source code.
for example, we can use kind: ERROR in YAML to find invalid syntax in source.
the name is_error implies the matcher itself is error.
But here the matcher itself is valid and it is what it matches is error.
Trait Implementations
sourceimpl<L: Clone + Language> Clone for KindMatcher<L>
impl<L: Clone + Language> Clone for KindMatcher<L>
sourcefn clone(&self) -> KindMatcher<L>
fn clone(&self) -> KindMatcher<L>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresourceimpl<L: Language> Matcher<L> for KindMatcher<L>
impl<L: Language> Matcher<L> for KindMatcher<L>
sourcefn match_node_with_env<'tree>(
&self,
node: Node<'tree, L>,
_env: &mut MetaVarEnv<'tree, L>
) -> Option<Node<'tree, L>>
fn match_node_with_env<'tree>(
&self,
node: Node<'tree, L>,
_env: &mut MetaVarEnv<'tree, L>
) -> Option<Node<'tree, L>>
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. Read morefn match_node<'tree>(&self, node: Node<'tree, L>) -> Option<NodeMatch<'tree, L>>
fn get_meta_var_matchers(&self) -> MetaVarMatchers<L>
fn get_meta_var_env<'tree>(&self) -> MetaVarEnv<'tree, L>
fn find_node_with_env<'tree>(
&self,
node: Node<'tree, L>,
env: &mut MetaVarEnv<'tree, L>
) -> Option<Node<'tree, L>>
fn find_node<'tree>(&self, node: Node<'tree, L>) -> Option<NodeMatch<'tree, L>>
fn find_all_nodes(self, node: Node<'_, L>) -> FindAllNodes<'_, L, Self>where
Self: Sized,
impl<L: Language> PositiveMatcher<L> for KindMatcher<L>
Auto Trait Implementations
impl<L> RefUnwindSafe for KindMatcher<L>where
L: RefUnwindSafe,
impl<L> Send for KindMatcher<L>where
L: Send,
impl<L> Sync for KindMatcher<L>where
L: Sync,
impl<L> Unpin for KindMatcher<L>where
L: Unpin,
impl<L> UnwindSafe for KindMatcher<L>where
L: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more