Skip to content

Commit

Permalink
Improve codeWriter usage
Browse files Browse the repository at this point in the history
  • Loading branch information
theEvilReaper committed Dec 16, 2024
1 parent fe5a60c commit 46c2114
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,16 @@ internal class ClassWriter : Writeable<ClassSpec> {
*/
private fun writeGenericArguments(spec: ClassSpec, writer: CodeWriter) {
when (spec.genericCasts.isEmpty()) {
true -> writer.emit("·")
true -> writer.emitSpace()
false -> {
val joinedGenerics = StringHelper.concatData(
spec.genericCasts,
prefix = LESS_THAN_SIGN,
separator = COMMA_SEPARATOR,
postfix = GREATER_THAN_SIGN
) { it.toString() }
writer.emitCode("%L·", joinedGenerics)
writer.emitCode("%L", joinedGenerics)
writer.emitSpace()
}
}
}
Expand Down Expand Up @@ -142,14 +143,18 @@ internal class ClassWriter : Writeable<ClassSpec> {
ClassType.ABSTRACT -> "${CLASS.identifier}·"
else -> EMPTY_STRING
}
writer.emitCode("%L·", spec.classType.keyword)
writer.emitCode("%L", spec.classType.keyword)
writer.emitSpace()
writer.emitCode("%L%L%L", abstractPart, privateModifier, spec.name)
}

private fun writeInheritance(spec: ClassSpec, writer: CodeWriter) {
if (spec.superClass == null) return
writer.emit("${spec.inheritKeyWord!!.identifier}·")
writer.emitCode("%T·", spec.superClass)
writer.emitCode("%L", spec.inheritKeyWord!!.identifier)
writer.emitSpace()
writer.emitCode("%T", spec.superClass)
writer.emitSpace()

}

private fun List<EnumEntrySpec>.emit(
Expand Down

0 comments on commit 46c2114

Please sign in to comment.