feat(cli): add a no-ranges flag to the parse command

This commit is contained in:
Amaan Qureshi 2024-09-26 22:23:22 -04:00
parent e04387258b
commit 9ef12624c3
2 changed files with 12 additions and 9 deletions

View file

@ -60,6 +60,7 @@ pub struct ParseFileOptions<'a> {
pub cancellation_flag: Option<&'a AtomicUsize>,
pub encoding: Option<u32>,
pub open_log: bool,
pub no_ranges: bool,
}
#[derive(Copy, Clone)]
@ -178,15 +179,14 @@ pub fn parse_file_at_path(parser: &mut Parser, opts: &ParseFileOptions) -> Resul
if let Some(field_name) = cursor.field_name() {
write!(&mut stdout, "{field_name}: ")?;
}
write!(
&mut stdout,
"({} [{}, {}] - [{}, {}]",
node.kind(),
start.row,
start.column,
end.row,
end.column
)?;
write!(&mut stdout, "({}", node.kind())?;
if !opts.no_ranges {
write!(
&mut stdout,
" [{}, {}] - [{}, {}]",
start.row, start.column, end.row, end.column
)?;
}
needs_newline = true;
}
if cursor.goto_first_child() {