mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Put displays at the end
This commit is contained in:
parent
9285cbffb6
commit
56c8581b90
2 changed files with 706 additions and 702 deletions
File diff suppressed because it is too large
Load diff
|
@ -230,12 +230,6 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for #name {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AstNode for #name {
|
impl AstNode for #name {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
kind == #kind
|
kind == #kind
|
||||||
|
@ -280,12 +274,6 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
|
|
||||||
impl std::fmt::Display for #name {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AstNode for #name {
|
impl AstNode for #name {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
|
@ -315,6 +303,21 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let displays = grammar
|
||||||
|
.enums
|
||||||
|
.iter()
|
||||||
|
.map(|it| format_ident!("{}", it.name))
|
||||||
|
.chain(grammar.nodes.iter().map(|it| format_ident!("{}", it.name)))
|
||||||
|
.map(|name| {
|
||||||
|
quote! {
|
||||||
|
impl std::fmt::Display for #name {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let defined_nodes: HashSet<_> = grammar.nodes.iter().map(|node| node.name).collect();
|
let defined_nodes: HashSet<_> = grammar.nodes.iter().map(|node| node.name).collect();
|
||||||
|
|
||||||
for node in kinds
|
for node in kinds
|
||||||
|
@ -336,6 +339,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
|
|
||||||
#(#nodes)*
|
#(#nodes)*
|
||||||
#(#enums)*
|
#(#enums)*
|
||||||
|
#(#displays)*
|
||||||
};
|
};
|
||||||
|
|
||||||
let pretty = crate::reformat(ast)?;
|
let pretty = crate::reformat(ast)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue