mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-25 12:55:17 +00:00
Extract LineIndex
independent methods from Locator
(#13938)
This commit is contained in:
parent
f8eb547fb4
commit
9f3a38d408
171 changed files with 1348 additions and 1284 deletions
|
@ -1,16 +1,14 @@
|
|||
pub use generator::Generator;
|
||||
use ruff_python_parser::{parse_module, ParseError};
|
||||
pub use stylist::Stylist;
|
||||
|
||||
mod generator;
|
||||
mod stylist;
|
||||
|
||||
pub use generator::Generator;
|
||||
use ruff_python_parser::{parse_module, ParseError};
|
||||
use ruff_source_file::Locator;
|
||||
pub use stylist::Stylist;
|
||||
|
||||
/// Run round-trip source code generation on a given Python code.
|
||||
pub fn round_trip(code: &str) -> Result<String, ParseError> {
|
||||
let locator = Locator::new(code);
|
||||
let parsed = parse_module(code)?;
|
||||
let stylist = Stylist::from_tokens(parsed.tokens(), &locator);
|
||||
let stylist = Stylist::from_tokens(parsed.tokens(), code);
|
||||
let mut generator: Generator = (&stylist).into();
|
||||
generator.unparse_suite(parsed.suite());
|
||||
Ok(generator.generate())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue