aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-12-24 11:45:28 +0000
committerEdwin Cheng <[email protected]>2019-12-24 11:45:28 +0000
commit0edb5b4a501a66baa7db8ececf46135e6246f4de (patch)
treea65f9899f109d4df2c05069e037fe5dec0545d73 /crates/ra_syntax
parent60aa4d12f95477565d5b01f122d2c9dd845015b4 (diff)
Implement infer await from async func
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs1
-rw-r--r--crates/ra_syntax/src/ast/traits.rs7
-rw-r--r--crates/ra_syntax/src/grammar.ron3
3 files changed, 10 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 9f9d6e63c..73e1c407c 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1129,6 +1129,7 @@ impl ast::NameOwner for FnDef {}
1129impl ast::TypeParamsOwner for FnDef {} 1129impl ast::TypeParamsOwner for FnDef {}
1130impl ast::AttrsOwner for FnDef {} 1130impl ast::AttrsOwner for FnDef {}
1131impl ast::DocCommentsOwner for FnDef {} 1131impl ast::DocCommentsOwner for FnDef {}
1132impl ast::AsyncOwner for FnDef {}
1132impl FnDef { 1133impl FnDef {
1133 pub fn param_list(&self) -> Option<ParamList> { 1134 pub fn param_list(&self) -> Option<ParamList> {
1134 AstChildren::new(&self.syntax).next() 1135 AstChildren::new(&self.syntax).next()
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index f99984fe0..8bf6aa2f0 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -8,6 +8,7 @@ use crate::{
8 ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, 8 ast::{self, child_opt, children, AstChildren, AstNode, AstToken},
9 match_ast, 9 match_ast,
10 syntax_node::{SyntaxElementChildren, SyntaxNodeChildren}, 10 syntax_node::{SyntaxElementChildren, SyntaxNodeChildren},
11 SyntaxKind,
11}; 12};
12 13
13pub trait TypeAscriptionOwner: AstNode { 14pub trait TypeAscriptionOwner: AstNode {
@@ -105,6 +106,12 @@ pub trait AttrsOwner: AstNode {
105 } 106 }
106} 107}
107 108
109pub trait AsyncOwner: AstNode {
110 fn is_async(&self) -> bool {
111 self.syntax().children_with_tokens().any(|t| t.kind() == SyntaxKind::ASYNC_KW)
112 }
113}
114
108pub trait DocCommentsOwner: AstNode { 115pub trait DocCommentsOwner: AstNode {
109 fn doc_comments(&self) -> CommentIter { 116 fn doc_comments(&self) -> CommentIter {
110 CommentIter { iter: self.syntax().children_with_tokens() } 117 CommentIter { iter: self.syntax().children_with_tokens() }
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 08aafb610..7d11f0176 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -275,7 +275,8 @@ Grammar(
275 "NameOwner", 275 "NameOwner",
276 "TypeParamsOwner", 276 "TypeParamsOwner",
277 "AttrsOwner", 277 "AttrsOwner",
278 "DocCommentsOwner" 278 "DocCommentsOwner",
279 "AsyncOwner"
279 ], 280 ],
280 options: [ "ParamList", ["body", "BlockExpr"], "RetType" ], 281 options: [ "ParamList", ["body", "BlockExpr"], "RetType" ],
281 ), 282 ),