[−][src]Struct rowan::SyntaxNode
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]
impl<T: Types> SyntaxNode<T>
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]
impl<T: Types> SyntaxNode<T>
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( | [src] |
All ancestors of the current node, including itself
pub fn preorder( | [src] |
Traverse the subtree rooted at the current node (including the current node) in preorder.
pub fn common_ancestor<'a>( | [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]
impl<T: Types> TransparentNewType for SyntaxNode<T>
type Repr = SyntaxNode<T>
Underlying representation of a newtype.
fn from_repr(repr: &Self::Repr) -> &Self | [src] |
fn into_repr(&self) -> &Self::Repr | [src] |
impl<T: Types> Eq for SyntaxNode<T>
[src]
impl<T: Types> Eq for SyntaxNode<T>
impl<T: Types> PartialEq<SyntaxNode<T>> for SyntaxNode<T>
[src]
impl<T: Types> PartialEq<SyntaxNode<T>> for SyntaxNode<T>
fn eq(&self, other: &SyntaxNode<T>) -> bool | [src] |
| 1.0.0 [src] |
This method tests for !=
.
impl<T: Types> ToOwned for SyntaxNode<T>
[src]
impl<T: Types> ToOwned for SyntaxNode<T>
type Owned = TreeArc<T, SyntaxNode<T>>
fn to_owned(&self) -> TreeArc<T, SyntaxNode<T>> | [src] |
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> Send for SyntaxNode<T> where
T: Types,
T::RootData: Send,
T::Kind: Send,
[src]
impl<T> Send for SyntaxNode<T> where
T: Types,
T::RootData: Send,
T::Kind: Send,
impl<T> Sync for SyntaxNode<T> where
T: Types,
T::RootData: Sync + Send,
T::Kind: Sync + Send,
[src]
impl<T> Sync for SyntaxNode<T> where
T: Types,
T::RootData: Sync + Send,
T::Kind: Sync + Send,
impl<T: Types> Debug for SyntaxNode<T>
[src]
impl<T: Types> Debug for SyntaxNode<T>
impl<T: Types> Hash for SyntaxNode<T>
[src]
impl<T: Types> Hash for SyntaxNode<T>
fn hash<H: Hasher>(&self, state: &mut H) | [src] |
fn hash_slice<H>(data: &[Self], state: &mut H) where | 1.3.0 [src] |
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: Types> Display for SyntaxNode<T>
[src]
impl<T: Types> Display for SyntaxNode<T>
impl<T> RefUnwindSafe for SyntaxNode<T> where
T: Types,
T::RootData: RefUnwindSafe + UnwindSafe,
T::Kind: RefUnwindSafe + UnwindSafe,
[src]
impl<T> RefUnwindSafe for SyntaxNode<T> where
T: Types,
T::RootData: RefUnwindSafe + UnwindSafe,
T::Kind: RefUnwindSafe + UnwindSafe,
impl<T> UnwindSafe for SyntaxNode<T> where
T: Types,
T::RootData: UnwindSafe,
T::Kind: UnwindSafe,
[src]
impl<T> UnwindSafe for SyntaxNode<T> where
T: Types,
T::RootData: UnwindSafe,
T::Kind: UnwindSafe,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T> ToString for T where
T: Display + ?Sized,
[src]
impl<T> ToString for T where
T: Display + ?Sized,
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)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> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId | [src] |
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T | [src] |
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> | [src] |
impl<T> Erased for T
impl<T> Erased for T