From 8f552ab35222b7ea571f7ea9357db41489ae2247 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Aug 2018 21:32:12 +0300 Subject: break/continue completion --- crates/libsyntax2/src/ast/generated.rs | 17 ++++------------- crates/libsyntax2/src/ast/mod.rs | 6 ++++++ crates/libsyntax2/src/grammar.ron | 6 +++--- 3 files changed, 13 insertions(+), 16 deletions(-) (limited to 'crates/libsyntax2/src') diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 1bb3b11d1..0668dbfa7 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -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> { super::child_opt(self) @@ -601,10 +602,6 @@ impl<'a> ForExpr<'a> { pub fn iterable(self) -> Option> { super::child_opt(self) } - - pub fn body(self) -> Option> { - 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> { - 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> { super::child_opt(self) } - - pub fn body(self) -> Option> { - super::child_opt(self) - } } diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs index 3b5e9269f..49e283f5e 100644 --- a/crates/libsyntax2/src/ast/mod.rs +++ b/crates/libsyntax2/src/ast/mod.rs @@ -20,6 +20,12 @@ pub trait NameOwner<'a>: AstNode<'a> { } } +pub trait LoopBodyOwner<'a>: AstNode<'a> { + fn loop_body(self) -> Option> { + child_opt(self) + } +} + pub trait TypeParamsOwner<'a>: AstNode<'a> { fn type_param_list(self) -> Option> { child_opt(self) diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index 8267c2854..da18da8a9 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron @@ -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": (), -- cgit v1.2.3