mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Remove dead code
This commit is contained in:
parent
4560fe2abf
commit
e0f02d233f
5 changed files with 191 additions and 206 deletions
|
@ -90,7 +90,7 @@ mod support {
|
||||||
AstChildren::new(parent)
|
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)
|
parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,7 +343,7 @@ impl ast::TypeBound {
|
||||||
.skip_while(|it| it.kind() != T![const])
|
.skip_while(|it| it.kind() != T![const])
|
||||||
.find(|it| it.kind() == T![?])
|
.find(|it| it.kind() == T![?])
|
||||||
} else {
|
} else {
|
||||||
support::token2(&self.syntax, T![?])
|
support::token(&self.syntax, T![?])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -65,7 +65,7 @@ pub trait TypeBoundsOwner: AstNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn colon_token(&self) -> Option<SyntaxToken> {
|
fn colon_token(&self) -> Option<SyntaxToken> {
|
||||||
support::token2(self.syntax(), T![:])
|
support::token(self.syntax(), T![:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//! Specifically, it generates the `SyntaxKind` enum and a number of newtype
|
//! Specifically, it generates the `SyntaxKind` enum and a number of newtype
|
||||||
//! wrappers around `SyntaxNode` which implement `ra_syntax::AstNode`.
|
//! wrappers around `SyntaxNode` which implement `ra_syntax::AstNode`.
|
||||||
|
|
||||||
use std::collections::{BTreeSet, HashSet};
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use proc_macro2::{Punct, Spacing};
|
use proc_macro2::{Punct, Spacing};
|
||||||
use quote::{format_ident, quote};
|
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)?;
|
update(syntax_kinds_file.as_path(), &syntax_kinds, mode)?;
|
||||||
|
|
||||||
let ast_tokens_file = project_root().join(codegen::AST_TOKENS);
|
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)?;
|
update(ast_tokens_file.as_path(), &contents, mode)?;
|
||||||
|
|
||||||
let ast_nodes_file = project_root().join(codegen::AST_NODES);
|
let ast_nodes_file = project_root().join(codegen::AST_NODES);
|
||||||
|
@ -30,14 +30,7 @@ pub fn generate_syntax(mode: Mode) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
fn generate_tokens(grammar: AstSrc<'_>) -> Result<String> {
|
||||||
struct ElementKinds {
|
|
||||||
kinds: BTreeSet<proc_macro2::Ident>,
|
|
||||||
has_nodes: bool,
|
|
||||||
has_tokens: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
|
||||||
let tokens = grammar.tokens.iter().map(|token| {
|
let tokens = grammar.tokens.iter().map(|token| {
|
||||||
let name = format_ident!("{}", token);
|
let name = format_ident!("{}", token);
|
||||||
let kind = format_ident!("{}", to_upper_snake_case(token));
|
let kind = format_ident!("{}", to_upper_snake_case(token));
|
||||||
|
@ -91,7 +84,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
if let Some(token_kind) = field.token_kind() {
|
if let Some(token_kind) = field.token_kind() {
|
||||||
quote! {
|
quote! {
|
||||||
pub fn #method_name(&self) -> Option<#ty> {
|
pub fn #method_name(&self) -> Option<#ty> {
|
||||||
support::token2(&self.syntax, #token_kind)
|
support::token(&self.syntax, #token_kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue