mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Add character literal parsing and validation
This commit is contained in:
parent
19c6cbd954
commit
9b5bbab104
6 changed files with 397 additions and 2 deletions
|
@ -409,6 +409,40 @@ impl<'a> AstNode<'a> for CastExpr<'a> {
|
|||
|
||||
impl<'a> CastExpr<'a> {}
|
||||
|
||||
// Char
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CharNode(SyntaxNode);
|
||||
|
||||
impl CharNode {
|
||||
pub fn ast(&self) -> Char {
|
||||
Char::cast(self.0.borrowed()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Char<'a>> for CharNode {
|
||||
fn from(ast: Char<'a>) -> CharNode {
|
||||
let syntax = ast.syntax().owned();
|
||||
CharNode(syntax)
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Char<'a> {
|
||||
syntax: SyntaxNodeRef<'a>,
|
||||
}
|
||||
|
||||
impl<'a> AstNode<'a> for Char<'a> {
|
||||
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
||||
match syntax.kind() {
|
||||
CHAR => Some(Char { syntax }),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
||||
}
|
||||
|
||||
impl<'a> Char<'a> {}
|
||||
|
||||
// Comment
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue