mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 18:02:23 +00:00
Add Formatter benchmark (#4860)
This commit is contained in:
parent
8a3a269eef
commit
33434fcb9c
7 changed files with 76 additions and 10 deletions
|
@ -183,7 +183,6 @@ mod tests {
|
|||
use ruff_python_ast::node::AnyNode;
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use rustpython_parser::ast::{StmtBreak, StmtContinue};
|
||||
use std::cell::Cell;
|
||||
|
||||
#[test]
|
||||
fn debug() {
|
||||
|
@ -210,7 +209,7 @@ break;
|
|||
SourceComment {
|
||||
slice: source_code.slice(TextRange::at(TextSize::new(0), TextSize::new(17))),
|
||||
#[cfg(debug_assertions)]
|
||||
formatted: Cell::new(false),
|
||||
formatted: std::cell::Cell::new(false),
|
||||
position: CommentTextPosition::OwnLine,
|
||||
},
|
||||
);
|
||||
|
@ -220,7 +219,7 @@ break;
|
|||
SourceComment {
|
||||
slice: source_code.slice(TextRange::at(TextSize::new(28), TextSize::new(10))),
|
||||
#[cfg(debug_assertions)]
|
||||
formatted: Cell::new(false),
|
||||
formatted: std::cell::Cell::new(false),
|
||||
position: CommentTextPosition::EndOfLine,
|
||||
},
|
||||
);
|
||||
|
@ -230,7 +229,7 @@ break;
|
|||
SourceComment {
|
||||
slice: source_code.slice(TextRange::at(TextSize::new(39), TextSize::new(15))),
|
||||
#[cfg(debug_assertions)]
|
||||
formatted: Cell::new(false),
|
||||
formatted: std::cell::Cell::new(false),
|
||||
position: CommentTextPosition::OwnLine,
|
||||
},
|
||||
);
|
||||
|
|
|
@ -88,7 +88,6 @@
|
|||
//! It is possible to add an additional optional label to [`SourceComment`] If ever the need arises to distinguish two *dangling comments* in the formatting logic,
|
||||
|
||||
use rustpython_parser::ast::Mod;
|
||||
use std::cell::Cell;
|
||||
use std::fmt::Debug;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -119,7 +118,7 @@ pub(crate) struct SourceComment {
|
|||
|
||||
/// Whether the comment has been formatted or not.
|
||||
#[cfg(debug_assertions)]
|
||||
formatted: Cell<bool>,
|
||||
formatted: std::cell::Cell<bool>,
|
||||
|
||||
position: CommentTextPosition,
|
||||
}
|
||||
|
@ -137,7 +136,7 @@ impl SourceComment {
|
|||
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[inline(always)]
|
||||
pub fn mark_formatted(&self) {}
|
||||
pub(crate) fn mark_formatted(&self) {}
|
||||
|
||||
/// Marks the comment as formatted
|
||||
#[cfg(debug_assertions)]
|
||||
|
|
|
@ -5,7 +5,6 @@ use ruff_formatter::{SourceCode, SourceCodeSlice};
|
|||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use ruff_python_ast::prelude::*;
|
||||
use ruff_python_ast::source_code::{CommentRanges, Locator};
|
||||
use std::cell::Cell;
|
||||
// The interface is designed to only export the members relevant for iterating nodes in
|
||||
// pre-order.
|
||||
#[allow(clippy::wildcard_imports)]
|
||||
|
@ -418,7 +417,7 @@ impl From<DecoratedComment<'_>> for SourceComment {
|
|||
slice: decorated.slice,
|
||||
position: decorated.text_position,
|
||||
#[cfg(debug_assertions)]
|
||||
formatted: Cell::new(false),
|
||||
formatted: std::cell::Cell::new(false),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue