(&self, f: &mut PyFormatter)
| 35 | |
| 36 | impl Format<PyFormatContext<'_>> for FormatLeadingComments<'_> { |
| 37 | fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> { |
| 38 | fn write_leading_comments( |
| 39 | comments: &[SourceComment], |
| 40 | f: &mut PyFormatter, |
| 41 | ) -> FormatResult<()> { |
| 42 | for comment in comments.iter().filter(|comment| comment.is_unformatted()) { |
| 43 | let lines_after_comment = lines_after(comment.end(), f.context().source()); |
| 44 | write!( |
| 45 | f, |
| 46 | [format_comment(comment), empty_lines(lines_after_comment)] |
| 47 | )?; |
| 48 | |
| 49 | comment.mark_formatted(); |
| 50 | } |
| 51 | |
| 52 | Ok(()) |
| 53 | } |
| 54 | |
| 55 | match self { |
| 56 | FormatLeadingComments::Node(node) => { |
| 57 | let comments = f.context().comments().clone(); |
| 58 | write_leading_comments(comments.leading(*node), f) |
| 59 | } |
| 60 | FormatLeadingComments::Comments(comments) => write_leading_comments(comments, f), |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /// Formats the leading `comments` of an alternate branch and ensures that it preserves the right |
nothing calls this directly
no test coverage detected