Manual impl of Debug on Token (#11958)
## Summary I look at the token stream a lot, not specifically in the playground but in the terminal output and it's annoying to scroll a lot to find specific location. Most of the information is also redundant. The final format we end up with is: `<kind> <range> (flags = ...)` e.g., `String 0..4 (flags = BYTE_STRING)` where the flags part is only populated if there are any flags set.
This commit is contained in:
@@ -22,7 +22,6 @@ ruff_python_formatter = { workspace = true }
|
||||
ruff_python_parser = { workspace = true }
|
||||
ruff_python_stdlib = { workspace = true }
|
||||
ruff_python_trivia = { workspace = true }
|
||||
ruff_text_size = { workspace = true }
|
||||
ruff_workspace = { workspace = true, features = ["schemars"] }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
|
||||
@@ -8,7 +8,6 @@ use anyhow::Result;
|
||||
use ruff_linter::source_kind::SourceKind;
|
||||
use ruff_python_ast::PySourceType;
|
||||
use ruff_python_parser::parse_unchecked_source;
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
#[derive(clap::Args)]
|
||||
pub(crate) struct Args {
|
||||
@@ -27,12 +26,7 @@ pub(crate) fn main(args: &Args) -> Result<()> {
|
||||
})?;
|
||||
let parsed = parse_unchecked_source(source_kind.source_code(), source_type);
|
||||
for token in parsed.tokens() {
|
||||
println!(
|
||||
"{start:#?} {kind:#?} {end:#?}",
|
||||
start = token.start(),
|
||||
end = token.end(),
|
||||
kind = token.kind(),
|
||||
);
|
||||
println!("{token:#?}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user