pub struct SyntaxNode { /* private fields */ }Expand description
A node with a position.
Built on demand from a green node plus the offset it sits at and the parent it hangs from. Cheap to make and cheap to drop; nothing caches them.
Implementations§
Source§impl SyntaxNode
impl SyntaxNode
Sourcepub fn ancestors(&self) -> Vec<Arc<Self>>
pub fn ancestors(&self) -> Vec<Arc<Self>>
The chain from this node up to the root, this node first.
Sourcepub fn children(self: &Arc<Self>) -> Vec<Arc<Self>>
pub fn children(self: &Arc<Self>) -> Vec<Arc<Self>>
Its child nodes, with their positions filled in.
Sourcepub fn tokens(&self) -> Vec<(Span, GreenToken)>
pub fn tokens(&self) -> Vec<(Span, GreenToken)>
Its direct tokens, with their positions.
Sourcepub fn syntax_tokens(&self) -> Vec<(Span, GreenToken)>
pub fn syntax_tokens(&self) -> Vec<(Span, GreenToken)>
The node’s own tokens with the trivia left out.
SyntaxNode::tokens keeps everything, because the round trip
needs it. A rule asking what a node says wants this one: the
first token of @ key is @, and the one after it is key,
not the space between them.
Sourcepub fn descendants(self: &Arc<Self>) -> Vec<Arc<Self>>
pub fn descendants(self: &Arc<Self>) -> Vec<Arc<Self>>
Every node in the subtree, this one first, in source order.
Sourcepub fn has_errors(self: &Arc<Self>) -> bool
pub fn has_errors(self: &Arc<Self>) -> bool
Whether this node or any below it came from recovery.
Trait Implementations§
Source§impl Clone for SyntaxNode
impl Clone for SyntaxNode
Source§impl Debug for SyntaxNode
impl Debug for SyntaxNode
Auto Trait Implementations§
impl Freeze for SyntaxNode
impl RefUnwindSafe for SyntaxNode
impl Send for SyntaxNode
impl Sync for SyntaxNode
impl Unpin for SyntaxNode
impl UnsafeUnpin for SyntaxNode
impl UnwindSafe for SyntaxNode
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