Support let...else
This commit is contained in:
@@ -722,9 +722,19 @@ impl LetStmt {
|
||||
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
|
||||
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
|
||||
pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||
pub fn let_else(&self) -> Option<LetElse> { support::child(&self.syntax) }
|
||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct LetElse {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl LetElse {
|
||||
pub fn else_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![else]) }
|
||||
pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ArrayExpr {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
@@ -2304,6 +2314,17 @@ impl AstNode for LetStmt {
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for LetElse {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == LET_ELSE }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for ArrayExpr {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
@@ -4320,6 +4341,11 @@ impl std::fmt::Display for LetStmt {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for LetElse {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for ArrayExpr {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
|
||||
@@ -198,6 +198,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
|
||||
"NAME",
|
||||
"NAME_REF",
|
||||
"LET_STMT",
|
||||
"LET_ELSE",
|
||||
"EXPR_STMT",
|
||||
"GENERIC_PARAM_LIST",
|
||||
"GENERIC_PARAM",
|
||||
|
||||
Reference in New Issue
Block a user