[][src]Struct rowan::SyntaxNode

pub struct SyntaxNode<T: Types> { /* fields omitted */ }

Akn immutable lazy constructed syntax tree with offsets and parent pointers.

The design is close to https://github.com/apple/swift/tree/bc3189a2d265bf7728ea0cfeb55f032bfe5beaf1/lib/Syntax

All nodes constituting a tree share the ownership by a tree. Internally, and Arc is used, but outside world observes nodes as &SyntaxNode or TreeArc<SyntaxNode>, where a TreeArc is an Arc-like smart pointer.

Methods

impl<T: Types> SyntaxNode<T>
[src]

pub fn memory_size_of_red_children(&self) -> usize
[src]

Number of memory bytes of occupied by subtree rooted at self.

impl<T: Types> SyntaxNode<T>
[src]

pub fn new(green: GreenNode<T>, data: T::RootData) -> TreeArc<T, SyntaxNode<T>>
[src]

Creates a new SyntaxNode, whihc becomes the root of the tree.

pub fn green(&self) -> &GreenNode<T>
[src]

Get the green node for this node

pub fn replace_children(&self, children: Box<[GreenNode<T>]>) -> GreenNode<T>
[src]

Get the root node but with the children replaced. See replace_with.

pub fn replace_self(&self, green: GreenNode<T>) -> GreenNode<T>
[src]

Returns a green tree, equal to the green tree this node belongs two, except with this node substitute. The complexity of operation is proportional to the depth of the tree TODO: naming is unfortunate, the return value is not current node, it is the new root node.

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

Returns true if this node is a leaf node.

pub fn leaf_text<'a>(&'a self) -> Option<&'a SmolStr>
[src]

Text of this node if it is a leaf.

pub fn root_data(&self) -> &T::RootData
[src]

Get root data.

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

Get kind of this node.

pub fn range(&self) -> TextRange
[src]

Get text range, covered by this node.

pub fn parent(&self) -> Option<&SyntaxNode<T>>
[src]

Get the parent node.

pub fn first_child(&self) -> Option<&SyntaxNode<T>>
[src]

Get first child.

pub fn last_child(&self) -> Option<&SyntaxNode<T>>
[src]

Get last child.

pub fn next_sibling(&self) -> Option<&SyntaxNode<T>>
[src]

Get next sibling.

pub fn prev_sibling(&self) -> Option<&SyntaxNode<T>>
[src]

Get previous sibling.

Important traits for SyntaxNodeChildren<'a, T>
pub fn children(&self) -> SyntaxNodeChildren<T>
[src]

Get iterator over children.

pub fn ancestors(
    &self
) -> impl Iterator<Item = &SyntaxNode<T>>
[src]

All ancestors of the current node, including itself

pub fn preorder(
    &self
) -> impl Iterator<Item = WalkEvent<&SyntaxNode<T>>>
[src]

Traverse the subtree rooted at the current node (including the current node) in preorder.

pub fn common_ancestor<'a>(
    &'a self,
    other: &'a SyntaxNode<T>
) -> &'a SyntaxNode<T>
[src]

Returns common ancestor of the two nodes. Precondition: nodes must be from the same tree.

Important traits for LeafAtOffset<T>
pub fn leaf_at_offset(&self, offset: TextUnit) -> LeafAtOffset<&SyntaxNode<T>>
[src]

Find a leaf in the subtree corresponding to this node, which covers the offset. Precondition: offset must be withing node's range.

pub fn covering_node(&self, range: TextRange) -> &SyntaxNode<T>
[src]

Return the deepest node in the current subtree that fully contains the range. If the range is empty and is contained in two leaf nodes, either one can be returned. Precondition: range must be contained withing the current node

pub fn memory_size_of_subtree(&self) -> usize
[src]

Number of memory bytes of occupied by subtree rooted at self.

Trait Implementations

impl<T: Types> TransparentNewType for SyntaxNode<T>
[src]

type Repr = SyntaxNode<T>

Underlying representation of a newtype.

impl<T: Types> PartialEq<SyntaxNode<T>> for SyntaxNode<T>
[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<T: Types> Eq for SyntaxNode<T>
[src]

impl<T> Send for SyntaxNode<T> where
    T: Types,
    T::RootData: Send,
    T::Kind: Send
[src]

impl<T: Types> ToOwned for SyntaxNode<T>
[src]

type Owned = TreeArc<T, SyntaxNode<T>>

fn clone_into(&self, target: &mut Self::Owned)
[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> Sync for SyntaxNode<T> where
    T: Types,
    T::RootData: Sync + Send,
    T::Kind: Sync + Send
[src]

impl<T: Types> Display for SyntaxNode<T>
[src]

impl<T: Types> Debug for SyntaxNode<T>
[src]

impl<T: Types> Hash for SyntaxNode<T>
[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<T> UnwindSafe for SyntaxNode<T> where
    T: Types,
    T::RootData: UnwindSafe,
    T::Kind: UnwindSafe
[src]

impl<T> RefUnwindSafe for SyntaxNode<T> where
    T: Types,
    T::RootData: RefUnwindSafe + UnwindSafe,
    T::Kind: RefUnwindSafe + UnwindSafe
[src]

Blanket Implementations

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

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

type Owned = T

impl<T> From for T
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

impl<T> Erased for T