Struct rowan::api::SyntaxNode
source · [−]pub struct SyntaxNode<L: Language> { /* private fields */ }
Implementations
sourceimpl<L: Language> SyntaxNode<L>
impl<L: Language> SyntaxNode<L>
pub fn new_root(green: GreenNode) -> SyntaxNode<L>
sourcepub fn replace_with(&self, replacement: GreenNode) -> GreenNode
pub fn replace_with(&self, replacement: GreenNode) -> GreenNode
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
pub fn kind(&self) -> L::Kind
pub fn text_range(&self) -> TextRange
pub fn index(&self) -> usize
pub fn text(&self) -> SyntaxText
pub fn green(&self) -> Cow<'_, GreenNodeData>
pub fn parent(&self) -> Option<SyntaxNode<L>>
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>>
pub fn children(&self) -> SyntaxNodeChildren<L>ⓘNotable traits for SyntaxNodeChildren<L>impl<L: Language> Iterator for SyntaxNodeChildren<L> type Item = SyntaxNode<L>;
pub fn children_with_tokens(&self) -> SyntaxElementChildren<L>ⓘNotable traits for SyntaxElementChildren<L>impl<L: Language> Iterator for SyntaxElementChildren<L> type Item = SyntaxElement<L>;
pub fn first_child(&self) -> Option<SyntaxNode<L>>
pub fn last_child(&self) -> Option<SyntaxNode<L>>
pub fn first_child_or_token(&self) -> Option<SyntaxElement<L>>
pub fn last_child_or_token(&self) -> Option<SyntaxElement<L>>
pub fn next_sibling(&self) -> Option<SyntaxNode<L>>
pub fn prev_sibling(&self) -> Option<SyntaxNode<L>>
pub fn next_sibling_or_token(&self) -> Option<SyntaxElement<L>>
pub fn prev_sibling_or_token(&self) -> Option<SyntaxElement<L>>
sourcepub fn first_token(&self) -> Option<SyntaxToken<L>>
pub fn first_token(&self) -> Option<SyntaxToken<L>>
Return the leftmost token in the subtree of this node.
sourcepub fn last_token(&self) -> Option<SyntaxToken<L>>
pub fn last_token(&self) -> Option<SyntaxToken<L>>
Return the rightmost token in the subtree of this node.
pub fn siblings(
&self,
direction: Direction
) -> impl Iterator<Item = SyntaxNode<L>>
pub fn siblings_with_tokens(
&self,
direction: Direction
) -> impl Iterator<Item = SyntaxElement<L>>
pub fn descendants(&self) -> impl Iterator<Item = SyntaxNode<L>>
pub fn descendants_with_tokens(&self) -> impl Iterator<Item = SyntaxElement<L>>
sourcepub fn preorder(&self) -> Preorder<L>ⓘNotable traits for Preorder<L>impl<L: Language> Iterator for Preorder<L> type Item = WalkEvent<SyntaxNode<L>>;
pub fn preorder(&self) -> Preorder<L>ⓘNotable traits for Preorder<L>impl<L: Language> Iterator for Preorder<L> type Item = WalkEvent<SyntaxNode<L>>;
Traverse the subtree rooted at the current node (including the current node) in preorder, excluding tokens.
sourcepub fn preorder_with_tokens(&self) -> PreorderWithTokens<L>ⓘNotable traits for PreorderWithTokens<L>impl<L: Language> Iterator for PreorderWithTokens<L> type Item = WalkEvent<SyntaxElement<L>>;
pub fn preorder_with_tokens(&self) -> PreorderWithTokens<L>ⓘNotable traits for PreorderWithTokens<L>impl<L: Language> Iterator for PreorderWithTokens<L> type Item = WalkEvent<SyntaxElement<L>>;
Traverse the subtree rooted at the current node (including the current node) in preorder, including tokens.
sourcepub fn token_at_offset(&self, offset: TextSize) -> TokenAtOffset<SyntaxToken<L>>ⓘNotable traits for TokenAtOffset<T>impl<T> Iterator for TokenAtOffset<T> type Item = T;
pub fn token_at_offset(&self, offset: TextSize) -> TokenAtOffset<SyntaxToken<L>>ⓘNotable traits for TokenAtOffset<T>impl<T> Iterator for TokenAtOffset<T> type Item = T;
Find a token in the subtree corresponding to this node, which covers the offset. Precondition: offset must be withing node’s range.
sourcepub fn covering_element(&self, range: TextRange) -> SyntaxElement<L>
pub fn covering_element(&self, range: TextRange) -> SyntaxElement<L>
Return the deepest node or token 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
sourcepub fn child_or_token_at_range(
&self,
range: TextRange
) -> Option<SyntaxElement<L>>
pub fn child_or_token_at_range(
&self,
range: TextRange
) -> Option<SyntaxElement<L>>
Finds a SyntaxElement
which intersects with a given range
. If
there are several intersecting elements, any one can be returned.
The method uses binary search internally, so it’s complexity is
O(log(N))
where N = self.children_with_tokens().count()
.
sourcepub fn clone_subtree(&self) -> SyntaxNode<L>
pub fn clone_subtree(&self) -> SyntaxNode<L>
Returns an independent copy of the subtree rooted at this node.
The parent of the returned node will be None
, the start offset will be
zero, but, otherwise, it’ll be equivalent to the source node.
pub fn clone_for_update(&self) -> SyntaxNode<L>
pub fn detach(&self)
pub fn splice_children(
&self,
to_delete: Range<usize>,
to_insert: Vec<SyntaxElement<L>>
)
Trait Implementations
sourceimpl<L: Clone + Language> Clone for SyntaxNode<L>
impl<L: Clone + Language> Clone for SyntaxNode<L>
sourcefn clone(&self) -> SyntaxNode<L>
fn clone(&self) -> SyntaxNode<L>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<L: Language> Debug for SyntaxNode<L>
impl<L: Language> Debug for SyntaxNode<L>
sourceimpl<L: Language> Display for SyntaxNode<L>
impl<L: Language> Display for SyntaxNode<L>
sourceimpl<L: Language> From<SyntaxNode<L>> for SyntaxElement<L>
impl<L: Language> From<SyntaxNode<L>> for SyntaxElement<L>
sourcefn from(node: SyntaxNode<L>) -> SyntaxElement<L>
fn from(node: SyntaxNode<L>) -> SyntaxElement<L>
Performs the conversion.
sourceimpl<L: Language> From<SyntaxNode<L>> for SyntaxNode
impl<L: Language> From<SyntaxNode<L>> for SyntaxNode
sourcefn from(node: SyntaxNode<L>) -> SyntaxNode
fn from(node: SyntaxNode<L>) -> SyntaxNode
Performs the conversion.
sourceimpl<L: Language> From<SyntaxNode> for SyntaxNode<L>
impl<L: Language> From<SyntaxNode> for SyntaxNode<L>
sourcefn from(raw: SyntaxNode) -> SyntaxNode<L>
fn from(raw: SyntaxNode) -> SyntaxNode<L>
Performs the conversion.
sourceimpl<L: Hash + Language> Hash for SyntaxNode<L>
impl<L: Hash + Language> Hash for SyntaxNode<L>
sourceimpl<L: PartialEq + Language> PartialEq<SyntaxNode<L>> for SyntaxNode<L>
impl<L: PartialEq + Language> PartialEq<SyntaxNode<L>> for SyntaxNode<L>
sourcefn eq(&self, other: &SyntaxNode<L>) -> bool
fn eq(&self, other: &SyntaxNode<L>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SyntaxNode<L>) -> bool
fn ne(&self, other: &SyntaxNode<L>) -> bool
This method tests for !=
.
impl<L: Eq + Language> Eq for SyntaxNode<L>
impl<L: Language> StructuralEq for SyntaxNode<L>
impl<L: Language> StructuralPartialEq for SyntaxNode<L>
Auto Trait Implementations
impl<L> !RefUnwindSafe for SyntaxNode<L>
impl<L> !Send for SyntaxNode<L>
impl<L> !Sync for SyntaxNode<L>
impl<L> Unpin for SyntaxNode<L> where
L: Unpin,
impl<L> !UnwindSafe for SyntaxNode<L>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more