mirror of
https://github.com/astral-sh/ruff
synced 2026-01-23 06:20:55 -05:00
Move universal newline handling into its own crate (#4729)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_parser::Tok;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::ops::Deref;
|
||||
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_parser::Tok;
|
||||
|
||||
/// Stores the ranges of comments sorted by [`TextRange::start`] in increasing order. No two ranges are overlapping.
|
||||
#[derive(Clone)]
|
||||
pub struct CommentRanges {
|
||||
|
||||
@@ -8,7 +8,8 @@ use rustpython_parser::ast::{
|
||||
Excepthandler, Expr, Identifier, MatchCase, Operator, Pattern, Stmt, Suite, Withitem,
|
||||
};
|
||||
|
||||
use crate::newlines::LineEnding;
|
||||
use ruff_newlines::LineEnding;
|
||||
|
||||
use crate::source_code::stylist::{Indentation, Quote, Stylist};
|
||||
|
||||
mod precedence {
|
||||
@@ -1459,7 +1460,8 @@ mod tests {
|
||||
use rustpython_ast::Suite;
|
||||
use rustpython_parser::Parse;
|
||||
|
||||
use crate::newlines::LineEnding;
|
||||
use ruff_newlines::LineEnding;
|
||||
|
||||
use crate::source_code::stylist::{Indentation, Quote};
|
||||
use crate::source_code::Generator;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//! Struct used to index source code, to enable efficient lookup of tokens that
|
||||
//! are omitted from the AST (e.g., commented lines).
|
||||
|
||||
use crate::source_code::comment_ranges::{CommentRanges, CommentRangesBuilder};
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use rustpython_parser::lexer::LexResult;
|
||||
use rustpython_parser::{StringKind, Tok};
|
||||
|
||||
use crate::source_code::comment_ranges::{CommentRanges, CommentRangesBuilder};
|
||||
use crate::source_code::Locator;
|
||||
|
||||
pub struct Indexer {
|
||||
|
||||
@@ -6,7 +6,8 @@ use memchr::{memchr2, memrchr2};
|
||||
use once_cell::unsync::OnceCell;
|
||||
use ruff_text_size::{TextLen, TextRange, TextSize};
|
||||
|
||||
use crate::newlines::find_newline;
|
||||
use ruff_newlines::find_newline;
|
||||
|
||||
use crate::source_code::{LineIndex, OneIndexed, SourceCode, SourceLocation};
|
||||
|
||||
pub struct Locator<'a> {
|
||||
|
||||
@@ -7,13 +7,13 @@ use rustpython_parser::{ast, lexer, Mode, Parse, ParseError};
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub use comment_ranges::{CommentRanges, CommentRangesBuilder};
|
||||
pub use generator::Generator;
|
||||
pub use indexer::Indexer;
|
||||
pub use locator::Locator;
|
||||
pub use stylist::{Quote, Stylist};
|
||||
|
||||
pub use crate::source_code::line_index::{LineIndex, OneIndexed};
|
||||
pub use comment_ranges::{CommentRanges, CommentRangesBuilder};
|
||||
|
||||
mod comment_ranges;
|
||||
mod generator;
|
||||
|
||||
@@ -4,11 +4,11 @@ use std::fmt;
|
||||
use std::ops::Deref;
|
||||
|
||||
use once_cell::unsync::OnceCell;
|
||||
use ruff_newlines::{find_newline, LineEnding};
|
||||
use rustpython_literal::escape::Quote as StrQuote;
|
||||
use rustpython_parser::lexer::LexResult;
|
||||
use rustpython_parser::Tok;
|
||||
|
||||
use crate::newlines::{find_newline, LineEnding};
|
||||
use crate::source_code::Locator;
|
||||
use crate::str::leading_quote;
|
||||
|
||||
@@ -166,7 +166,8 @@ mod tests {
|
||||
use rustpython_parser::lexer::lex;
|
||||
use rustpython_parser::Mode;
|
||||
|
||||
use crate::newlines::{find_newline, LineEnding};
|
||||
use ruff_newlines::{find_newline, LineEnding};
|
||||
|
||||
use crate::source_code::stylist::{Indentation, Quote};
|
||||
use crate::source_code::{Locator, Stylist};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user