swiftpoet / io.outfoxx.swiftpoet / CodeBlock
CodeBlock
class CodeBlock
A fragment of a .kt file, potentially containing declarations, statements, and documentation.
Code blocks are not necessarily well-formed Kotlin code, and are not validated. This class
assumes kotlinc will check correctness later!
Code blocks support placeholders like java.text.Format. This class uses a percent sign
%
but has its own set of permitted placeholders:
%L
emits a literal value with no escaping. Arguments for literals may be strings,
primitives, type declarations and even other code blocks.
%N
emits a name, using name collision avoidance where necessary. Arguments for names may
be strings (actually any character sequence), parameters,
properties, functions, and types.
%S
escapes the value as a string, wraps it with double quotes, and emits that. For
example, 6" sandwich
is emitted "6\" sandwich"
.
%T
emits a type reference. Types will be imported if possible. Arguments for types may be
classes, type mirrors, and
elements.
%%
emits a percent sign.
%W
emits a space or a newline, depending on its position on the line. This prefers to wrap
lines before 100 columns.
%>
increases the indentation level.
%<
decreases the indentation level.
%[
begins a statement. For multiline statements, every line after the first line is
double-indented.
%]
ends a statement.
Types
Functions
|
fun equals(other: Any?): Boolean |
|
fun hashCode(): Int |
|
A heterogeneous list containing string literals and value placeholders.
fun isEmpty(): Boolean |
|
fun isNotEmpty(): Boolean |
|
fun toBuilder(): Builder |
|
fun toString(): String |
Companion Object Properties
Companion Object Functions