Implicit format args support

This commit is contained in:
Lukas Wirth 2023-12-05 15:42:39 +01:00
parent 5b8e386bae
commit d2cd30007c
37 changed files with 615 additions and 174 deletions

View file

@ -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)
}

View file

@ -13,7 +13,7 @@ pub(crate) enum Repr<'a> {
}
impl<'a> TokenText<'a> {
pub(crate) fn borrowed(text: &'a str) -> Self {
pub fn borrowed(text: &'a str) -> Self {
TokenText(Repr::Borrowed(text))
}