mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +00:00
Rename ruff_python_whitespace
to ruff_python_trivia
(#5886)
## Summary This crate now contains utilities for dealing with trivia more broadly: whitespace, newlines, "simple" trivia lexing, etc. So renaming it to reflect its increased responsibilities. To avoid conflicts, I've also renamed `Token` and `TokenKind` to `SimpleToken` and `SimpleTokenKind`.
This commit is contained in:
parent
a75a6de577
commit
5f3da9955a
86 changed files with 360 additions and 353 deletions
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::{Ranged, StmtAsyncWith, StmtWith, Suite, WithItem};
|
|||
|
||||
use ruff_formatter::{format_args, write, FormatError};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use ruff_python_whitespace::{SimpleTokenizer, TokenKind};
|
||||
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer};
|
||||
|
||||
use crate::comments::trailing_comments;
|
||||
use crate::expression::parentheses::{
|
||||
|
@ -125,7 +125,7 @@ fn are_with_items_parenthesized(
|
|||
|
||||
let mut tokenizer = SimpleTokenizer::new(context.source(), before_first_with_item)
|
||||
.skip_trivia()
|
||||
.skip_while(|t| t.kind() == TokenKind::Async);
|
||||
.skip_while(|t| t.kind() == SimpleTokenKind::Async);
|
||||
|
||||
let with_keyword = tokenizer.next().ok_or(FormatError::syntax_error(
|
||||
"Expected a with keyword, didn't find any token",
|
||||
|
@ -133,13 +133,13 @@ fn are_with_items_parenthesized(
|
|||
|
||||
debug_assert_eq!(
|
||||
with_keyword.kind(),
|
||||
TokenKind::With,
|
||||
SimpleTokenKind::With,
|
||||
"Expected with keyword but at {with_keyword:?}"
|
||||
);
|
||||
|
||||
match tokenizer.next() {
|
||||
Some(left_paren) => {
|
||||
debug_assert_eq!(left_paren.kind(), TokenKind::LParen);
|
||||
debug_assert_eq!(left_paren.kind(), SimpleTokenKind::LParen);
|
||||
Ok(true)
|
||||
}
|
||||
None => Ok(false),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue