Improve Formatter API (#1505)

- pass `GrammarVersion` to constructor instead of passing it to each
`format` method
- replace `format(Path): String` with `format(Reader, Appendable)`
- instead of picking which overloads besides `format(String): String`
might be useful, offer a single generalized method that streams input
and output
- add `@Throws(IOException::class)` to ensure that Java callers can
catch this exception
- deprecate old methods
This commit is contained in:
odenix authored and GitHub committed 2026-04-07 14:16:12 -07:00
1 parent 99cbd07518
commit 09435af54f
5 files changed
+68 -34

No files matched your search

@@ -47,7 +47,7 @@ constructor(
private val errWriter: Writer = System.err.writer(),
) : CliCommand(CliBaseOptions()) {
private fun format(contents: String): String {
return Formatter().format(contents, grammarVersion)
return Formatter(grammarVersion).format(contents)
}
private fun writeErrLine(error: String) {