Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- fmt: `squawk-fmt --ir` to print the pretty printing IR instead of the formatted SQL

## v2.63.0 - 2026-08-19

### Added
Expand Down
15 changes: 15 additions & 0 deletions crates/squawk_fmt/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22979,3 +22979,18 @@ pub fn fmt(text: &str) -> Result<String> {
},
))
}

/// The pretty printing IR that [`fmt`] prints to text, rather than the text
/// itself. Handy when a statement formats in a surprising way.
pub fn fmt_ir(text: &str) -> Result<String> {
let parse = ast::SourceFile::parse(text);
let file = parse.tree();
debug_assert_eq!(
parse.errors(),
vec![],
"should bail out when there's parse errors"
);
let doc = build_source_file(&file);

Ok(crate::ir::render(&doc))
}
Loading
Loading