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 +++++++ 2 files changed, 8 insertions(+) (limited to 'crates/ra_syntax/src/ast') 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() } -- cgit v1.2.3