se.ansman.dagger.auto.compiler.common.ksp.AnnotationSpecs.kt Maven / Gradle / Ivy
package se.ansman.dagger.auto.compiler.common.ksp
import com.squareup.kotlinpoet.AnnotationSpec
import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.CodeBlock
fun AnnotationSpec.Builder.addMemberArray(name: String, values: Iterable, render: (T) -> CodeBlock) = apply {
val renderedValues = values.map(render)
addMember(
renderedValues.joinToString(prefix = "%L = [", postfix = "]") { "%L" },
name,
*renderedValues.toTypedArray()
)
}
fun AnnotationSpec.Builder.addMemberClassArray(name: String, values: Iterable) =
addMemberArray(name, values) { CodeBlock.of("%T::class", it) }