Skip to content

Commit

Permalink
Update ksp to 1.0.1 with multiplatform support
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvanyo committed Apr 4, 2023
1 parent 7b15e1c commit 9b32edc
Show file tree
Hide file tree
Showing 60 changed files with 486 additions and 312 deletions.
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ plugins {
alias(libs.plugins.dokka)
alias(libs.plugins.kotlinx.kover)
}

tasks.koverMergedHtmlReport {
excludes = listOf("com.livefront.sealedenum.compilation.*")
}
tasks.koverMergedXmlReport {
excludes = listOf("com.livefront.sealedenum.compilation.*")
}
18 changes: 13 additions & 5 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ complexity:
includePrivateDeclarations: false
ComplexMethod:
active: true
excludes: [ '**/generated/**' ]
threshold: 15
ignoreSingleWhenExpression: false
ignoreSimpleWhenEntries: false
Expand Down Expand Up @@ -136,6 +137,7 @@ empty-blocks:
active: true
EmptyDefaultConstructor:
active: true
excludes: [ '**/generated/**' ]
EmptyDoWhileBlock:
active: true
EmptyElseBlock:
Expand Down Expand Up @@ -254,7 +256,7 @@ formatting:
continuationIndentSize: 4
MaximumLineLength:
active: true
excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ]
excludes: [ '**/generated/**', '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ]
maxLineLength: 120
ModifierOrdering:
active: true
Expand All @@ -267,6 +269,7 @@ formatting:
autoCorrect: true
NoConsecutiveBlankLines:
active: true
excludes: [ '**/generated/**' ]
autoCorrect: true
NoEmptyClassBody:
active: true
Expand All @@ -279,6 +282,7 @@ formatting:
autoCorrect: true
NoLineBreakBeforeAssignment:
active: true
excludes: [ '**/generated/**' ]
autoCorrect: true
NoMultipleSpaces:
active: true
Expand Down Expand Up @@ -312,6 +316,7 @@ formatting:
autoCorrect: true
SpacingAroundCurly:
active: true
excludes: [ '**/generated/**' ]
autoCorrect: true
SpacingAroundDot:
active: true
Expand Down Expand Up @@ -340,12 +345,14 @@ formatting:
StringTemplate:
active: true
autoCorrect: true
Wrapping:
excludes: [ '**/generated/**' ]

naming:
active: true
ClassNaming:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
excludes: ['**/generated/**', '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
classPattern: '[A-Z][a-zA-Z0-9]*'
ConstructorParameterNaming:
active: true
Expand Down Expand Up @@ -388,6 +395,7 @@ naming:
rootPackage: ''
MatchingDeclarationName:
active: true
excludes: ['**/generated/**']
mustBeFirst: true
MemberNameEqualsClassName:
active: true
Expand All @@ -407,7 +415,7 @@ naming:
packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*'
TopLevelPropertyNaming:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
excludes: ['**/generated/**', '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
constantPattern: '[A-Z][_A-Z0-9]*'
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
Expand Down Expand Up @@ -552,7 +560,7 @@ style:
maxJumpCount: 1
MagicNumber:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
excludes: [ '**/generated/**', '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
ignoreNumbers: ['-1', '0', '1', '2']
ignoreHashCodeFunction: true
ignorePropertyDeclaration: false
Expand All @@ -569,7 +577,7 @@ style:
active: false
MaxLineLength:
active: true
excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ]
excludes: [ '**/generated/**', '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ]
maxLineLength: 120
excludePackageStatements: true
excludeImportStatements: true
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ org.gradle.jvmargs=-Xmx1536m
org.gradle.parallel=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Don't work about mpp stability
kotlin.mpp.stability.nowarn=true
# Don't warn about disabled targets
kotlin.native.ignoreDisabledTargets=true

group=com.livefront.sealedenum
version=0.5.0
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.livefront.sealedenum.internal.common.Visibility
import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.FunSpec
import com.squareup.kotlinpoet.PropertySpec
import com.squareup.kotlinpoet.asTypeName
import javax.lang.model.element.TypeElement

internal data class SealedEnumSealedEnumPropertySpec(
Expand All @@ -18,7 +19,11 @@ internal data class SealedEnumSealedEnumPropertySpec(
fun build(): PropertySpec {
val propertySpecBuilder = PropertySpec.builder(pascalCaseToCamelCase(enumPrefix + "SealedEnum"), sealedEnum)
.maybeAddOriginatingElement(sealedClassCompanionObjectElement)
.addKdoc("Returns an implementation of [%T] for the sealed class [%T]", SealedEnum::class, sealedClass)
.addKdoc(
"Returns an implementation of [%T] for the sealed class [%T]",
SealedEnum::class.asTypeName(), // Explicitly resolve to TypeName to avoid hitting javax.lang classes
sealedClass
)
.receiver(sealedClassCompanionObject)
.addModifiers(sealedClassCompanionObjectEffectiveVisibility.kModifier)
.getter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.livefront.sealedenum.compilation.basic

import com.livefront.sealedenum.GenSealedEnum

sealed class EmptySealedClass {
public sealed class EmptySealedClass {
@GenSealedEnum(generateEnum = true)
companion object
public companion object
}

val emptySealedClassGenerated = """
public val emptySealedClassGenerated: String = """
package com.livefront.sealedenum.compilation.basic
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.livefront.sealedenum.compilation.basic

import com.livefront.sealedenum.GenSealedEnum

sealed interface EmptySealedInterface {
public sealed interface EmptySealedInterface {
@GenSealedEnum(generateEnum = true)
companion object
public companion object
}

val emptySealedInterfaceGenerated = """
public val emptySealedInterfaceGenerated: String = """
package com.livefront.sealedenum.compilation.basic
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.livefront.sealedenum.compilation.basic

import com.livefront.sealedenum.GenSealedEnum

sealed class OneObjectSealedClass {
object FirstObject : OneObjectSealedClass()
public sealed class OneObjectSealedClass {
public object FirstObject : OneObjectSealedClass()

@GenSealedEnum(generateEnum = true)
companion object
public companion object
}

val oneObjectSealedClassGenerated = """
public val oneObjectSealedClassGenerated: String = """
package com.livefront.sealedenum.compilation.basic
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.livefront.sealedenum.compilation.basic

import com.livefront.sealedenum.GenSealedEnum

sealed interface OneObjectSealedInterface {
object FirstObject : OneObjectSealedInterface
public sealed interface OneObjectSealedInterface {
public object FirstObject : OneObjectSealedInterface

@GenSealedEnum(generateEnum = true)
companion object
public companion object
}

val oneObjectSealedInterfaceGenerated = """
public val oneObjectSealedInterfaceGenerated: String = """
package com.livefront.sealedenum.compilation.basic
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package com.livefront.sealedenum.compilation.basic

import com.livefront.sealedenum.GenSealedEnum

sealed class TwoObjectSealedClass {
object FirstObject : TwoObjectSealedClass()
public sealed class TwoObjectSealedClass {
public object FirstObject : TwoObjectSealedClass()

object SecondObject : TwoObjectSealedClass()
public object SecondObject : TwoObjectSealedClass()

@GenSealedEnum(generateEnum = true)
companion object
public companion object
}

val twoObjectSealedClassGenerated = """
public val twoObjectSealedClassGenerated: String = """
package com.livefront.sealedenum.compilation.basic
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package com.livefront.sealedenum.compilation.basic

import com.livefront.sealedenum.GenSealedEnum

sealed interface TwoObjectSealedInterface {
object FirstObject : TwoObjectSealedInterface
public sealed interface TwoObjectSealedInterface {
public object FirstObject : TwoObjectSealedInterface

object SecondObject : TwoObjectSealedInterface
public object SecondObject : TwoObjectSealedInterface

@GenSealedEnum(generateEnum = true)
companion object
public companion object
}

val twoObjectSealedInterfaceGenerated = """
public val twoObjectSealedInterfaceGenerated: String = """
package com.livefront.sealedenum.compilation.basic
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package com.livefront.sealedenum.compilation.generics

import com.livefront.sealedenum.GenSealedEnum

interface GenericInterfaceOut<out T>
public interface GenericInterfaceOut<out T>

sealed class OneTypeParameterSealedClass<out T> : GenericInterfaceOut<T> {
object FirstObject : OneTypeParameterSealedClass<Int>()
public sealed class OneTypeParameterSealedClass<out T> : GenericInterfaceOut<T> {
public object FirstObject : OneTypeParameterSealedClass<Int>()

object SecondObject : OneTypeParameterSealedClass<String>()
public object SecondObject : OneTypeParameterSealedClass<String>()

object ThirdObject : OneTypeParameterSealedClass<Nothing>()
public object ThirdObject : OneTypeParameterSealedClass<Nothing>()

@GenSealedEnum(generateEnum = true)
companion object OneType
public companion object OneType
}

val oneTypeParameterSealedClassGenerated = """
public val oneTypeParameterSealedClassGenerated: String = """
package com.livefront.sealedenum.compilation.generics
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down Expand Up @@ -138,18 +138,18 @@ public fun OneTypeParameterSealedClass.OneType.valueOf(name: String): OneTypePar
""".trimIndent()

interface GenericInterfaceTwoOut<out A, out B>
public interface GenericInterfaceTwoOut<out A, out B>

sealed class TwoTypeParameterSealedClass<out A, out B> : GenericInterfaceTwoOut<A, B> {
object FirstObject : TwoTypeParameterSealedClass<Any?, Nothing>()
public sealed class TwoTypeParameterSealedClass<out A, out B> : GenericInterfaceTwoOut<A, B> {
public object FirstObject : TwoTypeParameterSealedClass<Any?, Nothing>()

object SecondObject : TwoTypeParameterSealedClass<Double, Double>()
public object SecondObject : TwoTypeParameterSealedClass<Double, Double>()

@GenSealedEnum(generateEnum = true)
companion object TwoType
public companion object TwoType
}

val twoTypeParameterSealedClassGenerated = """
public val twoTypeParameterSealedClassGenerated: String = """
package com.livefront.sealedenum.compilation.generics
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down Expand Up @@ -264,18 +264,18 @@ public fun TwoTypeParameterSealedClass.TwoType.valueOf(name: String):
""".trimIndent()

interface GenericInterfaceInOut<in A, out B>
public interface GenericInterfaceInOut<in A, out B>

sealed class LimitedTypeParameterSealedClass<in Number, out String> : GenericInterfaceInOut<Number, String> {
object FirstObject : LimitedTypeParameterSealedClass<Int, String>()
public sealed class LimitedTypeParameterSealedClass<in Number, out String> : GenericInterfaceInOut<Number, String> {
public object FirstObject : LimitedTypeParameterSealedClass<Int, String>()

object SecondObject : LimitedTypeParameterSealedClass<Int, Any>()
public object SecondObject : LimitedTypeParameterSealedClass<Int, Any>()

@GenSealedEnum(generateEnum = true)
companion object LimitedType
public companion object LimitedType
}

val limitedTypeParameterSealedClassGenerated = """
public val limitedTypeParameterSealedClassGenerated: String = """
package com.livefront.sealedenum.compilation.generics
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down Expand Up @@ -396,20 +396,20 @@ public fun LimitedTypeParameterSealedClass.LimitedType.valueOf(name: String):
""".trimIndent()

interface MultipleBoundsInterface1
public interface MultipleBoundsInterface1

interface MultipleBoundsInterface2
public interface MultipleBoundsInterface2

interface MultipleBoundsInterface3 : MultipleBoundsInterface1, MultipleBoundsInterface2
public interface MultipleBoundsInterface3 : MultipleBoundsInterface1, MultipleBoundsInterface2

sealed class MultipleBoundsSealedClass<T> where T : MultipleBoundsInterface1, T : MultipleBoundsInterface2 {
object FirstObject : MultipleBoundsSealedClass<MultipleBoundsInterface3>()
public sealed class MultipleBoundsSealedClass<T> where T : MultipleBoundsInterface1, T : MultipleBoundsInterface2 {
public object FirstObject : MultipleBoundsSealedClass<MultipleBoundsInterface3>()

@GenSealedEnum(generateEnum = true)
companion object
public companion object
}

val multipleBoundsSealedClassGenerated = """
public val multipleBoundsSealedClassGenerated: String = """
package com.livefront.sealedenum.compilation.generics
import com.livefront.sealedenum.EnumForSealedEnumProvider
Expand Down
Loading

0 comments on commit 9b32edc

Please sign in to comment.