pub struct AstPtr {
pub kind: SyntaxKind,
pub range: TextRange,
}Expand description
A reparse-stable pointer to a syntax node — its SyntaxKind plus byte TextRange
(rust-analyzer’s SyntaxNodePtr). Because it is plain Copy data keyed on text
position, identical source re-parses to the identical pointer, which is what lets the
crate::item_tree::ItemTree stay Eq while still being able to recover the CST node
for deferred body lowering / initializer inference.
Fields§
§kind: SyntaxKindThe pointed-to node’s kind.
range: TextRangeThe pointed-to node’s byte range.
Implementations§
Source§impl AstPtr
impl AstPtr
Sourcepub fn to_node(self, root: &GdNode) -> Option<GdNode>
pub fn to_node(self, root: &GdNode) -> Option<GdNode>
Recover the node this pointer refers to, searching from root. None if the tree
no longer contains a node of the matching kind + range (e.g. recovered from a stale
pointer against edited text).
Prunes by range — only descends into the one child subtree that contains the target — so
recovery is ~O(tree depth), not O(nodes). This is on the hot path (called per function /
field / TypeRef during inference), so the pruning is what keeps single-file analysis
within the warm budget.
Trait Implementations§
impl Copy for AstPtr
impl Eq for AstPtr
impl StructuralPartialEq for AstPtr
Auto Trait Implementations§
impl Freeze for AstPtr
impl RefUnwindSafe for AstPtr
impl Send for AstPtr
impl Sync for AstPtr
impl Unpin for AstPtr
impl UnsafeUnpin for AstPtr
impl UnwindSafe for AstPtr
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.