pub struct CppSyntaxId { /* private fields */ }Expand description
A cheap, storable pointer to a syntax node or token: (kind, range).
Red nodes borrow their tree, so they cannot be cached in the LSP layer; CppSyntaxId is the
serialisable substitute. It is resolvable back to a red node as long as the tree is unchanged,
which is why it must only ever be stored alongside an edit generation counter.
Implementations§
Source§impl CppSyntaxId
impl CppSyntaxId
pub fn new(kind: CppKind, range: TextRange) -> Self
pub fn from_ptr(ptr: CppSyntaxNodePtr) -> Self
pub fn from_node(node: &CppSyntaxNode) -> Self
pub fn from_token(token: &CppSyntaxToken) -> Self
pub fn get_kind(&self) -> CppSyntaxKind
pub fn get_token_kind(&self) -> CppTokenKind
pub fn is_token(&self) -> bool
pub fn is_node(&self) -> bool
pub fn get_range(&self) -> TextRange
Sourcepub fn to_node(&self, tree: &CppSyntaxTree) -> Option<CppSyntaxNode>
pub fn to_node(&self, tree: &CppSyntaxTree) -> Option<CppSyntaxNode>
Resolve back to a red node. Returns None if this id pointed at a token, if the tree is
empty, or if the tree has changed shape since the id was created.
pub fn to_node_from_root(&self, root: &CppSyntaxNode) -> Option<CppSyntaxNode>
pub fn to_token(&self, tree: &CppSyntaxTree) -> Option<CppSyntaxToken>
pub fn to_token_from_root(&self, root: &CppSyntaxNode) -> Option<CppSyntaxToken>
pub fn to_node_at_range( root: &CppSyntaxNode, range: TextRange, ) -> Option<CppSyntaxNode>
Trait Implementations§
Source§impl Clone for CppSyntaxId
impl Clone for CppSyntaxId
impl Copy for CppSyntaxId
Source§impl Debug for CppSyntaxId
impl Debug for CppSyntaxId
Source§impl<'de> Deserialize<'de> for CppSyntaxId
impl<'de> Deserialize<'de> for CppSyntaxId
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
Source§impl Display for CppSyntaxId
impl Display for CppSyntaxId
impl Eq for CppSyntaxId
Source§impl Hash for CppSyntaxId
impl Hash for CppSyntaxId
Source§impl PartialEq for CppSyntaxId
impl PartialEq for CppSyntaxId
Source§impl Serialize for CppSyntaxId
Serialised as kind:start:end, all hex.
impl Serialize for CppSyntaxId
Serialised as kind:start:end, all hex.
impl StructuralPartialEq for CppSyntaxId
Auto Trait Implementations§
impl Freeze for CppSyntaxId
impl RefUnwindSafe for CppSyntaxId
impl Send for CppSyntaxId
impl Sync for CppSyntaxId
impl Unpin for CppSyntaxId
impl UnsafeUnpin for CppSyntaxId
impl UnwindSafe for CppSyntaxId
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
Compare self to
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more