mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Rename ra_syntax -> syntax
This commit is contained in:
parent
3d6889cba7
commit
a1c187eef3
958 changed files with 353 additions and 363 deletions
|
@ -1,41 +0,0 @@
|
|||
//! This file is actually hand-written, but the submodules are indeed generated.
|
||||
#[rustfmt::skip]
|
||||
mod nodes;
|
||||
#[rustfmt::skip]
|
||||
mod tokens;
|
||||
|
||||
use crate::{
|
||||
AstNode,
|
||||
SyntaxKind::{self, *},
|
||||
SyntaxNode,
|
||||
};
|
||||
|
||||
pub use {nodes::*, tokens::*};
|
||||
|
||||
// Stmt is the only nested enum, so it's easier to just hand-write it
|
||||
impl AstNode for Stmt {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
LET_STMT | EXPR_STMT => true,
|
||||
_ => Item::can_cast(kind),
|
||||
}
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
let res = match syntax.kind() {
|
||||
LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
|
||||
EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
|
||||
_ => {
|
||||
let item = Item::cast(syntax)?;
|
||||
Stmt::Item(item)
|
||||
}
|
||||
};
|
||||
Some(res)
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode {
|
||||
match self {
|
||||
Stmt::LetStmt(it) => &it.syntax,
|
||||
Stmt::ExprStmt(it) => &it.syntax,
|
||||
Stmt::Item(it) => it.syntax(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue