mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
break/continue completion
This commit is contained in:
parent
80ab3433d3
commit
8f552ab352
5 changed files with 73 additions and 39 deletions
|
@ -593,6 +593,7 @@ impl<'a> AstNode<'a> for ForExpr<'a> {
|
|||
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
||||
}
|
||||
|
||||
impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {}
|
||||
impl<'a> ForExpr<'a> {
|
||||
pub fn pat(self) -> Option<Pat<'a>> {
|
||||
super::child_opt(self)
|
||||
|
@ -601,10 +602,6 @@ impl<'a> ForExpr<'a> {
|
|||
pub fn iterable(self) -> Option<Expr<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
|
||||
pub fn body(self) -> Option<Block<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
}
|
||||
|
||||
// ForType
|
||||
|
@ -845,11 +842,8 @@ impl<'a> AstNode<'a> for LoopExpr<'a> {
|
|||
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
||||
}
|
||||
|
||||
impl<'a> LoopExpr<'a> {
|
||||
pub fn body(self) -> Option<Block<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
}
|
||||
impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {}
|
||||
impl<'a> LoopExpr<'a> {}
|
||||
|
||||
// MatchArm
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
@ -2106,13 +2100,10 @@ impl<'a> AstNode<'a> for WhileExpr<'a> {
|
|||
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
||||
}
|
||||
|
||||
impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {}
|
||||
impl<'a> WhileExpr<'a> {
|
||||
pub fn condition(self) -> Option<Condition<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
|
||||
pub fn body(self) -> Option<Block<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,12 @@ pub trait NameOwner<'a>: AstNode<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait LoopBodyOwner<'a>: AstNode<'a> {
|
||||
fn loop_body(self) -> Option<Block<'a>> {
|
||||
child_opt(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TypeParamsOwner<'a>: AstNode<'a> {
|
||||
fn type_param_list(self) -> Option<TypeParamList<'a>> {
|
||||
child_opt(self)
|
||||
|
|
|
@ -354,19 +354,19 @@ Grammar(
|
|||
options: [ ["condition", "Condition"] ]
|
||||
),
|
||||
"LoopExpr": (
|
||||
options: [ ["body", "Block"] ]
|
||||
traits: ["LoopBodyOwner"],
|
||||
),
|
||||
"ForExpr": (
|
||||
traits: ["LoopBodyOwner"],
|
||||
options: [
|
||||
["pat", "Pat"],
|
||||
["iterable", "Expr"],
|
||||
["body", "Block"] ,
|
||||
]
|
||||
),
|
||||
"WhileExpr": (
|
||||
traits: ["LoopBodyOwner"],
|
||||
options: [
|
||||
["condition", "Condition"],
|
||||
["body", "Block"],
|
||||
]
|
||||
),
|
||||
"ContinueExpr": (),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue