CodePrinter
Prints code with automatic indentation based on calls to indent and outdent.
struct CodePrinterPrints code with automatic indentation based on calls to indent and outdent.
struct CodePrinterimport SwiftProtobufPluginLibraryA reusable framework for building protoc plugins in Swift.
init(_ parent: CodePrinter) Initialize a new printer using the existing state from another printer.
init(_ parent: CodePrinter, addNewlines newlines: Bool) Initialize a new printer using the existing state from another printer but with support to control the behavior of addNewlines.
init(indent: String.UnicodeScalarView = " ".unicodeScalars) init(indent: String.UnicodeScalarView = " ".unicodeScalars, addNewlines newlines: Bool) Initialize the printer for use.
var content: String { get }The string content that was printed.
var isEmpty: Bool { get }See if anything was printed.
mutating func append(_ printer: CodePrinter, indenting: Bool = false) Appended the content of another CodePrinterto this one.
mutating func indent() Increases the printer’s indentation level.
mutating func outdent() Decreases the printer’s indentation level.
mutating func print(_ text: String...) Writes the given strings to the printer, adding a newline after each string.
mutating func print(_ text: String..., newlines: Bool) Writes the given strings to the printer, optionally adding a newline after each string. If called with no strings, a blank line is added to the printer.
mutating func printIndented(_ text: String...) Indents, writes the given strings to the printer, and then outdents.
mutating func withIndentation(body: (inout CodePrinter) -> Void) Indents, calls body to do other work relaying along the printer, and the outdents after wards.