Rename PreorderVisitor to SourceOrderVisitor (#11798)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Micha Reiser 2024-06-07 19:01:58 +02:00 committed by GitHub
parent 37d8de3316
commit 32ca704956
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 496 additions and 491 deletions

View file

@ -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();

View file

@ -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();