mirror of
https://github.com/astral-sh/ruff
synced 2026-01-23 06:20:55 -05: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:
@@ -39,7 +39,7 @@ impl FormatRule<AnyFunctionDefinition<'_>, PyFormatContext<'_>> for FormatAnyFun
|
||||
|
||||
let dangling_comments = comments.dangling_comments(item);
|
||||
let trailing_definition_comments_start =
|
||||
dangling_comments.partition_point(|comment| comment.position().is_own_line());
|
||||
dangling_comments.partition_point(|comment| comment.line_position().is_own_line());
|
||||
|
||||
let (leading_function_definition_comments, trailing_definition_comments) =
|
||||
dangling_comments.split_at(trailing_definition_comments_start);
|
||||
|
||||
@@ -73,7 +73,7 @@ impl FormatNodeRule<StmtIf> for FormatStmtIf {
|
||||
if !orelse.is_empty() {
|
||||
// Leading comments are always own line comments
|
||||
let leading_else_comments_end =
|
||||
else_comments.partition_point(|comment| comment.position().is_own_line());
|
||||
else_comments.partition_point(|comment| comment.line_position().is_own_line());
|
||||
let (else_leading, else_trailing) = else_comments.split_at(leading_else_comments_end);
|
||||
|
||||
write!(
|
||||
|
||||
@@ -44,7 +44,7 @@ impl FormatNodeRule<StmtWhile> for FormatStmtWhile {
|
||||
// Split between leading comments before the `else` keyword and end of line comments at the end of
|
||||
// the `else:` line.
|
||||
let trailing_start =
|
||||
or_else_comments.partition_point(|comment| comment.position().is_own_line());
|
||||
or_else_comments.partition_point(|comment| comment.line_position().is_own_line());
|
||||
let (leading, trailing) = or_else_comments.split_at(trailing_start);
|
||||
|
||||
write!(
|
||||
|
||||
Reference in New Issue
Block a user