pub trait SgNode<'r>: Clone {
Show 23 methods
// Required methods
fn parent(&self) -> Option<Self>;
fn children(&self) -> impl ExactSizeIterator<Item = Self>;
fn kind(&self) -> Cow<'_, str>;
fn kind_id(&self) -> u16;
fn node_id(&self) -> usize;
fn range(&self) -> Range<usize>;
fn start_pos(&self) -> Position;
fn end_pos(&self) -> Position;
fn field(&self, name: &str) -> Option<Self>;
fn field_children(
&self,
field_id: Option<u16>,
) -> impl Iterator<Item = Self>;
fn child_by_field_id(&self, field_id: u16) -> Option<Self>;
// Provided methods
fn ancestors(&self, _root: Self) -> impl Iterator<Item = Self> { ... }
fn dfs(&self) -> impl Iterator<Item = Self> { ... }
fn child(&self, nth: usize) -> Option<Self> { ... }
fn next(&self) -> Option<Self> { ... }
fn prev(&self) -> Option<Self> { ... }
fn next_all(&self) -> impl Iterator<Item = Self> { ... }
fn prev_all(&self) -> impl Iterator<Item = Self> { ... }
fn is_named(&self) -> bool { ... }
fn is_named_leaf(&self) -> bool { ... }
fn is_leaf(&self) -> bool { ... }
fn is_missing(&self) -> bool { ... }
fn is_error(&self) -> bool { ... }
}
Expand description
NOTE: Some method names are the same as tree-sitter’s methods. Fully Qualified Syntax may needed https://stackoverflow.com/a/44445976/2198656
Required Methods§
fn parent(&self) -> Option<Self>
fn children(&self) -> impl ExactSizeIterator<Item = Self>
fn kind(&self) -> Cow<'_, str>
fn kind_id(&self) -> u16
fn node_id(&self) -> usize
fn range(&self) -> Range<usize>
fn start_pos(&self) -> Position
fn end_pos(&self) -> Position
fn field(&self, name: &str) -> Option<Self>
fn field_children(&self, field_id: Option<u16>) -> impl Iterator<Item = Self>
fn child_by_field_id(&self, field_id: u16) -> Option<Self>
Provided Methods§
fn ancestors(&self, _root: Self) -> impl Iterator<Item = Self>
fn dfs(&self) -> impl Iterator<Item = Self>
fn child(&self, nth: usize) -> Option<Self>
fn next(&self) -> Option<Self>
fn prev(&self) -> Option<Self>
fn next_all(&self) -> impl Iterator<Item = Self>
fn prev_all(&self) -> impl Iterator<Item = Self>
fn is_named(&self) -> bool
Sourcefn is_named_leaf(&self) -> bool
fn is_named_leaf(&self) -> bool
N.B. it is different from is_named && is_leaf if a node has no named children.
fn is_leaf(&self) -> bool
fn is_missing(&self) -> bool
fn is_error(&self) -> bool
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'r> SgNode<'r> for Node<'r>
impl<'r> SgNode<'r> for Node<'r>
Source§fn is_named_leaf(&self) -> bool
fn is_named_leaf(&self) -> bool
N.B. it is different from is_named && is_leaf if a node has no named children.