aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-30 19:32:12 +0100
committerAleksey Kladov <[email protected]>2018-08-30 19:32:12 +0100
commit8f552ab35222b7ea571f7ea9357db41489ae2247 (patch)
treeaf26565a1269276bf3026349b191be98ae5f3ea5 /crates/libsyntax2
parent80ab3433d3376b7c44787d63af6e7b3217ae41d8 (diff)
break/continue completion
Diffstat (limited to 'crates/libsyntax2')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs17
-rw-r--r--crates/libsyntax2/src/ast/mod.rs6
-rw-r--r--crates/libsyntax2/src/grammar.ron6
3 files changed, 13 insertions, 16 deletions
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> {
593 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 593 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
594} 594}
595 595
596impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {}
596impl<'a> ForExpr<'a> { 597impl<'a> ForExpr<'a> {
597 pub fn pat(self) -> Option<Pat<'a>> { 598 pub fn pat(self) -> Option<Pat<'a>> {
598 super::child_opt(self) 599 super::child_opt(self)
@@ -601,10 +602,6 @@ impl<'a> ForExpr<'a> {
601 pub fn iterable(self) -> Option<Expr<'a>> { 602 pub fn iterable(self) -> Option<Expr<'a>> {
602 super::child_opt(self) 603 super::child_opt(self)
603 } 604 }
604
605 pub fn body(self) -> Option<Block<'a>> {
606 super::child_opt(self)
607 }
608} 605}
609 606
610// ForType 607// ForType
@@ -845,11 +842,8 @@ impl<'a> AstNode<'a> for LoopExpr<'a> {
845 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 842 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
846} 843}
847 844
848impl<'a> LoopExpr<'a> { 845impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {}
849 pub fn body(self) -> Option<Block<'a>> { 846impl<'a> LoopExpr<'a> {}
850 super::child_opt(self)
851 }
852}
853 847
854// MatchArm 848// MatchArm
855#[derive(Debug, Clone, Copy)] 849#[derive(Debug, Clone, Copy)]
@@ -2106,13 +2100,10 @@ impl<'a> AstNode<'a> for WhileExpr<'a> {
2106 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2100 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2107} 2101}
2108 2102
2103impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {}
2109impl<'a> WhileExpr<'a> { 2104impl<'a> WhileExpr<'a> {
2110 pub fn condition(self) -> Option<Condition<'a>> { 2105 pub fn condition(self) -> Option<Condition<'a>> {
2111 super::child_opt(self) 2106 super::child_opt(self)
2112 } 2107 }
2113
2114 pub fn body(self) -> Option<Block<'a>> {
2115 super::child_opt(self)
2116 }
2117} 2108}
2118 2109
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> {
20 } 20 }
21} 21}
22 22
23pub trait LoopBodyOwner<'a>: AstNode<'a> {
24 fn loop_body(self) -> Option<Block<'a>> {
25 child_opt(self)
26 }
27}
28
23pub trait TypeParamsOwner<'a>: AstNode<'a> { 29pub trait TypeParamsOwner<'a>: AstNode<'a> {
24 fn type_param_list(self) -> Option<TypeParamList<'a>> { 30 fn type_param_list(self) -> Option<TypeParamList<'a>> {
25 child_opt(self) 31 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(
354 options: [ ["condition", "Condition"] ] 354 options: [ ["condition", "Condition"] ]
355 ), 355 ),
356 "LoopExpr": ( 356 "LoopExpr": (
357 options: [ ["body", "Block"] ] 357 traits: ["LoopBodyOwner"],
358 ), 358 ),
359 "ForExpr": ( 359 "ForExpr": (
360 traits: ["LoopBodyOwner"],
360 options: [ 361 options: [
361 ["pat", "Pat"], 362 ["pat", "Pat"],
362 ["iterable", "Expr"], 363 ["iterable", "Expr"],
363 ["body", "Block"] ,
364 ] 364 ]
365 ), 365 ),
366 "WhileExpr": ( 366 "WhileExpr": (
367 traits: ["LoopBodyOwner"],
367 options: [ 368 options: [
368 ["condition", "Condition"], 369 ["condition", "Condition"],
369 ["body", "Block"],
370 ] 370 ]
371 ), 371 ),
372 "ContinueExpr": (), 372 "ContinueExpr": (),