[−][src]Struct rowan::syntax::Token
Token in the syntax tree.
Methods
impl<Lang: Language> Token<Lang>
[src]
Constructors and transformations between Token
s and Node
s.
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]
&self,
replacement: impl Into<NodeOrToken<Arc<GreenNode>, Arc<GreenToken>>>
) -> NodeOrToken<Arc<GreenNode>, Arc<GreenToken>>
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
Auto Trait Implementations
impl<Lang> !Send for Token<Lang>
impl<Lang> !Sync for Token<Lang>
impl<Lang> Unpin for Token<Lang> where
Lang: Unpin,
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]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,