Introduce Token element (#7048)

This commit is contained in:
Micha Reiser 2023-09-02 10:05:47 +02:00 committed by GitHub
parent 2f3a950f6f
commit c05e4628b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
78 changed files with 733 additions and 723 deletions

View file

@ -276,16 +276,16 @@ for converter in connection.ops.get_db_converters(
f: &mut ruff_formatter::formatter::Formatter<SimpleFormatContext>,
) -> FormatResult<()> {
let format_str = format_with(|f| {
write!(f, [text("\"")])?;
write!(f, [token("\"")])?;
let mut words = self.0.split_whitespace().peekable();
let mut fill = f.fill();
let separator = format_with(|f| {
group(&format_args![
if_group_breaks(&text("\"")),
if_group_breaks(&token("\"")),
soft_line_break_or_space(),
if_group_breaks(&text("\" "))
if_group_breaks(&token("\" "))
])
.fmt(f)
});
@ -293,10 +293,10 @@ for converter in connection.ops.get_db_converters(
while let Some(word) = words.next() {
let is_last = words.peek().is_none();
let format_word = format_with(|f| {
write!(f, [dynamic_text(word, None)])?;
write!(f, [text(word, None)])?;
if is_last {
write!(f, [text("\"")])?;
write!(f, [token("\"")])?;
}
Ok(())
@ -311,9 +311,9 @@ for converter in connection.ops.get_db_converters(
write!(
f,
[group(&format_args![
if_group_breaks(&text("(")),
if_group_breaks(&token("(")),
soft_block_indent(&format_str),
if_group_breaks(&text(")"))
if_group_breaks(&token(")"))
])]
)
}