[][src]Struct rowan::syntax::Node

pub struct Node<Lang = Generic> { /* fields omitted */ }

Node (or token) in the syntax tree.

Methods

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

Constructors and transformations between Nodes and Tokens.

pub fn new_root(
    green: impl Into<NodeOrToken<Arc<GreenNode>, Arc<GreenToken>>>,
    lang: Lang
) -> Self
[src]

Create a new root syntax node.

pub fn generic(self) -> Node<Generic>[src]

A generic version of this node without language-specific behavior.

pub fn with_lang<L>(self, lang: L) -> Node<L>[src]

This node with language-specific behavior.

pub fn is_token(&self) -> bool[src]

Is this node a token?

Note: it is possible for a node to be backed by a green token without being a token, if the green token represents an unparsed subtree. For more info, see Language::is_token.

pub fn as_token(&self) -> Option<&Token<Lang>>[src]

Convert this node into a token.

Panics

Panics if the node is not backed by a green token.

For a non-panicking version, use Token::new_ref.

pub fn into_token(self) -> Token<Lang>[src]

Convert this node into a token.

Panics

Panics if the node is not a token or is not backed by a green token.

For a non-panicking version, use Token::new.

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

Tree traversal iterators.

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

Walk this subtree, including this node.

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

All nodes in this subtree in preorder, including this node.

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

All nodes in this subtree in postorder, including this node.

Important traits for Children<Lang>
pub fn children(self) -> Children<Lang>[src]

Child nodes (or tokens) of this node.

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

Children non-token subtrees of this node.

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

Sibling trees (and tokens) starting at and including this node.

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

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

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

Accessors.

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

The green element backing this syntax node.

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

The kind of this node.

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

The text of this node.

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

The range of text this node covers.

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 node.

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

The next token or node of this node's parent.

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

The next non-token node of this node's parent.

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

The previous token or node of this node's parent.

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

The previous non-token node of this node's parent.

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

The first child node or token of this node.

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

The first child non-token subtree of this node.

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

The last child node or token of this node.

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

The last child non-token subtree of this node.

Trait Implementations

impl<Lang> Drop for Node<Lang>[src]

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

impl<Lang: Language> Eq for Node<Lang>[src]

impl<Lang: Language> PartialEq<Node<Lang>> for Node<Lang>[src]

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

impl<Lang: Language> Hash for Node<Lang>[src]

Auto Trait Implementations

impl<Lang = Generic> !Send for Node<Lang>

impl<Lang = Generic> !Sync for Node<Lang>

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

impl<Lang = Generic> !UnwindSafe for Node<Lang>

impl<Lang = Generic> !RefUnwindSafe for Node<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]