Build CommentRanges outside the parser (#11792)
## Summary This PR updates the parser to remove building the `CommentRanges` and instead it'll be built by the linter and the formatter when it's required. For the linter, it'll be built and owned by the `Indexer` while for the formatter it'll be built from the `Tokens` struct and passed as an argument. ## Test Plan `cargo insta test`
This commit is contained in:
@@ -444,6 +444,7 @@ impl Format<PyFormatContext<'_>> for FormatEmptyParenthesized<'_> {
|
||||
mod tests {
|
||||
use ruff_python_ast::ExpressionRef;
|
||||
use ruff_python_parser::parse_expression;
|
||||
use ruff_python_trivia::CommentRanges;
|
||||
|
||||
use crate::expression::parentheses::is_expression_parenthesized;
|
||||
|
||||
@@ -453,7 +454,7 @@ mod tests {
|
||||
let parsed = parse_expression(expression).unwrap();
|
||||
assert!(!is_expression_parenthesized(
|
||||
ExpressionRef::from(parsed.expr()),
|
||||
parsed.comment_ranges(),
|
||||
&CommentRanges::default(),
|
||||
expression
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user