mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-14 06:15:13 +00:00
Consistently name comment own line/end-of-line line_position()
(#5215)
## Summary Previously, `DecoratedComment` used `text_position()` and `SourceComment` used `position()`. This PR unifies this to `line_position` everywhere. ## Test Plan This is a rename refactoring.
This commit is contained in:
parent
1336ca601b
commit
db301c14bd
9 changed files with 53 additions and 52 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::comments::{dangling_comments, CommentTextPosition, Comments};
|
||||
use crate::comments::{dangling_comments, CommentLinePosition, Comments};
|
||||
use crate::expression::parentheses::{
|
||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||
};
|
||||
|
@ -30,11 +30,12 @@ impl FormatNodeRule<ExprList> for FormatExprList {
|
|||
// ```
|
||||
// In all other cases comments get assigned to a list element
|
||||
if elts.is_empty() {
|
||||
let end_of_line_split = dangling
|
||||
.partition_point(|comment| comment.position() == CommentTextPosition::EndOfLine);
|
||||
let end_of_line_split = dangling.partition_point(|comment| {
|
||||
comment.line_position() == CommentLinePosition::EndOfLine
|
||||
});
|
||||
debug_assert!(dangling[end_of_line_split..]
|
||||
.iter()
|
||||
.all(|comment| comment.position() == CommentTextPosition::OwnLine));
|
||||
.all(|comment| comment.line_position() == CommentLinePosition::OwnLine));
|
||||
return write!(
|
||||
f,
|
||||
[group(&format_args![
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue