pub struct AstPtr<N: AstNode> { /* private fields */ }Expand description
A lightweight pointer to an AST node, resolvable against a syntax tree.
Stores the node’s SyntaxKind and TextRange — enough to find it again
given the tree root, without holding an Arc reference to the green tree.
Follows the pattern used by rust-analyzer’s AstPtr.
Implementations§
Source§impl<N: AstNode> AstPtr<N>
impl<N: AstNode> AstPtr<N>
Sourcepub fn text_range(&self) -> TextRange
pub fn text_range(&self) -> TextRange
The text range this pointer points to.
Sourcepub fn syntax_kind(&self) -> SyntaxKind
pub fn syntax_kind(&self) -> SyntaxKind
The syntax kind of the pointed-to node.
Sourcepub fn resolve(&self, root: &SyntaxNode) -> Option<N>
pub fn resolve(&self, root: &SyntaxNode) -> Option<N>
Resolve this pointer back to a live AST node.
Walks the tree from root to find a node with matching kind and range.
Returns None if the tree has been reparsed and no matching node exists
(stale pointer).
Trait Implementations§
impl<N: AstNode> Copy for AstPtr<N>
impl<N: AstNode> Eq for AstPtr<N>
Auto Trait Implementations§
impl<N> Freeze for AstPtr<N>
impl<N> RefUnwindSafe for AstPtr<N>
impl<N> Send for AstPtr<N>
impl<N> Sync for AstPtr<N>
impl<N> Unpin for AstPtr<N>
impl<N> UnsafeUnpin for AstPtr<N>
impl<N> UnwindSafe for AstPtr<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more