pub struct SyntaxNode<'a> { /* private fields */ }Expand description
A borrowed handle to one node in a SyntaxTree.
Implementations§
Source§impl<'a> SyntaxNode<'a>
impl<'a> SyntaxNode<'a>
pub fn id(self) -> NodeId
Sourcepub fn tree(self) -> &'a SyntaxTree
pub fn tree(self) -> &'a SyntaxTree
The tree this node belongs to.
Needed to resolve the NodeIds handed out by Self::children,
which is how a caller walks nodes and tokens together in source order.
pub fn kind(self) -> SyntaxKind
pub fn range(self) -> TextRange
Sourcepub fn children(self) -> impl Iterator<Item = Element> + 'a
pub fn children(self) -> impl Iterator<Item = Element> + 'a
Direct children, nodes and tokens interleaved in source order.
Sourcepub fn child_nodes(self) -> impl Iterator<Item = SyntaxNode<'a>> + 'a
pub fn child_nodes(self) -> impl Iterator<Item = SyntaxNode<'a>> + 'a
Direct child nodes, skipping tokens.
Sourcepub fn child_tokens(self) -> impl Iterator<Item = Token> + 'a
pub fn child_tokens(self) -> impl Iterator<Item = Token> + 'a
Direct child tokens, skipping nodes.
Sourcepub fn child_node_of(self, kind: SyntaxKind) -> Option<SyntaxNode<'a>>
pub fn child_node_of(self, kind: SyntaxKind) -> Option<SyntaxNode<'a>>
The first direct child node of the given kind.
Sourcepub fn child_token_of(self, kind: SyntaxKind) -> Option<Token>
pub fn child_token_of(self, kind: SyntaxKind) -> Option<Token>
The first direct child token of the given kind.
Sourcepub fn descendants(self) -> Descendants<'a> ⓘ
pub fn descendants(self) -> Descendants<'a> ⓘ
Every node in this subtree, parents before children.
Trait Implementations§
Source§impl<'a> Clone for SyntaxNode<'a>
impl<'a> Clone for SyntaxNode<'a>
Source§fn clone(&self) -> SyntaxNode<'a>
fn clone(&self) -> SyntaxNode<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for SyntaxNode<'a>
Auto Trait Implementations§
impl<'a> Freeze for SyntaxNode<'a>
impl<'a> RefUnwindSafe for SyntaxNode<'a>
impl<'a> Send for SyntaxNode<'a>
impl<'a> Sync for SyntaxNode<'a>
impl<'a> Unpin for SyntaxNode<'a>
impl<'a> UnsafeUnpin for SyntaxNode<'a>
impl<'a> UnwindSafe for SyntaxNode<'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