mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Added ArrayExprKind,
changed the display for fixed array types, Added Array Enum to ra_hir/expr
This commit is contained in:
parent
2d73c909fe
commit
e175921932
5 changed files with 76 additions and 31 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue