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:
konstin 2023-06-21 11:04:56 +02:00 committed by GitHub
parent 1336ca601b
commit db301c14bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 53 additions and 52 deletions

View file

@ -26,7 +26,7 @@ impl Debug for DebugComment<'_> {
strut
.field("text", &self.comment.slice.text(self.source_code))
.field("position", &self.comment.position);
.field("position", &self.comment.line_position);
#[cfg(debug_assertions)]
strut.field("formatted", &self.comment.formatted.get());
@ -177,7 +177,7 @@ impl Debug for DebugNodeCommentSlice<'_> {
#[cfg(test)]
mod tests {
use crate::comments::map::MultiMap;
use crate::comments::{CommentTextPosition, Comments, CommentsMap, SourceComment};
use crate::comments::{CommentLinePosition, Comments, CommentsMap, SourceComment};
use insta::assert_debug_snapshot;
use ruff_formatter::SourceCode;
use ruff_python_ast::node::AnyNode;
@ -208,7 +208,7 @@ break;
continue_statement.as_ref().into(),
SourceComment::new(
source_code.slice(TextRange::at(TextSize::new(0), TextSize::new(17))),
CommentTextPosition::OwnLine,
CommentLinePosition::OwnLine,
),
);
@ -216,7 +216,7 @@ break;
continue_statement.as_ref().into(),
SourceComment::new(
source_code.slice(TextRange::at(TextSize::new(28), TextSize::new(10))),
CommentTextPosition::EndOfLine,
CommentLinePosition::EndOfLine,
),
);
@ -224,7 +224,7 @@ break;
break_statement.as_ref().into(),
SourceComment::new(
source_code.slice(TextRange::at(TextSize::new(39), TextSize::new(15))),
CommentTextPosition::OwnLine,
CommentLinePosition::OwnLine,
),
);