[][src]Struct rowan::syntax::Token

#[repr(transparent)]
pub struct Token<Lang> { /* fields omitted */ }

Token in the syntax tree.

Methods

impl<Lang: Language> Token<Lang>[src]

Constructors and transformations between Tokens and Nodes.

pub fn new(node: Node<Lang>) -> Option<Token<Lang>>[src]

Create a new token from a node.

This does not check if the language considers the node a token, just whether the node is backed by a green token. If you need the language check, check Node::is_token.

pub fn new_ref(node: &Node<Lang>) -> Option<&Token<Lang>>[src]

Create a new token reference from a node reference.

This does not check if the language considers the node a token, just whether the node is backed by a green token. If you need the language check, use Node::as_token.

pub fn into_node(self) -> Node<Lang>[src]

Convert this token back into a node.

pub fn as_node(&self) -> &Node<Lang>[src]

Convert this token back into a node.

impl<Lang: Language> Token<Lang>[src]

Tree traversal iterators.

pub fn ancestors(self) -> impl Iterator<Item = Node<Lang>>[src]

The parent chain from this token, starting with this node.

pub fn siblings(self, direction: Direction) -> impl Iterator<Item = Node<Lang>>[src]

Sibling trees starting at and including this token.

impl<Lang: Language> Token<Lang>[src]

Accessors.

pub fn green(&self) -> ArcBorrow<GreenToken>[src]

The green token backing this token.

pub fn kind(&self) -> Kind[src]

The kind of this token.

pub fn text(self) -> Text[src]

The text of this token.

pub fn text_range(&self) -> StrRange[src]

The range of text this token covers.

pub fn as_str(&self) -> &str[src]

The raw string of this token.

pub fn replace_with(
    &self,
    replacement: impl Into<NodeOrToken<Arc<GreenNode>, Arc<GreenToken>>>
) -> NodeOrToken<Arc<GreenNode>, Arc<GreenToken>>
[src]

Create a new green tree with this node replaced. The complexity is proportional to the depth of the tree.

pub fn parent(self) -> Option<Node<Lang>>[src]

The parent of this token.

pub fn next_sibling(self) -> Option<Node<Lang>>[src]

The next subtree of this node's parent.

pub fn prev_sibling(self) -> Option<Node<Lang>>[src]

The previous subtree of this node's parent.

Trait Implementations

impl<Lang: Clone> Clone for Token<Lang>[src]

impl<Lang: Debug> Debug for Token<Lang>[src]

Auto Trait Implementations

impl<Lang> !Send for Token<Lang>

impl<Lang> !Sync for Token<Lang>

impl<Lang> Unpin for Token<Lang> where
    Lang: Unpin

impl<Lang> !UnwindSafe for Token<Lang>

impl<Lang> !RefUnwindSafe for Token<Lang>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erasable for T[src]