diff options
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index cb701f7f6..1ee60e74c 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -80,7 +80,7 @@ impl<N: AstNode> Iterator for AstChildren<N> { | |||
80 | } | 80 | } |
81 | 81 | ||
82 | mod support { | 82 | mod support { |
83 | use super::{AstChildren, AstNode, AstToken, SyntaxNode}; | 83 | use super::{AstChildren, AstNode, AstToken, SyntaxKind, SyntaxNode, SyntaxToken}; |
84 | 84 | ||
85 | pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> { | 85 | pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> { |
86 | parent.children().find_map(N::cast) | 86 | parent.children().find_map(N::cast) |
@@ -93,6 +93,10 @@ mod support { | |||
93 | pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> { | 93 | pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> { |
94 | parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast) | 94 | parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast) |
95 | } | 95 | } |
96 | |||
97 | pub(super) fn token2(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> { | ||
98 | parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind) | ||
99 | } | ||
96 | } | 100 | } |
97 | 101 | ||
98 | #[test] | 102 | #[test] |