mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:09:22 +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
|
@ -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!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue