Generate ast nodes for each ast trait

This commit is contained in:
Lukas Wirth
2021-09-21 15:52:11 +02:00
parent ba84b91e78
commit 6d6e0b8f21
6 changed files with 480 additions and 51 deletions

View File

@@ -167,36 +167,6 @@ impl NameOwner for Macro {
impl AttrsOwner for Macro {}
/// Basically an owned `dyn AttrsOwner` without extra boxing.
pub struct AttrsOwnerNode {
node: SyntaxNode,
}
impl AttrsOwnerNode {
pub fn new<N: AttrsOwner>(node: N) -> Self {
AttrsOwnerNode { node: node.syntax().clone() }
}
}
impl AttrsOwner for AttrsOwnerNode {}
impl AstNode for AttrsOwnerNode {
fn can_cast(_: SyntaxKind) -> bool
where
Self: Sized,
{
false
}
fn cast(_: SyntaxNode) -> Option<Self>
where
Self: Sized,
{
None
}
fn syntax(&self) -> &SyntaxNode {
&self.node
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AttrKind {
Inner,