Remove Parse trait (#6235)

This commit is contained in:
Micha Reiser 2023-08-01 18:35:03 +02:00 committed by GitHub
parent 83fe103d6e
commit debfca3a11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 235 additions and 1420 deletions

View file

@ -2,15 +2,14 @@ mod generator;
mod stylist;
pub use generator::Generator;
use ruff_python_ast::Suite;
use ruff_python_parser::{lexer, Mode, Parse, ParseError};
use ruff_python_parser::{lexer, parse_suite, Mode, ParseError};
use ruff_source_file::Locator;
pub use stylist::{Quote, Stylist};
/// Run round-trip source code generation on a given Python code.
pub fn round_trip(code: &str, source_path: &str) -> Result<String, ParseError> {
let locator = Locator::new(code);
let python_ast = Suite::parse(code, source_path)?;
let python_ast = parse_suite(code, source_path)?;
let tokens: Vec<_> = lexer::lex(code, Mode::Module).collect();
let stylist = Stylist::from_tokens(&tokens, &locator);
let mut generator: Generator = (&stylist).into();