pub struct SyntaxToken {
pub token: SyntaxToken<Language>,
pub source_file: SourceFile,
}
Fields§
§token: SyntaxToken<Language>
§source_file: SourceFile
Implementations§
Source§impl SyntaxToken
impl SyntaxToken
pub fn parent(&self) -> SyntaxNode
pub fn parent_ancestors(&self) -> impl Iterator<Item = SyntaxNode> + '_
pub fn next_token(&self) -> Option<SyntaxToken>
pub fn prev_token(&self) -> Option<SyntaxToken>
pub fn text(&self) -> &str
Methods from Deref<Target = SyntaxToken<Language>>§
Sourcepub fn replace_with(&self, new_token: GreenToken) -> GreenNode
pub fn replace_with(&self, new_token: GreenToken) -> GreenNode
Returns a green tree, equal to the green tree this token belongs to, except with this token substituted. The complexity of the operation is proportional to the depth of the tree.
pub fn kind(&self) -> <L as Language>::Kind
pub fn text_range(&self) -> TextRange
pub fn index(&self) -> usize
pub fn text(&self) -> &str
pub fn green(&self) -> &GreenTokenData
pub fn parent(&self) -> Option<SyntaxNode<L>>
Sourcepub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>>
👎Deprecated: use SyntaxToken::parent_ancestors
instead
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>>
SyntaxToken::parent_ancestors
insteadIterator over all the ancestors of this token excluding itself.
Sourcepub fn parent_ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>>
pub fn parent_ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>>
Iterator over all the ancestors of this token excluding itself.
pub fn next_sibling_or_token( &self, ) -> Option<NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>>
pub fn prev_sibling_or_token( &self, ) -> Option<NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>>
pub fn siblings_with_tokens( &self, direction: Direction, ) -> impl Iterator<Item = NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>>
Sourcepub fn next_token(&self) -> Option<SyntaxToken<L>>
pub fn next_token(&self) -> Option<SyntaxToken<L>>
Next token in the tree (i.e, not necessary a sibling).
Sourcepub fn prev_token(&self) -> Option<SyntaxToken<L>>
pub fn prev_token(&self) -> Option<SyntaxToken<L>>
Previous token in the tree (i.e, not necessary a sibling).
pub fn detach(&self)
Trait Implementations§
Source§impl Clone for SyntaxToken
impl Clone for SyntaxToken
Source§fn clone(&self) -> SyntaxToken
fn clone(&self) -> SyntaxToken
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SyntaxToken
impl Debug for SyntaxToken
Source§impl Deref for SyntaxToken
impl Deref for SyntaxToken
Source§impl Display for SyntaxToken
impl Display for SyntaxToken
Source§impl From<SyntaxToken> for NodeOrToken
impl From<SyntaxToken> for NodeOrToken
Source§fn from(value: SyntaxToken) -> Self
fn from(value: SyntaxToken) -> Self
Converts to this type from the input type.
Source§impl Spanned for SyntaxToken
impl Spanned for SyntaxToken
fn span(&self) -> Span
fn source_file(&self) -> Option<&SourceFile>
fn to_source_location(&self) -> SourceLocation
Auto Trait Implementations§
impl Freeze for SyntaxToken
impl !RefUnwindSafe for SyntaxToken
impl !Send for SyntaxToken
impl !Sync for SyntaxToken
impl Unpin for SyntaxToken
impl !UnwindSafe for SyntaxToken
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<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