mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Merge commit '457b966b17
' into sync-from-ra
This commit is contained in:
parent
5285df4f6c
commit
f532576ac5
263 changed files with 9788 additions and 6258 deletions
|
@ -121,6 +121,7 @@ impl ast::Whitespace {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct QuoteOffsets {
|
||||
pub quotes: (TextRange, TextRange),
|
||||
pub contents: TextRange,
|
||||
|
@ -167,6 +168,11 @@ pub trait IsString: AstToken {
|
|||
fn text_range_between_quotes(&self) -> Option<TextRange> {
|
||||
self.quote_offsets().map(|it| it.contents)
|
||||
}
|
||||
fn text_without_quotes(&self) -> &str {
|
||||
let text = self.text();
|
||||
let Some(offsets) = self.text_range_between_quotes() else { return text };
|
||||
&text[offsets - self.syntax().text_range().start()]
|
||||
}
|
||||
fn open_quote_text_range(&self) -> Option<TextRange> {
|
||||
self.quote_offsets().map(|it| it.quotes.0)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue