pub struct NodePtr { /* private fields */ }Expand description
A location-based handle to a syntax node: its SyntaxKind plus its text
range. Cheap (Copy), serializable, and resolvable to a live SyntaxNode
via NodePtr::try_to_node.
Implementations§
Source§impl NodePtr
impl NodePtr
Sourcepub fn from_node(node: &SyntaxNode) -> Self
pub fn from_node(node: &SyntaxNode) -> Self
Capture a handle to node.
Sourcepub fn kind(&self) -> SyntaxKind
pub fn kind(&self) -> SyntaxKind
The kind of node this points to.
Sourcepub fn text_range(&self) -> TextRange
pub fn text_range(&self) -> TextRange
The text range this points to.
Sourcepub fn with_range(self, range: TextRange) -> Self
pub fn with_range(self, range: TextRange) -> Self
Return a copy pointing at range, keeping the kind. Used after mapping
the range across an edit.
Sourcepub fn try_to_node(&self, root: &SyntaxNode) -> Option<SyntaxNode>
pub fn try_to_node(&self, root: &SyntaxNode) -> Option<SyntaxNode>
Resolve this handle to a node in root, which must be a root built from
the same text the handle was taken against (or a range already mapped onto
that text). Returns None if root is not a root, the range falls
outside it, or no node of the stored kind spans exactly the stored range.
Trait Implementations§
impl Copy for NodePtr
Source§impl<'de> Deserialize<'de> for NodePtr
impl<'de> Deserialize<'de> for NodePtr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for NodePtr
impl StructuralPartialEq for NodePtr
Auto Trait Implementations§
impl Freeze for NodePtr
impl RefUnwindSafe for NodePtr
impl Send for NodePtr
impl Sync for NodePtr
impl Unpin for NodePtr
impl UnsafeUnpin for NodePtr
impl UnwindSafe for NodePtr
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