Generate only minimal set of ineresting tokens

This commit is contained in:
Aleksey Kladov 2020-04-10 15:53:09 +02:00
parent 8d71a6bf0c
commit 4560fe2abf
8 changed files with 61 additions and 1306 deletions

View file

@ -80,7 +80,7 @@ impl<N: AstNode> Iterator for AstChildren<N> {
}
mod support {
use super::{AstChildren, AstNode, AstToken, SyntaxKind, SyntaxNode, SyntaxToken};
use super::{AstChildren, AstNode, SyntaxKind, SyntaxNode, SyntaxToken};
pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> {
parent.children().find_map(N::cast)
@ -90,10 +90,6 @@ mod support {
AstChildren::new(parent)
}
pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> {
parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast)
}
pub(super) fn token2(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> {
parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind)
}