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>) -> SyntaxNode
pub fn leaf(kind: SyntaxKind, text: impl Into<EcoString>) -> SyntaxNode
Create a new leaf node.
Sourcepub fn inner(kind: SyntaxKind, children: Vec<SyntaxNode>) -> SyntaxNode
pub fn inner(kind: SyntaxKind, children: Vec<SyntaxNode>) -> SyntaxNode
Create a new inner node with children.
Sourcepub fn error(
message: impl Into<EcoString>,
text: impl Into<EcoString>,
) -> SyntaxNode
pub fn error( message: impl Into<EcoString>, text: impl Into<EcoString>, ) -> SyntaxNode
Create a new error node with a user-presentable message for the given text. Note that the message is the first argument, and the text causing the error is the second argument.
Sourcepub fn warn(&mut self, message: impl Into<EcoString>)
pub fn warn(&mut self, message: impl Into<EcoString>)
Add a warning message to an existing node.
Sourcepub fn warn_at(&mut self, _: Range<usize>, message: impl Into<EcoString>)
pub fn warn_at(&mut self, _: Range<usize>, message: impl Into<EcoString>)
Add a warning around this node at a particular sub-range of the node’s text. Panics if the range is empty or exceeds the length of the wrapped text.
Sourcepub fn hint(&mut self, hint: impl Into<EcoString>)
pub fn hint(&mut self, hint: impl Into<EcoString>)
Add a user-presentable hint to an existing error or warning. Panics if this is not an error or warning.
Sourcepub fn hint_at(&mut self, _: Range<usize>, hint: impl Into<EcoString>)
pub fn hint_at(&mut self, _: Range<usize>, hint: impl Into<EcoString>)
Add a user-presentable hint to an existing error or warning at a sub-range of the text. Panics if the range is empty or exceeds the length of the wrapped text. Panics if this is not an error or warning node.
Sourcepub fn with_hints(
self,
new_hints: impl IntoIterator<Item = EcoString>,
) -> SyntaxNode
pub fn with_hints( self, new_hints: impl IntoIterator<Item = EcoString>, ) -> SyntaxNode
Add multiple hints while building an error or warning. Panics if this is not an error or warning.
Sourcepub const fn placeholder(kind: SyntaxKind) -> SyntaxNode
pub const fn placeholder(kind: SyntaxKind) -> SyntaxNode
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 leaf_text(&self) -> &EcoString
pub fn leaf_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 full_text(&self) -> EcoString
pub fn full_text(&self) -> EcoString
Clone the full text from the node. If this is an inner node, it will traverse the tree to build the text which may be expensive.
Sourcepub fn children(&self) -> Iter<'_, SyntaxNode>
pub fn children(&self) -> Iter<'_, SyntaxNode>
The node’s children.
Sourcepub fn diagnosis(&self) -> Diagnosis
pub fn diagnosis(&self) -> Diagnosis
Whether the node has diagnostic errors and/or warnings in it or its
children. Diagnosis has public fields, so you can write
node.diagnosis().errors to determine if a node is erroneous.
This can be used to determine whether Self::errors_and_warnings will
return an empty vector without traversing the tree if it will not.
Sourcepub fn errors_and_warnings(
&self,
) -> (Vec<SyntaxDiagnostic>, Vec<SyntaxDiagnostic>)
pub fn errors_and_warnings( &self, ) -> (Vec<SyntaxDiagnostic>, Vec<SyntaxDiagnostic>)
The error and warning diagnostics for this node and its descendants.
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 synthesize_mapped(
&mut self,
id: FileId,
mapper: &RangeMapper,
) -> Result<(), EcoString>
pub fn synthesize_mapped( &mut self, id: FileId, mapper: &RangeMapper, ) -> Result<(), EcoString>
Set a raw range span for each node.
The range is determined by mapping the node’s ranges through the given
mapper.
Returns an error with the mapper’s length if it was shorter than the length of the source text.
Sourcepub fn spanless_eq(&self, other: &SyntaxNode) -> bool
pub fn spanless_eq(&self, other: &SyntaxNode) -> 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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SyntaxNode
impl Debug for SyntaxNode
Source§impl Default for SyntaxNode
impl Default for SyntaxNode
Source§fn default() -> SyntaxNode
fn default() -> SyntaxNode
impl Eq for SyntaxNode
Source§impl Hash for SyntaxNode
impl Hash for SyntaxNode
Source§impl PartialEq for SyntaxNode
impl PartialEq for SyntaxNode
Source§fn eq(&self, other: &SyntaxNode) -> bool
fn eq(&self, other: &SyntaxNode) -> bool
self and other values to be equal, and is used by ==.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 UnsafeUnpin for SyntaxNode
impl UnwindSafe for SyntaxNode
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
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
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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>
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>
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more