mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +00:00
Simplify
This commit is contained in:
parent
36353bb182
commit
4fefc7d06c
2 changed files with 6 additions and 6 deletions
|
@ -84,7 +84,7 @@ impl Whitespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct QuoteOffsets {
|
pub struct QuoteOffsets {
|
||||||
pub quotes: [TextRange; 2],
|
pub quotes: (TextRange, TextRange),
|
||||||
pub contents: TextRange,
|
pub contents: TextRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ impl QuoteOffsets {
|
||||||
let end = TextSize::of(literal);
|
let end = TextSize::of(literal);
|
||||||
|
|
||||||
let res = QuoteOffsets {
|
let res = QuoteOffsets {
|
||||||
quotes: [TextRange::new(start, left_quote), TextRange::new(right_quote, end)],
|
quotes: (TextRange::new(start, left_quote), TextRange::new(right_quote, end)),
|
||||||
contents: TextRange::new(left_quote, right_quote),
|
contents: TextRange::new(left_quote, right_quote),
|
||||||
};
|
};
|
||||||
Some(res)
|
Some(res)
|
||||||
|
@ -116,17 +116,17 @@ pub trait HasQuotes: AstToken {
|
||||||
let offsets = QuoteOffsets::new(text)?;
|
let offsets = QuoteOffsets::new(text)?;
|
||||||
let o = self.syntax().text_range().start();
|
let o = self.syntax().text_range().start();
|
||||||
let offsets = QuoteOffsets {
|
let offsets = QuoteOffsets {
|
||||||
quotes: [offsets.quotes[0] + o, offsets.quotes[1] + o],
|
quotes: (offsets.quotes.0 + o, offsets.quotes.1 + o),
|
||||||
contents: offsets.contents + o,
|
contents: offsets.contents + o,
|
||||||
};
|
};
|
||||||
Some(offsets)
|
Some(offsets)
|
||||||
}
|
}
|
||||||
fn open_quote_text_range(&self) -> Option<TextRange> {
|
fn open_quote_text_range(&self) -> Option<TextRange> {
|
||||||
self.quote_offsets().map(|it| it.quotes[0])
|
self.quote_offsets().map(|it| it.quotes.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close_quote_text_range(&self) -> Option<TextRange> {
|
fn close_quote_text_range(&self) -> Option<TextRange> {
|
||||||
self.quote_offsets().map(|it| it.quotes[1])
|
self.quote_offsets().map(|it| it.quotes.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn text_range_between_quotes(&self) -> Option<TextRange> {
|
fn text_range_between_quotes(&self) -> Option<TextRange> {
|
||||||
|
|
|
@ -68,7 +68,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|node| {
|
.map(|node| {
|
||||||
let name = format_ident!("{}", node.name);
|
let name = format_ident!("{}", node.name);
|
||||||
let kind = format_ident!("{}", to_upper_snake_case(&name.to_string()));
|
let kind = format_ident!("{}", to_upper_snake_case(node.name));
|
||||||
let traits = node.traits.iter().map(|trait_name| {
|
let traits = node.traits.iter().map(|trait_name| {
|
||||||
let trait_name = format_ident!("{}", trait_name);
|
let trait_name = format_ident!("{}", trait_name);
|
||||||
quote!(impl ast::#trait_name for #name {})
|
quote!(impl ast::#trait_name for #name {})
|
||||||
|
|
Loading…
Reference in a new issue