Merge commit '3b7c7f97e4' into sync-from-ra

This commit is contained in:
Laurențiu Nicola 2023-11-08 08:15:03 +02:00
parent 6eaf3f8bb2
commit d1d111d09e
177 changed files with 14930 additions and 2099 deletions

View file

@ -73,6 +73,10 @@ impl<N: AstNode> AstPtr<N> {
Some(AstPtr { raw: self.raw, _ty: PhantomData })
}
pub fn kind(&self) -> parser::SyntaxKind {
self.raw.kind()
}
pub fn upcast<M: AstNode>(self) -> AstPtr<M>
where
N: Into<M>,
@ -84,6 +88,20 @@ impl<N: AstNode> AstPtr<N> {
pub fn try_from_raw(raw: SyntaxNodePtr) -> Option<AstPtr<N>> {
N::can_cast(raw.kind()).then_some(AstPtr { raw, _ty: PhantomData })
}
pub fn wrap_left<R>(self) -> AstPtr<either::Either<N, R>>
where
either::Either<N, R>: AstNode,
{
AstPtr { raw: self.raw, _ty: PhantomData }
}
pub fn wrap_right<L>(self) -> AstPtr<either::Either<L, N>>
where
either::Either<L, N>: AstNode,
{
AstPtr { raw: self.raw, _ty: PhantomData }
}
}
impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr {