mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-15 08:00:46 +00:00
Rename PreorderVisitor
to SourceOrderVisitor
(#11798)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
37d8de3316
commit
32ca704956
27 changed files with 496 additions and 491 deletions
|
@ -406,11 +406,11 @@ impl<'a> Comments<'a> {
|
|||
/// normally if `node` is the first or last node of a suppression range.
|
||||
#[cfg(debug_assertions)]
|
||||
pub(crate) fn mark_verbatim_node_comments_formatted(&self, node: AnyNodeRef) {
|
||||
use ruff_python_ast::visitor::preorder::{PreorderVisitor, TraversalSignal};
|
||||
use ruff_python_ast::visitor::source_order::{SourceOrderVisitor, TraversalSignal};
|
||||
|
||||
struct MarkVerbatimCommentsAsFormattedVisitor<'a>(&'a Comments<'a>);
|
||||
|
||||
impl<'a> PreorderVisitor<'a> for MarkVerbatimCommentsAsFormattedVisitor<'a> {
|
||||
impl<'a> SourceOrderVisitor<'a> for MarkVerbatimCommentsAsFormattedVisitor<'a> {
|
||||
fn enter_node(&mut self, node: AnyNodeRef<'a>) -> TraversalSignal {
|
||||
for comment in self.0.leading_dangling_trailing(node) {
|
||||
comment.mark_formatted();
|
||||
|
|
|
@ -7,7 +7,7 @@ use ruff_python_ast::{Mod, Stmt};
|
|||
// The interface is designed to only export the members relevant for iterating nodes in
|
||||
// pre-order.
|
||||
#[allow(clippy::wildcard_imports)]
|
||||
use ruff_python_ast::visitor::preorder::*;
|
||||
use ruff_python_ast::visitor::source_order::*;
|
||||
use ruff_python_trivia::{CommentLinePosition, CommentRanges};
|
||||
use ruff_source_file::Locator;
|
||||
use ruff_text_size::{Ranged, TextRange, TextSize};
|
||||
|
@ -70,7 +70,7 @@ impl<'a, 'builder> CommentsVisitor<'a, 'builder> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'ast> PreorderVisitor<'ast> for CommentsVisitor<'ast, '_> {
|
||||
impl<'ast> SourceOrderVisitor<'ast> for CommentsVisitor<'ast, '_> {
|
||||
fn enter_node(&mut self, node: AnyNodeRef<'ast>) -> TraversalSignal {
|
||||
let node_range = node.range();
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use ruff_formatter::{
|
|||
};
|
||||
use ruff_python_ast as ast;
|
||||
use ruff_python_ast::parenthesize::parentheses_iterator;
|
||||
use ruff_python_ast::visitor::preorder::{walk_expr, PreorderVisitor};
|
||||
use ruff_python_ast::visitor::source_order::{walk_expr, SourceOrderVisitor};
|
||||
use ruff_python_ast::{AnyNodeRef, Expr, ExpressionRef, Operator};
|
||||
use ruff_python_trivia::CommentRanges;
|
||||
use ruff_text_size::Ranged;
|
||||
|
@ -806,7 +806,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'input> PreorderVisitor<'input> for CanOmitOptionalParenthesesVisitor<'input> {
|
||||
impl<'input> SourceOrderVisitor<'input> for CanOmitOptionalParenthesesVisitor<'input> {
|
||||
fn visit_expr(&mut self, expr: &'input Expr) {
|
||||
self.last = Some(expr);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use ruff_formatter::printer::SourceMapGeneration;
|
|||
use ruff_formatter::{
|
||||
format, FormatContext, FormatError, FormatOptions, IndentStyle, PrintedRange, SourceCode,
|
||||
};
|
||||
use ruff_python_ast::visitor::preorder::{walk_body, PreorderVisitor, TraversalSignal};
|
||||
use ruff_python_ast::visitor::source_order::{walk_body, SourceOrderVisitor, TraversalSignal};
|
||||
use ruff_python_ast::{AnyNodeRef, Stmt, StmtMatch, StmtTry};
|
||||
use ruff_python_parser::{parse, AsMode};
|
||||
use ruff_python_trivia::{indentation_at_offset, BackwardsTokenizer, SimpleToken, SimpleTokenKind};
|
||||
|
@ -181,7 +181,7 @@ impl<'a, 'ast> FindEnclosingNode<'a, 'ast> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'ast> PreorderVisitor<'ast> for FindEnclosingNode<'_, 'ast> {
|
||||
impl<'ast> SourceOrderVisitor<'ast> for FindEnclosingNode<'_, 'ast> {
|
||||
fn enter_node(&mut self, node: AnyNodeRef<'ast>) -> TraversalSignal {
|
||||
if !(is_logical_line(node) || node.is_mod_module()) {
|
||||
return TraversalSignal::Skip;
|
||||
|
@ -336,7 +336,7 @@ struct NarrowRange<'a> {
|
|||
level: usize,
|
||||
}
|
||||
|
||||
impl PreorderVisitor<'_> for NarrowRange<'_> {
|
||||
impl SourceOrderVisitor<'_> for NarrowRange<'_> {
|
||||
fn enter_node(&mut self, node: AnyNodeRef<'_>) -> TraversalSignal {
|
||||
if !(is_logical_line(node) || node.is_mod_module()) {
|
||||
return TraversalSignal::Skip;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue