mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-19 08:40:39 +00:00
More enum work (#3212)
This commit is contained in:
parent
248590224a
commit
84e96cdcd9
12 changed files with 93 additions and 224 deletions
|
@ -4,7 +4,7 @@ use ruff_text_size::TextRange;
|
|||
|
||||
use crate::context::ASTFormatContext;
|
||||
use crate::core::types::Range;
|
||||
use crate::trivia::{Relationship, Trivia, TriviaKind};
|
||||
use crate::trivia::{Trivia, TriviaKind};
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub struct Literal {
|
||||
|
@ -36,7 +36,7 @@ pub struct LeadingComments<'a> {
|
|||
impl Format<ASTFormatContext<'_>> for LeadingComments<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<ASTFormatContext<'_>>) -> FormatResult<()> {
|
||||
for comment in self.comments {
|
||||
if matches!(comment.relationship, Relationship::Leading) {
|
||||
if comment.relationship.is_leading() {
|
||||
if let TriviaKind::OwnLineComment(range) = comment.kind {
|
||||
write!(f, [hard_line_break()])?;
|
||||
write!(f, [literal(range)])?;
|
||||
|
@ -60,7 +60,7 @@ pub struct TrailingComments<'a> {
|
|||
impl Format<ASTFormatContext<'_>> for TrailingComments<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<ASTFormatContext<'_>>) -> FormatResult<()> {
|
||||
for comment in self.comments {
|
||||
if matches!(comment.relationship, Relationship::Trailing) {
|
||||
if comment.relationship.is_trailing() {
|
||||
if let TriviaKind::OwnLineComment(range) = comment.kind {
|
||||
write!(f, [hard_line_break()])?;
|
||||
write!(f, [literal(range)])?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue