mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
⬆️ rust-analyzer
This commit is contained in:
parent
a1f1b95d00
commit
9d2cb42a41
45 changed files with 766 additions and 242 deletions
|
@ -806,6 +806,19 @@ impl ast::GenericParamList {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::ForExpr {
|
||||
pub fn iterable(&self) -> Option<ast::Expr> {
|
||||
// If the iterable is a BlockExpr, check if the body is missing.
|
||||
// If it is assume the iterable is the expression that is missing instead.
|
||||
let mut exprs = support::children(self.syntax());
|
||||
let first = exprs.next();
|
||||
match first {
|
||||
Some(ast::Expr::BlockExpr(_)) => exprs.next().and(first),
|
||||
first => first,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::HasLoopBody for ast::ForExpr {
|
||||
fn loop_body(&self) -> Option<ast::BlockExpr> {
|
||||
let mut exprs = support::children(self.syntax());
|
||||
|
@ -815,6 +828,19 @@ impl ast::HasLoopBody for ast::ForExpr {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::WhileExpr {
|
||||
pub fn condition(&self) -> Option<ast::Expr> {
|
||||
// If the condition is a BlockExpr, check if the body is missing.
|
||||
// If it is assume the condition is the expression that is missing instead.
|
||||
let mut exprs = support::children(self.syntax());
|
||||
let first = exprs.next();
|
||||
match first {
|
||||
Some(ast::Expr::BlockExpr(_)) => exprs.next().and(first),
|
||||
first => first,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::HasLoopBody for ast::WhileExpr {
|
||||
fn loop_body(&self) -> Option<ast::BlockExpr> {
|
||||
let mut exprs = support::children(self.syntax());
|
||||
|
@ -835,3 +861,15 @@ impl From<ast::Adt> for ast::Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::IfExpr {
|
||||
pub fn condition(&self) -> Option<ast::Expr> {
|
||||
support::child(&self.syntax)
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::MatchGuard {
|
||||
pub fn condition(&self) -> Option<ast::Expr> {
|
||||
support::child(&self.syntax)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue