mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 07:04:53 +00:00
Unify comment terminology with that of rome_formatter
(#2979)
This commit is contained in:
parent
34664a0ca0
commit
180541a924
4 changed files with 64 additions and 45 deletions
|
@ -20,11 +20,11 @@ fn format_pass(f: &mut Formatter<ASTFormatContext<'_>>, stmt: &Stmt) -> FormatRe
|
|||
// Write the statement body.
|
||||
write!(f, [text("pass")])?;
|
||||
|
||||
// Apply any inline comments.
|
||||
// Format any end-of-line comments.
|
||||
let mut first = true;
|
||||
for range in stmt.trivia.iter().filter_map(|trivia| {
|
||||
if matches!(trivia.relationship, Relationship::Trailing) {
|
||||
if let TriviaKind::InlineComment(range) = trivia.kind {
|
||||
if let TriviaKind::EndOfLineComment(range) = trivia.kind {
|
||||
Some(range)
|
||||
} else {
|
||||
None
|
||||
|
@ -206,11 +206,11 @@ fn format_func_def(
|
|||
|
||||
write!(f, [text(":")])?;
|
||||
|
||||
// Apply any inline comments.
|
||||
// Format any end-of-line comments.
|
||||
let mut first = true;
|
||||
for range in stmt.trivia.iter().filter_map(|trivia| {
|
||||
if matches!(trivia.relationship, Relationship::Trailing) {
|
||||
if let TriviaKind::InlineComment(range) = trivia.kind {
|
||||
if let TriviaKind::EndOfLineComment(range) = trivia.kind {
|
||||
Some(range)
|
||||
} else {
|
||||
None
|
||||
|
@ -255,11 +255,11 @@ fn format_assign(
|
|||
)?;
|
||||
}
|
||||
|
||||
// Apply any inline comments.
|
||||
// Format any end-of-line comments.
|
||||
let mut first = true;
|
||||
for range in stmt.trivia.iter().filter_map(|trivia| {
|
||||
if matches!(trivia.relationship, Relationship::Trailing) {
|
||||
if let TriviaKind::InlineComment(range) = trivia.kind {
|
||||
if let TriviaKind::EndOfLineComment(range) = trivia.kind {
|
||||
Some(range)
|
||||
} else {
|
||||
None
|
||||
|
@ -543,11 +543,11 @@ fn format_import_from(
|
|||
)?;
|
||||
}
|
||||
|
||||
// Apply any inline comments.
|
||||
// Format any end-of-line comments.
|
||||
let mut first = true;
|
||||
for range in stmt.trivia.iter().filter_map(|trivia| {
|
||||
if matches!(trivia.relationship, Relationship::Trailing) {
|
||||
if let TriviaKind::InlineComment(range) = trivia.kind {
|
||||
if let TriviaKind::EndOfLineComment(range) = trivia.kind {
|
||||
Some(range)
|
||||
} else {
|
||||
None
|
||||
|
@ -592,11 +592,11 @@ fn format_expr(
|
|||
)?;
|
||||
}
|
||||
|
||||
// Apply any inline comments.
|
||||
// Format any end-of-line comments.
|
||||
let mut first = true;
|
||||
for range in stmt.trivia.iter().filter_map(|trivia| {
|
||||
if matches!(trivia.relationship, Relationship::Trailing) {
|
||||
if let TriviaKind::InlineComment(range) = trivia.kind {
|
||||
if let TriviaKind::EndOfLineComment(range) = trivia.kind {
|
||||
Some(range)
|
||||
} else {
|
||||
None
|
||||
|
@ -665,7 +665,7 @@ impl Format<ASTFormatContext<'_>> for FormatStmt<'_> {
|
|||
TriviaKind::EmptyLine => {
|
||||
write!(f, [empty_line()])?;
|
||||
}
|
||||
TriviaKind::StandaloneComment(range) => {
|
||||
TriviaKind::OwnLineComment(range) => {
|
||||
write!(f, [literal(range), hard_line_break()])?;
|
||||
}
|
||||
_ => {}
|
||||
|
@ -808,7 +808,7 @@ impl Format<ASTFormatContext<'_>> for FormatStmt<'_> {
|
|||
TriviaKind::EmptyLine => {
|
||||
write!(f, [empty_line()])?;
|
||||
}
|
||||
TriviaKind::StandaloneComment(range) => {
|
||||
TriviaKind::OwnLineComment(range) => {
|
||||
write!(f, [literal(range), hard_line_break()])?;
|
||||
}
|
||||
_ => {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue