swiftlang / swift-format

Formatting technology for Swift source code
Apache License 2.0
2.38k stars 216 forks source link

Split the PrettyPrint class into two pieces. #759

Closed shawnhyam closed 1 week ago

shawnhyam commented 1 week ago

This change breaks up the PrettyPrint class into one piece that is responsible for tracking the state of the pretty printing algorithm - processing the tokens, tracking the break stack, comma delimited region stack, etc.; and another piece that is responsible for assembling the output and tracking the state of the output - current line, column position, and indentation.

shawnhyam commented 1 week ago

I did this as a learning exercise, to separate out the state that was part of the algorithm vs. the state that was part of the output stream. To me it makes things a bit easier to grok, interested in your thoughts on it.