pub struct BashNode<'a> { /* private fields */ }Expand description
A node in a parsed bash script.
Implementations§
Source§impl<'a> BashNode<'a>
impl<'a> BashNode<'a>
Sourcepub fn kind(&self) -> &'a str
pub fn kind(&self) -> &'a str
The grammar’s node kind, such as command, word, or file_redirect.
Sourcepub fn text(&self) -> &'a str
pub fn text(&self) -> &'a str
The source text covered by this node.
Returns an empty string when the node’s span is not valid UTF-8, which keeps AST walks total instead of panicking on malformed input.
Sourcepub fn start_byte(&self) -> usize
pub fn start_byte(&self) -> usize
The byte offset where this node starts in the source text.
Sourcepub fn is_named(&self) -> bool
pub fn is_named(&self) -> bool
Whether the grammar considers this node named.
Anonymous nodes carry punctuation (&&, |, ;), so a walk that must
reason about structure rather than operators checks this first.
Sourcepub fn field(&self, field: &str) -> Option<Self>
pub fn field(&self, field: &str) -> Option<Self>
Returns the child bound to field, such as a command’s name.
Sourcepub fn named_children(&self) -> Vec<Self>
pub fn named_children(&self) -> Vec<Self>
Returns every named child node.
Sourcepub fn field_children(&self, field: &str) -> Vec<Self>
pub fn field_children(&self, field: &str) -> Vec<Self>
Returns every child node bound to field.
A node can bind the same field more than once, so this returns a list rather than a single node.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Forget for BashNode<'a>
impl<'a> Freeze for BashNode<'a>
impl<'a> Move for BashNode<'a>
impl<'a> RefUnwindSafe for BashNode<'a>
impl<'a> Send for BashNode<'a>
impl<'a> Sync for BashNode<'a>
impl<'a> Unpin for BashNode<'a>
impl<'a> UnsafeUnpin for BashNode<'a>
impl<'a> UnwindSafe for BashNode<'a>
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