mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
More compact
This commit is contained in:
parent
6fd2a12495
commit
9285cbffb6
3 changed files with 240 additions and 1438 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -75,12 +75,7 @@ fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AstToken for #name {
|
impl AstToken for #name {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool { kind == #kind }
|
||||||
match kind {
|
|
||||||
#kind => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||||
}
|
}
|
||||||
|
@ -243,10 +238,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
|
|
||||||
impl AstNode for #name {
|
impl AstNode for #name {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
kind == #kind
|
||||||
#kind => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||||
|
|
Loading…
Reference in a new issue