Added ArrayExprKind,
changed the display for fixed array types, Added Array Enum to ra_hir/expr
This commit is contained in:
@@ -17,8 +17,8 @@ pub use self::{
|
||||
generated::*,
|
||||
traits::*,
|
||||
tokens::*,
|
||||
extensions::{PathSegmentKind, StructKind, FieldKind, SelfParamKind},
|
||||
expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralKind},
|
||||
extensions::{PathSegmentKind, StructKind, SelfParamKind},
|
||||
expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralKind,ArrayExprKind},
|
||||
};
|
||||
|
||||
/// The main trait to go from untyped `SyntaxNode` to a typed ast. The
|
||||
|
||||
@@ -193,6 +193,28 @@ impl ast::BinExpr {
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ArrayExprKind<'a> {
|
||||
Repeat { initializer: Option<&'a ast::Expr>, repeat: Option<&'a ast::Expr> },
|
||||
ElementList(AstChildren<'a, ast::Expr>),
|
||||
}
|
||||
|
||||
impl ast::ArrayExpr {
|
||||
pub fn kind(&self) -> ArrayExprKind {
|
||||
if self.is_repeat() {
|
||||
ArrayExprKind::Repeat {
|
||||
initializer: children(self).nth(0),
|
||||
repeat: children(self).nth(2),
|
||||
}
|
||||
} else {
|
||||
ArrayExprKind::ElementList(children(self))
|
||||
}
|
||||
}
|
||||
|
||||
fn is_repeat(&self) -> bool {
|
||||
self.syntax().children_with_tokens().any(|it| it.kind() == SEMI)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum LiteralKind {
|
||||
String,
|
||||
|
||||
Reference in New Issue
Block a user