Skip to content

Commit

Permalink
Make all copying eager
Browse files Browse the repository at this point in the history
  • Loading branch information
deusaquilus committed Mar 20, 2024
1 parent cff5dae commit 5d702e0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ apply(plugin = "io.github.gradle-nexus.publish-plugin")
allprojects {

group = "io.exoquery"
version = "0.1.214"
version = "0.1.215"

apply(plugin = "kotlin")
apply(plugin = "maven-publish")
Expand Down
14 changes: 1 addition & 13 deletions decomat-ksp/src/main/kotlin/io/decomat/DecomatProcessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -405,21 +405,9 @@ class DecomatProcessor(

val adtFunctions =
"""
class CopyEager${className}${genericBlock}(${allMembers.map { "val ${it.fieldName}: ${it.field.type.toString()}" }.commaSep()}) {
operator fun invoke(original: ${model.parametrizedName}) =
original.copy(${allMembers.map { "${it.fieldName} = ${it.fieldName}" }.commaSep()})
}
fun ${genericBlock} ${companionName}.Companion.${fromFunctionName}Eager(${memberKeyValues}) = CopyEager${className}(${allMembers.map { it.fieldName }.commaSep()})
context(${model.parametrizedName}) fun ${genericBlock} ${companionName}.Companion.${fromHereFunctionName}Eager(${memberKeyValues}) =
CopyEager${className}(${allMembers.map { it.fieldName }.commaSep()}).invoke(this@${className})
class Copy${className}${genericBlock}(${allMembers.map { "val ${it.fieldName}: ${it.field.type.toString()}" }.commaSep()}) {
operator fun invoke(original: ${model.parametrizedName}) =
if (${allMembers.map {"original.${it.fieldName} == ${it.fieldName}"}.joinToString(" && ")})
original
else
original.copy(${allMembers.map { "${it.fieldName} = ${it.fieldName}" }.commaSep()})
original.copy(${allMembers.map { "${it.fieldName} = ${it.fieldName}" }.commaSep()})
}
// Helper function for ADTs that allows you to easily copy the element mentioning only the properties you care about
Expand Down

0 comments on commit 5d702e0

Please sign in to comment.