pub struct SyntaxNode(/* private fields */);Expand description
A node in the untyped syntax tree.
Implementations§
Source§impl SyntaxNode
 
impl SyntaxNode
Source§impl SyntaxNode
 
impl SyntaxNode
Sourcepub fn leaf(kind: SyntaxKind, text: impl Into<EcoString>) -> Self
 
pub fn leaf(kind: SyntaxKind, text: impl Into<EcoString>) -> Self
Create a new leaf node.
Sourcepub fn inner(kind: SyntaxKind, children: Vec<SyntaxNode>) -> Self
 
pub fn inner(kind: SyntaxKind, children: Vec<SyntaxNode>) -> Self
Create a new inner node with children.
Sourcepub fn error(error: SyntaxError, text: impl Into<EcoString>) -> Self
 
pub fn error(error: SyntaxError, text: impl Into<EcoString>) -> Self
Create a new error node.
Sourcepub const fn placeholder(kind: SyntaxKind) -> Self
 
pub const fn placeholder(kind: SyntaxKind) -> Self
Create a dummy node of the given kind.
Panics if kind is SyntaxKind::Error.
Sourcepub fn kind(&self) -> SyntaxKind
 
pub fn kind(&self) -> SyntaxKind
The type of the node.
Sourcepub fn text(&self) -> &EcoString
 
pub fn text(&self) -> &EcoString
The text of the node if it is a leaf or error node.
Returns the empty string if this is an inner node.
Sourcepub fn into_text(self) -> EcoString
 
pub fn into_text(self) -> EcoString
Extract the text from the node.
Builds the string if this is an inner node.
Sourcepub fn children(&self) -> Iter<'_, SyntaxNode>
 
pub fn children(&self) -> Iter<'_, SyntaxNode>
The node’s children.
Sourcepub fn errors(&self) -> Vec<SyntaxError>
 
pub fn errors(&self) -> Vec<SyntaxError>
The error messages for this node and its descendants.
Sourcepub fn hint(&mut self, hint: impl Into<EcoString>)
 
pub fn hint(&mut self, hint: impl Into<EcoString>)
Add a user-presentable hint if this is an error node.
Sourcepub fn synthesize(&mut self, span: Span)
 
pub fn synthesize(&mut self, span: Span)
Set a synthetic span for the node and all its descendants.
Sourcepub fn spanless_eq(&self, other: &Self) -> bool
 
pub fn spanless_eq(&self, other: &Self) -> bool
Whether the two syntax nodes are the same apart from spans.
Trait Implementations§
Source§impl Clone for SyntaxNode
 
impl Clone for SyntaxNode
Source§fn clone(&self) -> SyntaxNode
 
fn clone(&self) -> SyntaxNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moreSource§impl Debug for SyntaxNode
 
impl Debug for SyntaxNode
Source§impl Default for SyntaxNode
 
impl Default for SyntaxNode
Source§impl Hash for SyntaxNode
 
impl Hash for SyntaxNode
Source§impl PartialEq for SyntaxNode
 
impl PartialEq for SyntaxNode
impl Eq for SyntaxNode
impl StructuralPartialEq 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 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
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
Compare self to 
key and return true if they are equal.Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more