aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs35
-rw-r--r--crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast2
10 files changed, 30 insertions, 37 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 186db538b..158544fa2 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -582,9 +582,7 @@ pub struct BinExpr {
582 pub(crate) syntax: SyntaxNode, 582 pub(crate) syntax: SyntaxNode,
583} 583}
584impl ast::AttrsOwner for BinExpr {} 584impl ast::AttrsOwner for BinExpr {}
585impl BinExpr { 585impl BinExpr {}
586 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
587}
588#[derive(Debug, Clone, PartialEq, Eq, Hash)] 586#[derive(Debug, Clone, PartialEq, Eq, Hash)]
589pub struct BoxExpr { 587pub struct BoxExpr {
590 pub(crate) syntax: SyntaxNode, 588 pub(crate) syntax: SyntaxNode,
@@ -680,9 +678,7 @@ impl ast::AttrsOwner for IfExpr {}
680impl IfExpr { 678impl IfExpr {
681 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } 679 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
682 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 680 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
683 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
684 pub fn else_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![else]) } 681 pub fn else_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![else]) }
685 pub fn if_expr(&self) -> Option<IfExpr> { support::child(&self.syntax) }
686} 682}
687#[derive(Debug, Clone, PartialEq, Eq, Hash)] 683#[derive(Debug, Clone, PartialEq, Eq, Hash)]
688pub struct IndexExpr { 684pub struct IndexExpr {
@@ -690,7 +686,6 @@ pub struct IndexExpr {
690} 686}
691impl ast::AttrsOwner for IndexExpr {} 687impl ast::AttrsOwner for IndexExpr {}
692impl IndexExpr { 688impl IndexExpr {
693 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
694 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 689 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
695 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 690 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
696} 691}
@@ -704,11 +699,11 @@ impl Label {
704 } 699 }
705} 700}
706#[derive(Debug, Clone, PartialEq, Eq, Hash)] 701#[derive(Debug, Clone, PartialEq, Eq, Hash)]
707pub struct LambdaExpr { 702pub struct ClosureExpr {
708 pub(crate) syntax: SyntaxNode, 703 pub(crate) syntax: SyntaxNode,
709} 704}
710impl ast::AttrsOwner for LambdaExpr {} 705impl ast::AttrsOwner for ClosureExpr {}
711impl LambdaExpr { 706impl ClosureExpr {
712 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } 707 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
713 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 708 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
714 pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) } 709 pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
@@ -778,9 +773,7 @@ pub struct RangeExpr {
778 pub(crate) syntax: SyntaxNode, 773 pub(crate) syntax: SyntaxNode,
779} 774}
780impl ast::AttrsOwner for RangeExpr {} 775impl ast::AttrsOwner for RangeExpr {}
781impl RangeExpr { 776impl RangeExpr {}
782 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
783}
784#[derive(Debug, Clone, PartialEq, Eq, Hash)] 777#[derive(Debug, Clone, PartialEq, Eq, Hash)]
785pub struct RecordExpr { 778pub struct RecordExpr {
786 pub(crate) syntax: SyntaxNode, 779 pub(crate) syntax: SyntaxNode,
@@ -1351,7 +1344,7 @@ pub enum Expr {
1351 IfExpr(IfExpr), 1344 IfExpr(IfExpr),
1352 IndexExpr(IndexExpr), 1345 IndexExpr(IndexExpr),
1353 Label(Label), 1346 Label(Label),
1354 LambdaExpr(LambdaExpr), 1347 ClosureExpr(ClosureExpr),
1355 Literal(Literal), 1348 Literal(Literal),
1356 LoopExpr(LoopExpr), 1349 LoopExpr(LoopExpr),
1357 MacroCall(MacroCall), 1350 MacroCall(MacroCall),
@@ -2101,8 +2094,8 @@ impl AstNode for Label {
2101 } 2094 }
2102 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2095 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2103} 2096}
2104impl AstNode for LambdaExpr { 2097impl AstNode for ClosureExpr {
2105 fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR } 2098 fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR }
2106 fn cast(syntax: SyntaxNode) -> Option<Self> { 2099 fn cast(syntax: SyntaxNode) -> Option<Self> {
2107 if Self::can_cast(syntax.kind()) { 2100 if Self::can_cast(syntax.kind()) {
2108 Some(Self { syntax }) 2101 Some(Self { syntax })
@@ -3114,8 +3107,8 @@ impl From<IndexExpr> for Expr {
3114impl From<Label> for Expr { 3107impl From<Label> for Expr {
3115 fn from(node: Label) -> Expr { Expr::Label(node) } 3108 fn from(node: Label) -> Expr { Expr::Label(node) }
3116} 3109}
3117impl From<LambdaExpr> for Expr { 3110impl From<ClosureExpr> for Expr {
3118 fn from(node: LambdaExpr) -> Expr { Expr::LambdaExpr(node) } 3111 fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) }
3119} 3112}
3120impl From<Literal> for Expr { 3113impl From<Literal> for Expr {
3121 fn from(node: Literal) -> Expr { Expr::Literal(node) } 3114 fn from(node: Literal) -> Expr { Expr::Literal(node) }
@@ -3167,7 +3160,7 @@ impl AstNode for Expr {
3167 match kind { 3160 match kind {
3168 ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR 3161 ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR
3169 | CAST_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR | IF_EXPR 3162 | CAST_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR | IF_EXPR
3170 | INDEX_EXPR | LABEL | LAMBDA_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR 3163 | INDEX_EXPR | LABEL | CLOSURE_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
3171 | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR 3164 | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR
3172 | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true, 3165 | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true,
3173 _ => false, 3166 _ => false,
@@ -3190,7 +3183,7 @@ impl AstNode for Expr {
3190 IF_EXPR => Expr::IfExpr(IfExpr { syntax }), 3183 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
3191 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), 3184 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
3192 LABEL => Expr::Label(Label { syntax }), 3185 LABEL => Expr::Label(Label { syntax }),
3193 LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }), 3186 CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }),
3194 LITERAL => Expr::Literal(Literal { syntax }), 3187 LITERAL => Expr::Literal(Literal { syntax }),
3195 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }), 3188 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
3196 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), 3189 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
@@ -3227,7 +3220,7 @@ impl AstNode for Expr {
3227 Expr::IfExpr(it) => &it.syntax, 3220 Expr::IfExpr(it) => &it.syntax,
3228 Expr::IndexExpr(it) => &it.syntax, 3221 Expr::IndexExpr(it) => &it.syntax,
3229 Expr::Label(it) => &it.syntax, 3222 Expr::Label(it) => &it.syntax,
3230 Expr::LambdaExpr(it) => &it.syntax, 3223 Expr::ClosureExpr(it) => &it.syntax,
3231 Expr::Literal(it) => &it.syntax, 3224 Expr::Literal(it) => &it.syntax,
3232 Expr::LoopExpr(it) => &it.syntax, 3225 Expr::LoopExpr(it) => &it.syntax,
3233 Expr::MacroCall(it) => &it.syntax, 3226 Expr::MacroCall(it) => &it.syntax,
@@ -3757,7 +3750,7 @@ impl std::fmt::Display for Label {
3757 std::fmt::Display::fmt(self.syntax(), f) 3750 std::fmt::Display::fmt(self.syntax(), f)
3758 } 3751 }
3759} 3752}
3760impl std::fmt::Display for LambdaExpr { 3753impl std::fmt::Display for ClosureExpr {
3761 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3754 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3762 std::fmt::Display::fmt(self.syntax(), f) 3755 std::fmt::Display::fmt(self.syntax(), f)
3763 } 3756 }
diff --git a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast b/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast
index 1c3e0f65b..e0f1d0c27 100644
--- a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast
+++ b/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 [email protected] 14 [email protected]
15 LAMBDA[email protected] 15 CLOSURE[email protected]
16 [email protected] 16 [email protected]
17 [email protected] "|" 17 [email protected] "|"
18 [email protected] "|" 18 [email protected] "|"
diff --git a/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast b/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast
index d62906b99..0afa24b77 100644
--- a/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast
+++ b/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast
@@ -117,7 +117,7 @@ [email protected]
117 [email protected] 117 [email protected]
118 [email protected] 118 [email protected]
119 [email protected] 119 [email protected]
120 LAMBDA[email protected] 120 CLOSURE[email protected]
121 [email protected] 121 [email protected]
122 [email protected] 122 [email protected]
123 [email protected] 123 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast b/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast
index a98c31b0c..0678d4278 100644
--- a/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast
+++ b/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast
@@ -49,7 +49,7 @@ [email protected]
49 [email protected] "map" 49 [email protected] "map"
50 [email protected] 50 [email protected]
51 [email protected] "(" 51 [email protected] "("
52 LAMBDA[email protected] 52 CLOSURE[email protected]
53 [email protected] 53 [email protected]
54 [email protected] "|" 54 [email protected] "|"
55 [email protected] 55 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast
index 51a6c5170..a80d79563 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 [email protected] 14 [email protected]
15 LAMBDA[email protected] 15 CLOSURE[email protected]
16 [email protected] 16 [email protected]
17 [email protected] "|" 17 [email protected] "|"
18 [email protected] "|" 18 [email protected] "|"
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] ";" 23 [email protected] ";"
24 [email protected] "\n " 24 [email protected] "\n "
25 [email protected] 25 [email protected]
26 LAMBDA[email protected] 26 CLOSURE[email protected]
27 [email protected] 27 [email protected]
28 [email protected] "|" 28 [email protected] "|"
29 [email protected] "|" 29 [email protected] "|"
@@ -47,7 +47,7 @@ [email protected]
47 [email protected] ";" 47 [email protected] ";"
48 [email protected] "\n " 48 [email protected] "\n "
49 [email protected] 49 [email protected]
50 LAMBDA[email protected] 50 CLOSURE[email protected]
51 [email protected] 51 [email protected]
52 [email protected] "|" 52 [email protected] "|"
53 [email protected] 53 [email protected]
@@ -64,7 +64,7 @@ [email protected]
64 [email protected] ";" 64 [email protected] ";"
65 [email protected] "\n " 65 [email protected] "\n "
66 [email protected] 66 [email protected]
67 LAMBDA[email protected] 67 CLOSURE[email protected]
68 [email protected] "move" 68 [email protected] "move"
69 [email protected] " " 69 [email protected] " "
70 [email protected] 70 [email protected]
@@ -91,7 +91,7 @@ [email protected]
91 [email protected] ";" 91 [email protected] ";"
92 [email protected] "\n " 92 [email protected] "\n "
93 [email protected] 93 [email protected]
94 LAMBDA[email protected] 94 CLOSURE[email protected]
95 [email protected] "async" 95 [email protected] "async"
96 [email protected] " " 96 [email protected] " "
97 [email protected] 97 [email protected]
@@ -104,7 +104,7 @@ [email protected]
104 [email protected] ";" 104 [email protected] ";"
105 [email protected] "\n " 105 [email protected] "\n "
106 [email protected] 106 [email protected]
107 LAMBDA[email protected] 107 CLOSURE[email protected]
108 [email protected] "move" 108 [email protected] "move"
109 [email protected] " " 109 [email protected] " "
110 [email protected] 110 [email protected]
@@ -117,7 +117,7 @@ [email protected]
117 [email protected] ";" 117 [email protected] ";"
118 [email protected] "\n " 118 [email protected] "\n "
119 [email protected] 119 [email protected]
120 LAMBDA[email protected] 120 CLOSURE[email protected]
121 [email protected] "async" 121 [email protected] "async"
122 [email protected] " " 122 [email protected] " "
123 [email protected] "move" 123 [email protected] "move"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast b/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast
index 931e81f27..d2fd6e567 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast
@@ -105,7 +105,7 @@ [email protected]
105 [email protected] " " 105 [email protected] " "
106 [email protected] "=" 106 [email protected] "="
107 [email protected] " " 107 [email protected] " "
108 LAMBDA[email protected] 108 CLOSURE[email protected]
109 [email protected] 109 [email protected]
110 [email protected] "#" 110 [email protected] "#"
111 [email protected] "[" 111 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast
index c63a55a56..0a9f7c137 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] " " 20 [email protected] " "
21 [email protected] "=" 21 [email protected] "="
22 [email protected] " " 22 [email protected] " "
23 LAMBDA[email protected] 23 CLOSURE[email protected]
24 [email protected] 24 [email protected]
25 [email protected] "|" 25 [email protected] "|"
26 [email protected] 26 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast
index 9c071ec2e..aa4099a92 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast
@@ -13,7 +13,7 @@ [email protected]
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
15 [email protected] 15 [email protected]
16 LAMBDA[email protected] 16 CLOSURE[email protected]
17 [email protected] 17 [email protected]
18 [email protected] "|" 18 [email protected] "|"
19 [email protected] "|" 19 [email protected] "|"
diff --git a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast b/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast
index 66cd5727a..1d75ed08f 100644
--- a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast
@@ -351,7 +351,7 @@ [email protected]
351 [email protected] " " 351 [email protected] " "
352 [email protected] 352 [email protected]
353 [email protected] "{" 353 [email protected] "{"
354 LAMBDA[email protected] 354 CLOSURE[email protected]
355 [email protected] 355 [email protected]
356 [email protected] "|" 356 [email protected] "|"
357 [email protected] "|" 357 [email protected] "|"
@@ -1628,7 +1628,7 @@ [email protected]
1628 [email protected] 1628 [email protected]
1629 [email protected] 1629 [email protected]
1630 [email protected] "(" 1630 [email protected] "("
1631 LAMBDA[email protected] 1631 CLOSURE[email protected]
1632 [email protected] 1632 [email protected]
1633 [email protected] "|" 1633 [email protected] "|"
1634 [email protected] 1634 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast b/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast
index c9e6d88eb..650f4e310 100644
--- a/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast
@@ -52,7 +52,7 @@ [email protected]
52 [email protected] "catch_unwind" 52 [email protected] "catch_unwind"
53 [email protected] 53 [email protected]
54 [email protected] "(" 54 [email protected] "("
55 LAMBDA[email protected] 55 CLOSURE[email protected]
56 [email protected] "move" 56 [email protected] "move"
57 [email protected] " " 57 [email protected] " "
58 [email protected] 58 [email protected]