From 0edb5b4a501a66baa7db8ececf46135e6246f4de Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 24 Dec 2019 19:45:28 +0800 Subject: Implement infer await from async func --- crates/ra_syntax/src/ast/generated.rs | 1 + crates/ra_syntax/src/ast/traits.rs | 7 +++++++ crates/ra_syntax/src/grammar.ron | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax') 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 {} impl ast::TypeParamsOwner for FnDef {} impl ast::AttrsOwner for FnDef {} impl ast::DocCommentsOwner for FnDef {} +impl ast::AsyncOwner for FnDef {} impl FnDef { pub fn param_list(&self) -> Option { 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::{ ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, match_ast, syntax_node::{SyntaxElementChildren, SyntaxNodeChildren}, + SyntaxKind, }; pub trait TypeAscriptionOwner: AstNode { @@ -105,6 +106,12 @@ pub trait AttrsOwner: AstNode { } } +pub trait AsyncOwner: AstNode { + fn is_async(&self) -> bool { + self.syntax().children_with_tokens().any(|t| t.kind() == SyntaxKind::ASYNC_KW) + } +} + pub trait DocCommentsOwner: AstNode { fn doc_comments(&self) -> CommentIter { 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( "NameOwner", "TypeParamsOwner", "AttrsOwner", - "DocCommentsOwner" + "DocCommentsOwner", + "AsyncOwner" ], options: [ "ParamList", ["body", "BlockExpr"], "RetType" ], ), -- cgit v1.2.3 From 208ad97fdc9427f1243ac170c1c25f9f7d6ae964 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Wed, 25 Dec 2019 00:25:18 +0800 Subject: Remove AsyncOwner --- crates/ra_syntax/src/ast/extensions.rs | 4 ++++ crates/ra_syntax/src/ast/generated.rs | 1 - crates/ra_syntax/src/ast/traits.rs | 7 ------- crates/ra_syntax/src/grammar.ron | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index a8f625176..baaef3023 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs @@ -221,6 +221,10 @@ impl ast::FnDef { .and_then(|it| it.into_token()) .filter(|it| it.kind() == T![;]) } + + pub fn is_async(&self) -> bool { + self.syntax().children_with_tokens().any(|it| it.kind() == T![async]) + } } impl ast::LetStmt { diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 73e1c407c..9f9d6e63c 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -1129,7 +1129,6 @@ impl ast::NameOwner for FnDef {} impl ast::TypeParamsOwner for FnDef {} impl ast::AttrsOwner for FnDef {} impl ast::DocCommentsOwner for FnDef {} -impl ast::AsyncOwner for FnDef {} impl FnDef { pub fn param_list(&self) -> Option { AstChildren::new(&self.syntax).next() diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index 8bf6aa2f0..f99984fe0 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs @@ -8,7 +8,6 @@ use crate::{ ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, match_ast, syntax_node::{SyntaxElementChildren, SyntaxNodeChildren}, - SyntaxKind, }; pub trait TypeAscriptionOwner: AstNode { @@ -106,12 +105,6 @@ pub trait AttrsOwner: AstNode { } } -pub trait AsyncOwner: AstNode { - fn is_async(&self) -> bool { - self.syntax().children_with_tokens().any(|t| t.kind() == SyntaxKind::ASYNC_KW) - } -} - pub trait DocCommentsOwner: AstNode { fn doc_comments(&self) -> CommentIter { CommentIter { iter: self.syntax().children_with_tokens() } diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 7d11f0176..08aafb610 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -275,8 +275,7 @@ Grammar( "NameOwner", "TypeParamsOwner", "AttrsOwner", - "DocCommentsOwner", - "AsyncOwner" + "DocCommentsOwner" ], options: [ "ParamList", ["body", "BlockExpr"], "RetType" ], ), -- cgit v1.2.3