mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +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
|
@ -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,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue