Struct rowan::ast::SyntaxNodePtr
source · [−]pub struct SyntaxNodePtr<L: Language> { /* private fields */ }
Expand description
A “pointer” to a SyntaxNode
, via location in the source code.
Implementations
sourceimpl<L: Language> SyntaxNodePtr<L>
impl<L: Language> SyntaxNodePtr<L>
sourcepub fn new(node: &SyntaxNode<L>) -> Self
pub fn new(node: &SyntaxNode<L>) -> Self
Returns a SyntaxNodePtr
for the node.
sourcepub fn to_node(&self, root: &SyntaxNode<L>) -> SyntaxNode<L>
pub fn to_node(&self, root: &SyntaxNode<L>) -> SyntaxNode<L>
“Dereferences” the pointer to get the SyntaxNode
it points to.
Panics if node is not found, so make sure that root
syntax tree is
equivalent (is build from the same text) to the tree which was
originally used to get this SyntaxNodePtr
.
Also panics if root
is not actually a root (i.e. it has a parent).
The complexity is linear in the depth of the tree and logarithmic in
tree width. As most trees are shallow, thinking about this as
O(log(N))
in the size of the tree is not too wrong!
Trait Implementations
sourceimpl<L: Clone + Language> Clone for SyntaxNodePtr<L> where
L::Kind: Clone,
impl<L: Clone + Language> Clone for SyntaxNodePtr<L> where
L::Kind: Clone,
sourcefn clone(&self) -> SyntaxNodePtr<L>
fn clone(&self) -> SyntaxNodePtr<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<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr<N::Language>
impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr<N::Language>
sourcefn from(ptr: AstPtr<N>) -> SyntaxNodePtr<N::Language>
fn from(ptr: AstPtr<N>) -> SyntaxNodePtr<N::Language>
Converts to this type from the input type.
sourceimpl<L: PartialEq + Language> PartialEq<SyntaxNodePtr<L>> for SyntaxNodePtr<L> where
L::Kind: PartialEq,
impl<L: PartialEq + Language> PartialEq<SyntaxNodePtr<L>> for SyntaxNodePtr<L> where
L::Kind: PartialEq,
sourcefn eq(&self, other: &SyntaxNodePtr<L>) -> bool
fn eq(&self, other: &SyntaxNodePtr<L>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SyntaxNodePtr<L>) -> bool
fn ne(&self, other: &SyntaxNodePtr<L>) -> bool
This method tests for !=
.
impl<L: Eq + Language> Eq for SyntaxNodePtr<L> where
L::Kind: Eq,
impl<L: Language> StructuralEq for SyntaxNodePtr<L>
impl<L: Language> StructuralPartialEq for SyntaxNodePtr<L>
Auto Trait Implementations
impl<L> RefUnwindSafe for SyntaxNodePtr<L> where
<L as Language>::Kind: RefUnwindSafe,
impl<L> Send for SyntaxNodePtr<L> where
<L as Language>::Kind: Send,
impl<L> Sync for SyntaxNodePtr<L> where
<L as Language>::Kind: Sync,
impl<L> Unpin for SyntaxNodePtr<L> where
<L as Language>::Kind: Unpin,
impl<L> UnwindSafe for SyntaxNodePtr<L> where
<L as Language>::Kind: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more