Remove dead code

This commit is contained in:
Aleksey Kladov 2020-04-10 15:54:05 +02:00
parent 4560fe2abf
commit e0f02d233f
5 changed files with 191 additions and 206 deletions

View File

@ -90,7 +90,7 @@ pub(super) fn children<N: AstNode>(parent: &SyntaxNode) -> AstChildren<N> {
AstChildren::new(parent)
}
pub(super) fn token2(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> {
pub(super) fn token(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> {
parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind)
}
}

View File

@ -343,7 +343,7 @@ pub fn question_token(&self) -> Option<SyntaxToken> {
.skip_while(|it| it.kind() != T![const])
.find(|it| it.kind() == T![?])
} else {
support::token2(&self.syntax, T![?])
support::token(&self.syntax, T![?])
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,7 @@ fn type_bound_list(&self) -> Option<ast::TypeBoundList> {
}
fn colon_token(&self) -> Option<SyntaxToken> {
support::token2(self.syntax(), T![:])
support::token(self.syntax(), T![:])
}
}

View File

@ -3,7 +3,7 @@
//! Specifically, it generates the `SyntaxKind` enum and a number of newtype
//! wrappers around `SyntaxNode` which implement `ra_syntax::AstNode`.
use std::collections::{BTreeSet, HashSet};
use std::collections::HashSet;
use proc_macro2::{Punct, Spacing};
use quote::{format_ident, quote};
@ -20,7 +20,7 @@ pub fn generate_syntax(mode: Mode) -> Result<()> {
update(syntax_kinds_file.as_path(), &syntax_kinds, mode)?;
let ast_tokens_file = project_root().join(codegen::AST_TOKENS);
let contents = generate_tokens(KINDS_SRC, AST_SRC)?;
let contents = generate_tokens(AST_SRC)?;
update(ast_tokens_file.as_path(), &contents, mode)?;
let ast_nodes_file = project_root().join(codegen::AST_NODES);
@ -30,14 +30,7 @@ pub fn generate_syntax(mode: Mode) -> Result<()> {
Ok(())
}
#[derive(Debug, Default, Clone)]
struct ElementKinds {
kinds: BTreeSet<proc_macro2::Ident>,
has_nodes: bool,
has_tokens: bool,
}
fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
fn generate_tokens(grammar: AstSrc<'_>) -> Result<String> {
let tokens = grammar.tokens.iter().map(|token| {
let name = format_ident!("{}", token);
let kind = format_ident!("{}", to_upper_snake_case(token));
@ -91,7 +84,7 @@ pub fn #method_name(&self) -> AstChildren<#ty> {
if let Some(token_kind) = field.token_kind() {
quote! {
pub fn #method_name(&self) -> Option<#ty> {
support::token2(&self.syntax, #token_kind)
support::token(&self.syntax, #token_kind)
}
}
} else {