Struct ast_grep_core::Node
source · pub struct Node<'r, L: Language> { /* private fields */ }Implementations
sourceimpl<'r, L: Language> Node<'r, L>
impl<'r, L: Language> Node<'r, L>
pub fn is_leaf(&self) -> bool
pub fn kind(&self) -> Cow<'_, str>
pub fn kind_id(&self) -> u16
pub fn is_named(&self) -> bool
pub fn range(&self) -> Range<usize>
pub fn start_pos(&self) -> (usize, usize)
pub fn end_pos(&self) -> (usize, usize)
pub fn text(&self) -> Cow<'r, str>
pub fn to_sexp(&self) -> Cow<'_, str>
pub fn display_context(&self, context_lines: usize) -> DisplayContext<'r>
pub fn lang(&self) -> &L
sourceimpl<'r, L: Language> Node<'r, L>
impl<'r, L: Language> Node<'r, L>
tree traversal API
pub fn children<'s>(&'s self) -> impl ExactSizeIterator<Item = Node<'r, L>> + 's
pub fn dfs<'s>(&'s self) -> Dfs<'r, L>
pub fn find<M: Matcher<L>>(&self, pat: M) -> Option<NodeMatch<'r, L>>
pub fn find_all<M: Matcher<L>>(
&self,
pat: M
) -> impl Iterator<Item = NodeMatch<'r, L>>
pub fn field(&self, name: &str) -> Option<Self>
pub fn field_children(&self, name: &str) -> impl Iterator<Item = Node<'r, L>>
pub fn parent(&self) -> Option<Self>
pub fn child(&self, nth: usize) -> Option<Self>
pub fn ancestors(&self) -> impl Iterator<Item = Node<'r, L>> + '_
pub fn next(&self) -> Option<Self>
pub fn next_all(&self) -> impl Iterator<Item = Node<'r, L>> + '_
pub fn prev(&self) -> Option<Node<'r, L>>
pub fn prev_all(&self) -> impl Iterator<Item = Node<'r, L>> + '_
sourceimpl<'r, L: Language> Node<'r, L>
impl<'r, L: Language> Node<'r, L>
Tree manipulation API
pub fn replace<M: Matcher<L>, R: Replacer<L>>(
&self,
matcher: M,
replacer: R
) -> Option<Edit>
pub fn replace_all<M: Matcher<L>, R: Replacer<L>>(
&self,
matcher: M,
replacer: R
) -> Vec<Edit>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
pub fn after(&self)
pub fn before(&self)
pub fn append(&self)
pub fn prepend(&self)
pub fn empty(&self)
pub fn remove(&self)
Trait Implementations
sourceimpl<'tree, L: Language> BorrowMut<Node<'tree, L>> for NodeMatch<'tree, L>
impl<'tree, L: Language> BorrowMut<Node<'tree, L>> for NodeMatch<'tree, L>
sourcefn borrow_mut(&mut self) -> &mut Node<'tree, L>
fn borrow_mut(&mut self) -> &mut Node<'tree, L>
Mutably borrows from an owned value. Read more
Auto Trait Implementations
impl<'r, L> RefUnwindSafe for Node<'r, L>where
L: RefUnwindSafe,
impl<'r, L> !Send for Node<'r, L>
impl<'r, L> !Sync for Node<'r, L>
impl<'r, L> Unpin for Node<'r, L>
impl<'r, L> UnwindSafe for Node<'r, L>where
L: RefUnwindSafe,
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