CodeWriter
An indentation-aware string builder for generating formatted Kotlin code.
CodeWriter tracks the current indentation level and applies it consistently when writing lines. It uses the FormatConfig to determine indent characters and final newline behavior.
Functions
Link copied to clipboard
Increases the indentation level by one and executes block, then decreases it back.
Link copied to clipboard
Returns the generated code as a string, optionally appending a final newline per FormatConfig.insertFinalNewline.
Link copied to clipboard
Writes text at the current indentation without appending a newline.
Link copied to clipboard
Writes a line with the current indentation followed by a newline.
Link copied to clipboard
Appends raw text without any indentation.