diff --git a/src/main/kotlin/net/theevilreaper/dartpoet/code/CodeBlock.kt b/src/main/kotlin/net/theevilreaper/dartpoet/code/CodeBlock.kt index 86b29642..6dc3f3d4 100644 --- a/src/main/kotlin/net/theevilreaper/dartpoet/code/CodeBlock.kt +++ b/src/main/kotlin/net/theevilreaper/dartpoet/code/CodeBlock.kt @@ -22,6 +22,7 @@ package net.theevilreaper.dartpoet.code import net.theevilreaper.dartpoet.type.TypeName import net.theevilreaper.dartpoet.type.asTypeName +import net.theevilreaper.dartpoet.util.EMPTY_STRING import net.theevilreaper.dartpoet.util.escapeIfNecessary import net.theevilreaper.dartpoet.util.isOneOf import net.theevilreaper.dartpoet.util.toImmutableList @@ -342,7 +343,7 @@ class CodeBlock private constructor( unused += "%" + (i + 1) } } - val s = if (unused.size == 1) "" else "s" + val s = if (unused.size == 1) EMPTY_STRING else "s" require(unused.isEmpty()) { "unused argument$s: ${unused.joinToString(", ")}" } } } @@ -492,8 +493,8 @@ class CodeBlock private constructor( @JvmOverloads fun Collection.joinToCode( separator: CharSequence = ", ", - prefix: CharSequence = "", - suffix: CharSequence = "", + prefix: CharSequence = EMPTY_STRING, + suffix: CharSequence = EMPTY_STRING, ): CodeBlock { val blocks = toTypedArray() val placeholders = Array(blocks.size) { "%L" } diff --git a/src/main/kotlin/net/theevilreaper/dartpoet/code/LineWrapper.kt b/src/main/kotlin/net/theevilreaper/dartpoet/code/LineWrapper.kt index aaca0ead..87289bb3 100644 --- a/src/main/kotlin/net/theevilreaper/dartpoet/code/LineWrapper.kt +++ b/src/main/kotlin/net/theevilreaper/dartpoet/code/LineWrapper.kt @@ -43,19 +43,19 @@ class LineWrapper( * Segments of the current line to be joined by spaces or wraps. Never empty, but contains a lone * empty string if no data has been emitted since the last newline. */ - private val segments = mutableListOf("") + private val segments = mutableListOf(EMPTY_STRING) /** Number of indents in wraps. -1 if the current line has no wraps. */ private var indentLevel = -1 /** Optional prefix that will be prepended to wrapped lines. */ - private var linePrefix = "" + private var linePrefix = EMPTY_STRING /** @return whether there are pending segments for the current line. */ val hasPendingSegments get() = segments.size != 1 || segments[0].isNotEmpty() /** Emit `s` replacing its spaces with line wraps as necessary. */ - fun append(string: String, indentLevel: Int = -1, linePrefix: String = "") { + fun append(string: String, indentLevel: Int = -1, linePrefix: String = EMPTY_STRING) { check(!closed) { "closed" } var pos = 0 diff --git a/src/main/kotlin/net/theevilreaper/dartpoet/code/writer/ParameterWriter.kt b/src/main/kotlin/net/theevilreaper/dartpoet/code/writer/ParameterWriter.kt index 7fb52fd6..6fa4bea4 100644 --- a/src/main/kotlin/net/theevilreaper/dartpoet/code/writer/ParameterWriter.kt +++ b/src/main/kotlin/net/theevilreaper/dartpoet/code/writer/ParameterWriter.kt @@ -4,6 +4,7 @@ import net.theevilreaper.dartpoet.DartModifier import net.theevilreaper.dartpoet.code.* import net.theevilreaper.dartpoet.code.emitAnnotations import net.theevilreaper.dartpoet.parameter.ParameterSpec +import net.theevilreaper.dartpoet.util.EMPTY_STRING /** * The ParameterWriter is used to write each parameter. @@ -28,7 +29,7 @@ internal class ParameterWriter : Writeable, InitializerAppender