diff --git a/build.gradle.kts b/build.gradle.kts index 21af8cab..d72db753 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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.*") +} diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml index 2b4846aa..c96d4000 100644 --- a/config/detekt/detekt.yml +++ b/config/detekt/detekt.yml @@ -74,6 +74,7 @@ complexity: includePrivateDeclarations: false ComplexMethod: active: true + excludes: [ '**/generated/**' ] threshold: 15 ignoreSingleWhenExpression: false ignoreSimpleWhenEntries: false @@ -136,6 +137,7 @@ empty-blocks: active: true EmptyDefaultConstructor: active: true + excludes: [ '**/generated/**' ] EmptyDoWhileBlock: active: true EmptyElseBlock: @@ -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 @@ -267,6 +269,7 @@ formatting: autoCorrect: true NoConsecutiveBlankLines: active: true + excludes: [ '**/generated/**' ] autoCorrect: true NoEmptyClassBody: active: true @@ -279,6 +282,7 @@ formatting: autoCorrect: true NoLineBreakBeforeAssignment: active: true + excludes: [ '**/generated/**' ] autoCorrect: true NoMultipleSpaces: active: true @@ -312,6 +316,7 @@ formatting: autoCorrect: true SpacingAroundCurly: active: true + excludes: [ '**/generated/**' ] autoCorrect: true SpacingAroundDot: active: true @@ -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 @@ -388,6 +395,7 @@ naming: rootPackage: '' MatchingDeclarationName: active: true + excludes: ['**/generated/**'] mustBeFirst: true MemberNameEqualsClassName: active: true @@ -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]*' @@ -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 @@ -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 diff --git a/gradle.properties b/gradle.properties index 53465742..6127859e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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.4.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 34bc5cd3..ec4f5ebb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] autoService = "1.0" -detekt = "1.18.1" +detekt = "1.20.0" dokka = "1.5.31" incap = "0.3" junit = "5.8.1" diff --git a/processing-common/src/jvmMain/kotlin/com/livefront/sealedenum/internal/common/spec/SealedEnumSealedEnumPropertySpec.kt b/processing-common/src/jvmMain/kotlin/com/livefront/sealedenum/internal/common/spec/SealedEnumSealedEnumPropertySpec.kt index e6d9b1af..76decd47 100644 --- a/processing-common/src/jvmMain/kotlin/com/livefront/sealedenum/internal/common/spec/SealedEnumSealedEnumPropertySpec.kt +++ b/processing-common/src/jvmMain/kotlin/com/livefront/sealedenum/internal/common/spec/SealedEnumSealedEnumPropertySpec.kt @@ -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( @@ -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( diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedClass.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedClass.kt similarity index 96% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedClass.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedClass.kt index 11f53ca8..02022834 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedClass.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedClass.kt @@ -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 diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedInterface.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedInterface.kt similarity index 96% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedInterface.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedInterface.kt index 8b3696ce..fdc9de72 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedInterface.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/EmptySealedInterface.kt @@ -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 diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedClass.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedClass.kt similarity index 95% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedClass.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedClass.kt index 598869af..c628edfc 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedClass.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedClass.kt @@ -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 diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedInterface.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedInterface.kt similarity index 95% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedInterface.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedInterface.kt index ac5de035..b399d26a 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedInterface.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/OneObjectSealedInterface.kt @@ -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 diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedClass.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedClass.kt similarity index 94% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedClass.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedClass.kt index 41294199..7ffe8609 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedClass.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedClass.kt @@ -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 diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedInterface.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedInterface.kt similarity index 94% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedInterface.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedInterface.kt index 97455de6..9cd2b448 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedInterface.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/basic/TwoObjectSealedInterface.kt @@ -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 diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/GenericSealedClass.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/generics/GenericSealedClass.kt similarity index 91% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/GenericSealedClass.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/generics/GenericSealedClass.kt index 937d9002..0b7006de 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/GenericSealedClass.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/generics/GenericSealedClass.kt @@ -2,20 +2,20 @@ package com.livefront.sealedenum.compilation.generics import com.livefront.sealedenum.GenSealedEnum -interface GenericInterfaceOut +public interface GenericInterfaceOut -sealed class OneTypeParameterSealedClass : GenericInterfaceOut { - object FirstObject : OneTypeParameterSealedClass() +public sealed class OneTypeParameterSealedClass : GenericInterfaceOut { + public object FirstObject : OneTypeParameterSealedClass() - object SecondObject : OneTypeParameterSealedClass() + public object SecondObject : OneTypeParameterSealedClass() - object ThirdObject : OneTypeParameterSealedClass() + public object ThirdObject : OneTypeParameterSealedClass() @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 @@ -138,18 +138,18 @@ public fun OneTypeParameterSealedClass.OneType.valueOf(name: String): OneTypePar """.trimIndent() -interface GenericInterfaceTwoOut +public interface GenericInterfaceTwoOut -sealed class TwoTypeParameterSealedClass : GenericInterfaceTwoOut { - object FirstObject : TwoTypeParameterSealedClass() +public sealed class TwoTypeParameterSealedClass : GenericInterfaceTwoOut { + public object FirstObject : TwoTypeParameterSealedClass() - object SecondObject : TwoTypeParameterSealedClass() + public object SecondObject : TwoTypeParameterSealedClass() @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 @@ -264,18 +264,18 @@ public fun TwoTypeParameterSealedClass.TwoType.valueOf(name: String): TwoTypePar """.trimIndent() -interface GenericInterfaceInOut +public interface GenericInterfaceInOut -sealed class LimitedTypeParameterSealedClass : GenericInterfaceInOut { - object FirstObject : LimitedTypeParameterSealedClass() +public sealed class LimitedTypeParameterSealedClass : GenericInterfaceInOut { + public object FirstObject : LimitedTypeParameterSealedClass() - object SecondObject : LimitedTypeParameterSealedClass() + public object SecondObject : LimitedTypeParameterSealedClass() @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 @@ -397,20 +397,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 where T : MultipleBoundsInterface1, T : MultipleBoundsInterface2 { - object FirstObject : MultipleBoundsSealedClass() +public sealed class MultipleBoundsSealedClass where T : MultipleBoundsInterface1, T : MultipleBoundsInterface2 { + public object FirstObject : MultipleBoundsSealedClass() @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 diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClasses.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClasses.kt similarity index 90% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClasses.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClasses.kt index 3f011993..36565b71 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClasses.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClasses.kt @@ -2,22 +2,25 @@ package com.livefront.sealedenum.compilation.generics import com.livefront.sealedenum.GenSealedEnum -interface BaseClassInterface1 +public interface BaseClassInterface1 -interface BaseClassInterface2 +public interface BaseClassInterface2 -interface BaseClassInterface3 +public interface BaseClassInterface3 -abstract class AlphaBase : BaseClassInterface1 +@Suppress("UnnecessaryAbstractClass") +public abstract class AlphaBase : BaseClassInterface1 -abstract class BetaBase : AlphaBase>(), BaseClassInterface2 +@Suppress("UnnecessaryAbstractClass") +public abstract class BetaBase : AlphaBase>(), BaseClassInterface2 -sealed class SealedEnumWithAbstractBaseClasses : BetaBase() { +public sealed class SealedEnumWithAbstractBaseClasses : BetaBase() { @GenSealedEnum(generateEnum = true) - companion object + public companion object } -val sealedEnumWithAbstractBaseClassesGenerated = """ +@Suppress("MaxLineLength") +public val sealedEnumWithAbstractBaseClassesGenerated: String = """ package com.livefront.sealedenum.compilation.generics import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -121,16 +124,19 @@ public fun SealedEnumWithAbstractBaseClasses.Companion.valueOf(name: String): """.trimIndent() -abstract class GammaBase +@Suppress("UnnecessaryAbstractClass") +public abstract class GammaBase -abstract class DeltaBase : GammaBase(), BaseClassInterface3> +@Suppress("UnnecessaryAbstractClass") +public abstract class DeltaBase : GammaBase(), BaseClassInterface3> -sealed class SealedEnumWithAbstractBaseClassesCovariantType : DeltaBase() { +public sealed class SealedEnumWithAbstractBaseClassesCovariantType : DeltaBase() { @GenSealedEnum(generateEnum = true) - companion object + public companion object } -val sealedEnumWithAbstractBaseClassesCovariantTypeGenerated = """ +@Suppress("MaxLineLength") +public val sealedEnumWithAbstractBaseClassesCovariantTypeGenerated: String = """ package com.livefront.sealedenum.compilation.generics import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithInterfaces.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithInterfaces.kt similarity index 93% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithInterfaces.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithInterfaces.kt index 4d6d8e89..210fbcf7 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithInterfaces.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithInterfaces.kt @@ -2,20 +2,21 @@ package com.livefront.sealedenum.compilation.generics import com.livefront.sealedenum.GenSealedEnum -interface TestInterface +public interface TestInterface -interface TestGenericInterface +public interface TestGenericInterface -interface TestGetterInterface { - fun get(): String +public interface TestGetterInterface { + public fun get(): String } -sealed class EmptySealedClassWithInterface : TestInterface { +public sealed class EmptySealedClassWithInterface : TestInterface { @GenSealedEnum(generateEnum = true) - companion object + public companion object } -val emptySealedClassWithInterfaceGenerated = """ +@Suppress("MaxLineLength") +public val emptySealedClassWithInterfaceGenerated: String = """ package com.livefront.sealedenum.compilation.generics import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -112,14 +113,15 @@ public fun EmptySealedClassWithInterface.Companion.valueOf(name: String): """.trimIndent() -sealed class OneObjectSealedClassWithInterface : TestInterface { - object FirstObject : OneObjectSealedClassWithInterface() +public sealed class OneObjectSealedClassWithInterface : TestInterface { + public object FirstObject : OneObjectSealedClassWithInterface() @GenSealedEnum(generateEnum = true) - companion object + public companion object } -val oneObjectSealedClassWithInterfaceGenerated = """ +@Suppress("MaxLineLength") +public val oneObjectSealedClassWithInterfaceGenerated: String = """ package com.livefront.sealedenum.compilation.generics import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -235,15 +237,16 @@ public fun OneObjectSealedClassWithInterface.Companion.valueOf(name: String): """.trimIndent() -sealed class TwoObjectSealedClassWithGenericInterface : TestGenericInterface { - object FirstObject : TwoObjectSealedClassWithGenericInterface() - object SecondObject : TwoObjectSealedClassWithGenericInterface() +public sealed class TwoObjectSealedClassWithGenericInterface : TestGenericInterface { + public object FirstObject : TwoObjectSealedClassWithGenericInterface() + public object SecondObject : TwoObjectSealedClassWithGenericInterface() @GenSealedEnum(generateEnum = true) - companion object + public companion object } -val twoObjectSealedClassWithGenericInterfaceGenerated = """ +@Suppress("MaxLineLength") +public val twoObjectSealedClassWithGenericInterfaceGenerated: String = """ package com.livefront.sealedenum.compilation.generics import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -377,10 +380,10 @@ public fun TwoObjectSealedClassWithGenericInterface.Companion.valueOf(name: Stri """.trimIndent() -var hasGetBeenCalled = false +public var hasGetBeenCalled: Boolean = false -sealed class SealedClassWithGetterInterface : TestGetterInterface { - object FirstObject : SealedClassWithGetterInterface() { +public sealed class SealedClassWithGetterInterface : TestGetterInterface { + public object FirstObject : SealedClassWithGetterInterface() { override fun get(): String { hasGetBeenCalled = true @@ -389,10 +392,11 @@ sealed class SealedClassWithGetterInterface : TestGetterInterface { } @GenSealedEnum(generateEnum = true) - companion object + public companion object } -val sealedClassWithGetterInterface = """ +@Suppress("MaxLineLength") +public val sealedClassWithGetterInterface: String = """ package com.livefront.sealedenum.compilation.generics import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedClassHierarchy.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedClassHierarchy.kt similarity index 94% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedClassHierarchy.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedClassHierarchy.kt index 3fb1d132..d5383765 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedClassHierarchy.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedClassHierarchy.kt @@ -2,23 +2,23 @@ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.GenSealedEnum -class FirstClassHierarchy { +public class FirstClassHierarchy { - sealed class A { + public sealed class A { - sealed class B : A() { - object C : B() + public sealed class B : A() { + public object C : B() @GenSealedEnum(generateEnum = true) - companion object + public companion object } @GenSealedEnum(generateEnum = true) - companion object + public companion object } } -val firstClassHierarchyAGenerated = """ +public val firstClassHierarchyAGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -121,7 +121,7 @@ public fun FirstClassHierarchy.A.Companion.valueOf(name: String): FirstClassHier """.trimIndent() -val firstClassHierarchyBGenerated = """ +public val firstClassHierarchyBGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -224,52 +224,52 @@ public fun FirstClassHierarchy.A.B.Companion.valueOf(name: String): FirstClassHi """.trimIndent() -class SecondClassHierarchy { +public class SecondClassHierarchy { - sealed class A { + public sealed class A { - object B : A() + public object B : A() - sealed class C : A() { + public sealed class C : A() { - object D : C() + public object D : C() - object E : C() + public object E : C() - sealed class F : C() { - object G : F() + public sealed class F : C() { + public object G : F() @GenSealedEnum - companion object + public companion object } - sealed class H : C() { - object I : H() + public sealed class H : C() { + public object I : H() @GenSealedEnum - companion object + public companion object } @GenSealedEnum - companion object + public companion object } - sealed class J : A() { + public sealed class J : A() { - object K : J() + public object K : J() @GenSealedEnum - companion object + public companion object } - object L : A() + public object L : A() @GenSealedEnum - companion object + public companion object } } -val secondClassHierarchyAGenerated = """ +public val secondClassHierarchyAGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum @@ -359,7 +359,7 @@ public fun SecondClassHierarchy.A.Companion.valueOf(name: String): SecondClassHi """.trimIndent() -val secondClassHierarchyACGenerated = """ +public val secondClassHierarchyACGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum @@ -437,7 +437,7 @@ public fun SecondClassHierarchy.A.C.Companion.valueOf(name: String): SecondClass """.trimIndent() -val secondClassHierarchyACFGenerated = """ +public val secondClassHierarchyACFGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum @@ -503,7 +503,7 @@ public fun SecondClassHierarchy.A.C.F.Companion.valueOf(name: String): SecondCla """.trimIndent() -val secondClassHierarchyACHGenerated = """ +public val secondClassHierarchyACHGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum @@ -569,7 +569,7 @@ public fun SecondClassHierarchy.A.C.H.Companion.valueOf(name: String): SecondCla """.trimIndent() -val secondClassHierarchyAJGenerated = """ +public val secondClassHierarchyAJGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedInterfaceHierarchy.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedInterfaceHierarchy.kt similarity index 94% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedInterfaceHierarchy.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedInterfaceHierarchy.kt index cab6d98e..9a1d7831 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedInterfaceHierarchy.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/hierarchy/SealedInterfaceHierarchy.kt @@ -2,23 +2,23 @@ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.GenSealedEnum -class FirstInterfaceHierarchy { +public class FirstInterfaceHierarchy { - sealed interface A { + public sealed interface A { - sealed interface B : A { - object C : B + public sealed interface B : A { + public object C : B @GenSealedEnum(generateEnum = true) - companion object + public companion object } @GenSealedEnum(generateEnum = true) - companion object + public companion object } } -val firstInterfaceHierarchyAGenerated = """ +public val firstInterfaceHierarchyAGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -121,7 +121,7 @@ public fun FirstInterfaceHierarchy.A.Companion.valueOf(name: String): FirstInter """.trimIndent() -val firstInterfaceHierarchyBGenerated = """ +public val firstInterfaceHierarchyBGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -226,52 +226,52 @@ public fun FirstInterfaceHierarchy.A.B.Companion.valueOf(name: String): FirstInt """.trimIndent() -class SecondInterfaceHierarchy { +public class SecondInterfaceHierarchy { - sealed interface A { + public sealed interface A { - object B : A + public object B : A - sealed interface C : A { + public sealed interface C : A { - object D : C + public object D : C - object E : C + public object E : C - sealed interface F : C { - object G : F + public sealed interface F : C { + public object G : F @GenSealedEnum - companion object + public companion object } - sealed interface H : C { - object I : H + public sealed interface H : C { + public object I : H @GenSealedEnum - companion object + public companion object } @GenSealedEnum - companion object + public companion object } - sealed interface J : A { + public sealed interface J : A { - object K : J + public object K : J @GenSealedEnum - companion object + public companion object } - object L : A + public object L : A @GenSealedEnum - companion object + public companion object } } -val secondInterfaceHierarchyAGenerated = """ +public val secondInterfaceHierarchyAGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum @@ -361,7 +361,7 @@ public fun SecondInterfaceHierarchy.A.Companion.valueOf(name: String): SecondInt """.trimIndent() -val secondInterfaceHierarchyACGenerated = """ +public val secondInterfaceHierarchyACGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum @@ -439,7 +439,7 @@ public fun SecondInterfaceHierarchy.A.C.Companion.valueOf(name: String): """.trimIndent() -val secondInterfaceHierarchyACFGenerated = """ +public val secondInterfaceHierarchyACFGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum @@ -507,7 +507,7 @@ public fun SecondInterfaceHierarchy.A.C.F.Companion.valueOf(name: String): """.trimIndent() -val secondInterfaceHierarchyACHGenerated = """ +public val secondInterfaceHierarchyACHGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum @@ -575,7 +575,7 @@ public fun SecondInterfaceHierarchy.A.C.H.Companion.valueOf(name: String): """.trimIndent() -val secondInterfaceHierarchyAJGenerated = """ +public val secondInterfaceHierarchyAJGenerated: String = """ package com.livefront.sealedenum.compilation.hierarchy import com.livefront.sealedenum.SealedEnum diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/NestedClass.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/NestedClass.kt similarity index 91% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/NestedClass.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/NestedClass.kt index 98d9a4fd..6757a612 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/NestedClass.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/NestedClass.kt @@ -2,18 +2,18 @@ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.GenSealedEnum -class OuterClass { - sealed class InsideOneClassSealedClass { - object FirstObject : InsideOneClassSealedClass() +public class OuterClass { + public sealed class InsideOneClassSealedClass { + public object FirstObject : InsideOneClassSealedClass() - object SecondObject : InsideOneClassSealedClass() + public object SecondObject : InsideOneClassSealedClass() @GenSealedEnum - companion object + public companion object } } -val insideOneClassSealedClassGenerated = """ +public val insideOneClassSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.SealedEnum @@ -92,20 +92,20 @@ public fun OuterClass.InsideOneClassSealedClass.Companion.valueOf(name: String): """.trimIndent() -class FirstOuterClass { - class SecondOuterClass { - sealed class InsideTwoClassesSealedClass { - object FirstObject : InsideTwoClassesSealedClass() +public class FirstOuterClass { + public class SecondOuterClass { + public sealed class InsideTwoClassesSealedClass { + public object FirstObject : InsideTwoClassesSealedClass() - object SecondObject : InsideTwoClassesSealedClass() + public object SecondObject : InsideTwoClassesSealedClass() @GenSealedEnum - companion object + public companion object } } } -val insideTwoClassesSealedClassGenerated = """ +public val insideTwoClassesSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.SealedEnum diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/OutsideSealedClass.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/OutsideSealedClass.kt similarity index 94% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/OutsideSealedClass.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/OutsideSealedClass.kt index aeb964cb..ce562e7a 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/OutsideSealedClass.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/OutsideSealedClass.kt @@ -2,14 +2,14 @@ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.GenSealedEnum -sealed class AlphaOutsideSealedClass { +public sealed class AlphaOutsideSealedClass { @GenSealedEnum(generateEnum = true) - companion object + public companion object } -object AlphaFirstObject : AlphaOutsideSealedClass() +public object AlphaFirstObject : AlphaOutsideSealedClass() -val alphaOutsideSealedClassGenerated = """ +public val alphaOutsideSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -112,16 +112,16 @@ public fun AlphaOutsideSealedClass.Companion.valueOf(name: String): AlphaOutside """.trimIndent() -sealed class BetaOutsideSealedClass { +public sealed class BetaOutsideSealedClass { @GenSealedEnum(generateEnum = true) - companion object + public companion object } -object BetaFirstObject : BetaOutsideSealedClass() +public object BetaFirstObject : BetaOutsideSealedClass() -object BetaSecondObject : BetaOutsideSealedClass() +public object BetaSecondObject : BetaOutsideSealedClass() -val betaOutsideSealedClassGenerated = """ +public val betaOutsideSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -231,19 +231,19 @@ public fun BetaOutsideSealedClass.Companion.valueOf(name: String): BetaOutsideSe """.trimIndent() -object GammaFirstObject : GammaOutsideSealedClass() +public object GammaFirstObject : GammaOutsideSealedClass() -sealed class GammaOutsideSealedClass { +public sealed class GammaOutsideSealedClass { - object GammaSecondObject : GammaOutsideSealedClass() + public object GammaSecondObject : GammaOutsideSealedClass() @GenSealedEnum(generateEnum = true) - companion object + public companion object } -object GammaThirdObject : GammaOutsideSealedClass() +public object GammaThirdObject : GammaOutsideSealedClass() -val gammaOutsideSealedClassGenerated = """ +public val gammaOutsideSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -362,16 +362,16 @@ public fun GammaOutsideSealedClass.Companion.valueOf(name: String): GammaOutside """.trimIndent() -sealed class DeltaOutsideSealedClass { - object DeltaObject : DeltaOutsideSealedClass() +public sealed class DeltaOutsideSealedClass { + public object DeltaObject : DeltaOutsideSealedClass() @GenSealedEnum(generateEnum = true) - companion object + public companion object } -object DeltaObject : DeltaOutsideSealedClass() +public object DeltaObject : DeltaOutsideSealedClass() -val deltaOutsideSealedClassGenerated = """ +public val deltaOutsideSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSealedClass.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSealedClass.kt similarity index 97% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSealedClass.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSealedClass.kt index 6e71fcff..e86e51d1 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSealedClass.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSealedClass.kt @@ -2,13 +2,13 @@ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.GenSealedEnum -sealed class SplitAcrossFilesSealedClass { +public sealed class SplitAcrossFilesSealedClass { @GenSealedEnum(generateEnum = true) - companion object + public companion object } -val splitAcrossFilesSealedClassGenerated = """ +public val splitAcrossFilesSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.location import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassA.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassA.kt new file mode 100644 index 00000000..f71deb2c --- /dev/null +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassA.kt @@ -0,0 +1,3 @@ +package com.livefront.sealedenum.compilation.location + +public object SplitAcrossFilesSubclassA : SplitAcrossFilesSealedClass() diff --git a/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassB.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassB.kt new file mode 100644 index 00000000..ee90e9b6 --- /dev/null +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassB.kt @@ -0,0 +1,3 @@ +package com.livefront.sealedenum.compilation.location + +public object SplitAcrossFilesSubclassB : SplitAcrossFilesSealedClass() diff --git a/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassC.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassC.kt new file mode 100644 index 00000000..b7cdff42 --- /dev/null +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassC.kt @@ -0,0 +1,3 @@ +package com.livefront.sealedenum.compilation.location + +public object SplitAcrossFilesSubclassC : SplitAcrossFilesSealedClass() diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/traversal/TraversalOrder.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/traversal/TraversalOrder.kt similarity index 96% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/traversal/TraversalOrder.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/traversal/TraversalOrder.kt index 7983549c..5a21af2d 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/traversal/TraversalOrder.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/traversal/TraversalOrder.kt @@ -5,62 +5,62 @@ package com.livefront.sealedenum.compilation.traversal import com.livefront.sealedenum.GenSealedEnum import com.livefront.sealedenum.TreeTraversalOrder -sealed class Tree { +public sealed class Tree { - object A : Tree() + public object A : Tree() - sealed class B : Tree() { + public sealed class B : Tree() { - sealed class C : B() { + public sealed class C : B() { - object D : C() + public object D : C() - object E : C() + public object E : C() - sealed class F : C() { + public sealed class F : C() { - object G : F() + public object G : F() - object H : F() + public object H : F() - object I : F() + public object I : F() } - object J : C() + public object J : C() } } - object K : Tree() + public object K : Tree() - sealed class L : Tree() { + public sealed class L : Tree() { - sealed class M : L() { + public sealed class M : L() { - object N : M() + public object N : M() - object O : M() + public object O : M() } - sealed class P : L() { + public sealed class P : L() { - object Q : P() + public object Q : P() - object R : P() + public object R : P() } - object S : L() + public object S : L() } - object T : Tree() + public object T : Tree() @GenSealedEnum(traversalOrder = TreeTraversalOrder.PRE_ORDER, generateEnum = true) @GenSealedEnum(traversalOrder = TreeTraversalOrder.IN_ORDER, generateEnum = true) @GenSealedEnum(traversalOrder = TreeTraversalOrder.POST_ORDER, generateEnum = true) @GenSealedEnum(traversalOrder = TreeTraversalOrder.LEVEL_ORDER, generateEnum = true) - companion object + public companion object } -val treeGenerated = """ +public val treeGenerated: String = """ package com.livefront.sealedenum.compilation.traversal import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/usecases/EnvironmentsSealedEnum.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/usecases/EnvironmentsSealedEnum.kt similarity index 90% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/usecases/EnvironmentsSealedEnum.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/usecases/EnvironmentsSealedEnum.kt index 18e684d3..73e7840e 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/usecases/EnvironmentsSealedEnum.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/usecases/EnvironmentsSealedEnum.kt @@ -2,39 +2,39 @@ package com.livefront.sealedenum.compilation.usecases import com.livefront.sealedenum.GenSealedEnum -interface Uri { - val scheme: String - val authority: String - val path: String +public interface Uri { + public val scheme: String + public val authority: String + public val path: String } -sealed class Environments( +public sealed class Environments( override val scheme: String, override val authority: String, override val path: String ) : Uri { - sealed class Http( + public sealed class Http( override val authority: String, override val path: String ) : Environments("http", authority, path) { - object Livefront : Http("www.livefront.com", "/") - object Google : Http("www.google.com", "/") + public object Livefront : Http("www.livefront.com", "/") + public object Google : Http("www.google.com", "/") } - sealed class Https( + public sealed class Https( override val authority: String, override val path: String ) : Environments("https", authority, path) { - object Livefront : Https("www.livefront.com", "/") - object Google : Https("www.google.com", "/") + public object Livefront : Https("www.livefront.com", "/") + public object Google : Https("www.google.com", "/") } @GenSealedEnum(generateEnum = true) - companion object + public companion object } -val environmentsGenerated = """ +public val environmentsGenerated: String = """ package com.livefront.sealedenum.compilation.usecases import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/visibility/VisibilitySealedClass.kt b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/visibility/VisibilitySealedClass.kt similarity index 97% rename from processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/visibility/VisibilitySealedClass.kt rename to processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/visibility/VisibilitySealedClass.kt index fee75f48..188982cd 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/visibility/VisibilitySealedClass.kt +++ b/processing-tests/common/src/commonMain/kotlin/com/livefront/sealedenum/compilation/visibility/VisibilitySealedClass.kt @@ -2,7 +2,7 @@ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.GenSealedEnum -sealed class InternalObjectsSealedClass { +public sealed class InternalObjectsSealedClass { internal object FirstObject : InternalObjectsSealedClass() internal object SecondObject : InternalObjectsSealedClass() @@ -12,10 +12,10 @@ sealed class InternalObjectsSealedClass { } @GenSealedEnum(generateEnum = true) - companion object + public companion object } -val internalObjectsSealedClassGenerated = """ +public val internalObjectsSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -149,7 +149,7 @@ internal sealed class InternalSealedClass { companion object } -val internalSealedClassGenerated = """ +public val internalSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -259,8 +259,8 @@ internal fun InternalSealedClass.Companion.valueOf(name: String): InternalSealed """.trimIndent() -sealed class InternalCompanionSealedClass { - object FirstObject : InternalCompanionSealedClass() +public sealed class InternalCompanionSealedClass { + public object FirstObject : InternalCompanionSealedClass() internal object SecondObject : InternalCompanionSealedClass() @@ -268,7 +268,7 @@ sealed class InternalCompanionSealedClass { internal companion object } -val internalCompanionSealedClassGenerated = """ +public val internalCompanionSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.EnumForSealedEnumProvider @@ -392,7 +392,7 @@ internal sealed class InternalSealedAndCompanionSealedClass { internal companion object } -val internalSealedAndCompanionSealedClassGenerated = """ +public val internalSealedAndCompanionSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClassesTests.kt b/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClassesTests.kt index b4f4c6cf..73dd5af8 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClassesTests.kt +++ b/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/generics/SealedEnumWithAbstractBaseClassesTests.kt @@ -3,7 +3,6 @@ package com.livefront.sealedenum.compilation.generics import kotlin.test.Test import kotlin.test.assertEquals -@OptIn(ExperimentalStdlibApi::class) class SealedEnumWithAbstractBaseClassesTests { @Test fun enum_implements_correct_interfaces_with_type_arguments() { diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassA.kt b/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassA.kt deleted file mode 100644 index d42ef1bd..00000000 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassA.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.livefront.sealedenum.compilation.location - -object SplitAcrossFilesSubclassA : SplitAcrossFilesSealedClass() diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassB.kt b/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassB.kt deleted file mode 100644 index 7453c7cb..00000000 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassB.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.livefront.sealedenum.compilation.location - -object SplitAcrossFilesSubclassB : SplitAcrossFilesSealedClass() diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassC.kt b/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassC.kt deleted file mode 100644 index 5233abd5..00000000 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/location/SplitAcrossFilesSubclassC.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.livefront.sealedenum.compilation.location - -object SplitAcrossFilesSubclassC : SplitAcrossFilesSealedClass() diff --git a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/testing/ProcessingType.kt b/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/testing/ProcessingType.kt index 59917d24..dbf56fbc 100644 --- a/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/testing/ProcessingType.kt +++ b/processing-tests/common/src/commonTest/kotlin/com/livefront/sealedenum/testing/ProcessingType.kt @@ -1,18 +1,13 @@ package com.livefront.sealedenum.testing -import com.livefront.sealedenum.GenSealedEnum +import kotlin.jvm.JvmStatic -sealed class ProcessingType { - - object AnnotationProcessing : ProcessingType() - - object KotlinSymbolProcessing : ProcessingType() - - @GenSealedEnum(generateEnum = true) +enum class ProcessingType { + AnnotationProcessing, KotlinSymbolProcessing; companion object } object ProcessingTypeGetter { @JvmStatic - fun isKSP(): Boolean = ProcessingType.currentType is ProcessingType.KotlinSymbolProcessing + fun isKSP(): Boolean = ProcessingType.currentType == ProcessingType.KotlinSymbolProcessing } diff --git a/processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/JavaPrivateInterfaceOuterClass.java b/processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/JavaPrivateInterfaceOuterClass.java similarity index 100% rename from processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/JavaPrivateInterfaceOuterClass.java rename to processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/JavaPrivateInterfaceOuterClass.java diff --git a/processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/JavaPrivateInterfaceSubclass.java b/processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/JavaPrivateInterfaceSubclass.java similarity index 100% rename from processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/JavaPrivateInterfaceSubclass.java rename to processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/JavaPrivateInterfaceSubclass.java diff --git a/processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/JavaProtectedInterfaceBaseClass.java b/processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/JavaProtectedInterfaceBaseClass.java similarity index 100% rename from processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/JavaProtectedInterfaceBaseClass.java rename to processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/JavaProtectedInterfaceBaseClass.java diff --git a/processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/JavaProtectedInterfaceSubclass.java b/processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/JavaProtectedInterfaceSubclass.java similarity index 100% rename from processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/JavaProtectedInterfaceSubclass.java rename to processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/JavaProtectedInterfaceSubclass.java diff --git a/processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/subpackage/JavaProtectedInterfaceBaseClass.java b/processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/subpackage/JavaProtectedInterfaceBaseClass.java similarity index 100% rename from processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/subpackage/JavaProtectedInterfaceBaseClass.java rename to processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/subpackage/JavaProtectedInterfaceBaseClass.java diff --git a/processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/subpackage/JavaProtectedInterfaceSubclass.java b/processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/subpackage/JavaProtectedInterfaceSubclass.java similarity index 100% rename from processing-tests/common/src/jvmTest/java/com/livefront/sealedenum/compilation/visibility/subpackage/JavaProtectedInterfaceSubclass.java rename to processing-tests/common/src/jvmMain/java/com/livefront/sealedenum/compilation/visibility/subpackage/JavaProtectedInterfaceSubclass.java diff --git a/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/visibility/PrivateInterfaceSealedClass.kt b/processing-tests/common/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/visibility/PrivateInterfaceSealedClass.kt similarity index 94% rename from processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/visibility/PrivateInterfaceSealedClass.kt rename to processing-tests/common/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/visibility/PrivateInterfaceSealedClass.kt index 1c57bfbc..642e5716 100644 --- a/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/visibility/PrivateInterfaceSealedClass.kt +++ b/processing-tests/common/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/visibility/PrivateInterfaceSealedClass.kt @@ -3,21 +3,21 @@ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.GenSealedEnum import org.intellij.lang.annotations.Language -sealed class PrivateInterfaceSealedClass : +public sealed class PrivateInterfaceSealedClass : JavaPrivateInterfaceSubclass(JavaPrivateInterfaceOuterClass()), PrivateInterface { - object FirstObject : PrivateInterfaceSealedClass() + public object FirstObject : PrivateInterfaceSealedClass() - object SecondObject : PrivateInterfaceSealedClass() + public object SecondObject : PrivateInterfaceSealedClass() @GenSealedEnum(generateEnum = true) - companion object + public companion object } private interface PrivateInterface @Language("kotlin") -val privateInterfaceSealedClassGenerated = """ +public val privateInterfaceSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClass.kt b/processing-tests/common/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClass.kt similarity index 94% rename from processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClass.kt rename to processing-tests/common/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClass.kt index e1c3e9d7..34fb9e66 100644 --- a/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClass.kt +++ b/processing-tests/common/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClass.kt @@ -5,24 +5,25 @@ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.GenSealedEnum import org.intellij.lang.annotations.Language -open class ProtectedInterfaceOuterClass { +public open class ProtectedInterfaceOuterClass { protected interface ProtectedInterface - sealed class ProtectedInterfaceSealedClass : - com.livefront.sealedenum.compilation.visibility.JavaProtectedInterfaceSubclass(), ProtectedInterface { + public sealed class ProtectedInterfaceSealedClass : + JavaProtectedInterfaceSubclass(), ProtectedInterface { - object FirstObject : ProtectedInterfaceSealedClass() + public object FirstObject : ProtectedInterfaceSealedClass() - object SecondObject : ProtectedInterfaceSealedClass() + public object SecondObject : ProtectedInterfaceSealedClass() @GenSealedEnum(generateEnum = true) - companion object + public companion object } } +@Suppress("MaxLineLength") @Language("kotlin") -val protectedInterfaceSealedClassGenerated = """ +public val protectedInterfaceSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClassWithDifferentPackageBaseClass.kt b/processing-tests/common/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClassWithDifferentPackageBaseClass.kt similarity index 95% rename from processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClassWithDifferentPackageBaseClass.kt rename to processing-tests/common/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClassWithDifferentPackageBaseClass.kt index 7cd2a07f..45856074 100644 --- a/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClassWithDifferentPackageBaseClass.kt +++ b/processing-tests/common/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/visibility/ProtectedInterfaceSealedClassWithDifferentPackageBaseClass.kt @@ -5,25 +5,26 @@ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.GenSealedEnum import org.intellij.lang.annotations.Language -open class ProtectedInterfaceOuterClassWithDifferentPackageBaseClass { +public open class ProtectedInterfaceOuterClassWithDifferentPackageBaseClass { protected interface ProtectedInterface - sealed class ProtectedInterfaceSealedClass : + public sealed class ProtectedInterfaceSealedClass : com.livefront.sealedenum.compilation.visibility.subpackage.JavaProtectedInterfaceSubclass(), ProtectedInterface { - object FirstObject : ProtectedInterfaceSealedClass() + public object FirstObject : ProtectedInterfaceSealedClass() - object SecondObject : ProtectedInterfaceSealedClass() + public object SecondObject : ProtectedInterfaceSealedClass() @GenSealedEnum(generateEnum = true) - companion object + public companion object } } +@Suppress("MaxLineLength") @Language("kotlin") -val protectedInterfaceSealedClassWithDifferentPackageBaseClassGenerated = """ +public val protectedInterfaceSealedClassWithDifferentPackageBaseClassGenerated: String = """ package com.livefront.sealedenum.compilation.visibility import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/testing/PathsUtils.kt b/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/testing/PathsUtils.kt index 612cb499..c9311cb6 100644 --- a/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/testing/PathsUtils.kt +++ b/processing-tests/common/src/jvmTest/kotlin/com/livefront/sealedenum/testing/PathsUtils.kt @@ -14,12 +14,13 @@ internal fun getSourceFile( ): SourceFile { val relativePaths = when (sharableProcessingSourceType) { SharableProcessingSourceType.COMMMON -> arrayOf("..", "common") + SharableProcessingSourceType.KSP_COMMON -> arrayOf("..", "ksp-common-tests") SharableProcessingSourceType.UNIQUE -> emptyArray() } + arrayOf( "src", when (platformSourceType) { - PlatformSourceType.COMMON -> "commonTest" - PlatformSourceType.JVM -> "jvmTest" + PlatformSourceType.COMMON -> "commonMain" + PlatformSourceType.JVM -> "jvmMain" }, if (paths.last().endsWith(".java")) "java" else "kotlin", "com", @@ -45,7 +46,12 @@ enum class SharableProcessingSourceType { COMMMON, /** - * Source files unique to a specific type of processing (kapt vs ksp) + * Source files common to ksp processing + */ + KSP_COMMON, + + /** + * Source files unique to the current tests */ UNIQUE } diff --git a/processing-tests/ksp-common-tests/README.md b/processing-tests/ksp-common-tests/README.md new file mode 100644 index 00000000..59cf90a4 --- /dev/null +++ b/processing-tests/ksp-common-tests/README.md @@ -0,0 +1,7 @@ +# ksp-java-tests + +Tests that verify the KSP processor's Java-specific functionality. + +This module uses shared `commonMain`, `jvmMain`, `commonTest` and `jvmTest` code from [common/src](../common/src). + +This module exists because we want to apply `ksp` only to `commonMain` code, and we can't do that while also applying `ksp` to `jvmMain` code. diff --git a/processing-tests/ksp-common-tests/build.gradle.kts b/processing-tests/ksp-common-tests/build.gradle.kts new file mode 100644 index 00000000..9ff0379d --- /dev/null +++ b/processing-tests/ksp-common-tests/build.gradle.kts @@ -0,0 +1,66 @@ +plugins { + id("com.livefront.sealedenum.kotlin") + id("com.livefront.sealedenum.detekt") + alias(libs.plugins.ksp) +} + +/** + * Swap to `true` to allow debugging other tests that share code + */ +val disableForSharedCode = false + +kotlin { + jvm() + + js(BOTH) { + browser() + nodejs() + } + + macosX64() + iosArm32(); iosArm64(); iosX64() + watchosArm32(); watchosArm64(); watchosX86(); watchosX64() + + linuxArm64(); linuxX64() + mingwX86(); mingwX64() + + sourceSets { + val commonMain by getting { + dependencies { + implementation(projects.runtime) + project.dependencies.add("kspMetadata", projects.ksp) + } + if (!disableForSharedCode) { + kotlin.srcDir("$rootDir/processing-tests/common/src/commonMain") + } + kotlin.srcDir("$buildDir/generated/ksp/commonMain/kotlin") + } + + val commonTest by getting { + dependencies { + implementation(kotlin("reflect")) + implementation(kotlin("test")) + } + if (!disableForSharedCode) { + kotlin.srcDir("$rootDir/processing-tests/common/src/commonTest") + } + } + } +} + +tasks { + withType>().all { + if (name != "kspKotlinMetadata") { + dependsOn("kspKotlinMetadata") + } + } +} + +detekt { + source = files( + "src/commonMain/kotlin", + "src/commonTest/kotlin", + "$rootDir/processing-tests/common/src/commonMain/kotlin", + "$rootDir/processing-tests/common/src/commonTest/kotlin", + ) +} diff --git a/processing-tests/ksp-tests/src/commonTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameName.kt b/processing-tests/ksp-common-tests/src/commonMain/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameName.kt similarity index 95% rename from processing-tests/ksp-tests/src/commonTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameName.kt rename to processing-tests/ksp-common-tests/src/commonMain/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameName.kt index f5b2c5c2..3a296358 100644 --- a/processing-tests/ksp-tests/src/commonTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameName.kt +++ b/processing-tests/ksp-common-tests/src/commonMain/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameName.kt @@ -3,16 +3,16 @@ package com.livefront.sealedenum.compilation.ksp import com.livefront.sealedenum.GenSealedEnum @Suppress("UtilityClassWithPublicConstructor") -class NestedObjectsWithSameName { - companion object { - sealed class EmptySealedClass { +public class NestedObjectsWithSameName { + public companion object { + public sealed class EmptySealedClass { @GenSealedEnum(generateEnum = true) - companion object + public companion object } } } -val nestedObjectsWithSameNameEmptySealedClassGenerated = """ +public val nestedObjectsWithSameNameEmptySealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.ksp import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/ksp-tests/src/commonTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameTests.kt b/processing-tests/ksp-common-tests/src/commonTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameTests.kt similarity index 100% rename from processing-tests/ksp-tests/src/commonTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameTests.kt rename to processing-tests/ksp-common-tests/src/commonTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameTests.kt diff --git a/processing-tests/ksp-tests/src/commonTest/kotlin/com/livefront/sealedenum/testing/CurrentProcessingType.kt b/processing-tests/ksp-common-tests/src/commonTest/kotlin/com/livefront/sealedenum/testing/CurrentProcessingType.kt similarity index 100% rename from processing-tests/ksp-tests/src/commonTest/kotlin/com/livefront/sealedenum/testing/CurrentProcessingType.kt rename to processing-tests/ksp-common-tests/src/commonTest/kotlin/com/livefront/sealedenum/testing/CurrentProcessingType.kt diff --git a/processing-tests/ksp-java-tests/README.md b/processing-tests/ksp-java-tests/README.md new file mode 100644 index 00000000..79de4d3b --- /dev/null +++ b/processing-tests/ksp-java-tests/README.md @@ -0,0 +1,7 @@ +# ksp-java-tests + +Tests that verify the KSP processor's Java-specific functionality. + +This module uses shared `commonMain`, `jvmMain`, `commonTest` and `jvmTest` code from [common/src](../common/src), and also uses shared `commonMain` and `commonTest` code from [ksp-common-tests/src](../ksp-common-tests/src). + +This module exists because we want to apply `ksp` only to `jvmMain` code, and we can't do that while also applying `ksp` to `commonMain` code. diff --git a/processing-tests/ksp-tests/build.gradle.kts b/processing-tests/ksp-java-tests/build.gradle.kts similarity index 52% rename from processing-tests/ksp-tests/build.gradle.kts rename to processing-tests/ksp-java-tests/build.gradle.kts index 9996244a..efcda2ee 100644 --- a/processing-tests/ksp-tests/build.gradle.kts +++ b/processing-tests/ksp-java-tests/build.gradle.kts @@ -5,22 +5,41 @@ plugins { } /** - * Swap to `true` to allow debugging `processor-tests` + * Swap to `true` to allow debugging other tests that share code */ -val debugProcessor = false +val disableForSharedCode = false kotlin { jvm() sourceSets { + val commonMain by getting { + dependencies { + implementation(projects.runtime) + } + if (!disableForSharedCode) { + kotlin.srcDir("$rootDir/processing-tests/common/src/commonMain") + kotlin.srcDir("$rootDir/processing-tests/ksp-common-tests/src/commonMain") + } + } + val commonTest by getting { dependencies { implementation(kotlin("reflect")) implementation(kotlin("test")) - implementation(projects.runtime) } - if (!debugProcessor) { + if (!disableForSharedCode) { kotlin.srcDir("$rootDir/processing-tests/common/src/commonTest") + kotlin.srcDir("$rootDir/processing-tests/ksp-common-tests/src/commonTest") + } + } + + val jvmMain by getting { + dependencies { + project.dependencies.add("kspJvm", projects.ksp) + } + if (!disableForSharedCode) { + kotlin.srcDir("$rootDir/processing-tests/common/src/jvmMain") } } @@ -32,17 +51,21 @@ kotlin { implementation(libs.ksp.runtime) implementation(libs.ksp.api) implementation(projects.ksp) - configurations["kspJvmTest"].dependencies.add(projects.ksp) } - if (!debugProcessor) { + if (!disableForSharedCode) { kotlin.srcDir("$rootDir/processing-tests/common/src/jvmTest") } } } } -if (!debugProcessor) { +if (!disableForSharedCode) { sourceSets { + main { + java { + srcDir("$rootDir/processing-tests/common/src/jvmMain/java") + } + } test { java { srcDir("$rootDir/processing-tests/common/src/jvmTest/java") @@ -53,9 +76,14 @@ if (!debugProcessor) { detekt { source = files( + "src/commonMain/kotlin", + "src/commonTest/kotlin", "src/jvmMain/kotlin", "src/jvmTest/kotlin", + "$rootDir/processing-tests/common/src/commonMain/kotlin", "$rootDir/processing-tests/common/src/commonTest/kotlin", + "$rootDir/processing-tests/common/src/jvmMain/java", + "$rootDir/processing-tests/common/src/jvmMain/kotlin", "$rootDir/processing-tests/common/src/jvmTest/java", "$rootDir/processing-tests/common/src/jvmTest/kotlin" ) diff --git a/processing-tests/ksp-tests/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameCompilationTests.kt b/processing-tests/ksp-java-tests/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameCompilationTests.kt similarity index 94% rename from processing-tests/ksp-tests/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameCompilationTests.kt rename to processing-tests/ksp-java-tests/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameCompilationTests.kt index c2279925..f6aecb25 100644 --- a/processing-tests/ksp-tests/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameCompilationTests.kt +++ b/processing-tests/ksp-java-tests/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/ksp/NestedObjectsWithSameNameCompilationTests.kt @@ -17,7 +17,7 @@ class NestedObjectsWithSameNameCompilationTests { fun `compilation generates correct code`() { val result = compile( getSourceFile( - SharableProcessingSourceType.UNIQUE, + SharableProcessingSourceType.KSP_COMMON, PlatformSourceType.COMMON, "compilation", "ksp", diff --git a/processing-tests/ksp-tests/src/jvmTest/kotlin/com/livefront/sealedenum/testing/Compilation.kt b/processing-tests/ksp-java-tests/src/jvmTest/kotlin/com/livefront/sealedenum/testing/Compilation.kt similarity index 100% rename from processing-tests/ksp-tests/src/jvmTest/kotlin/com/livefront/sealedenum/testing/Compilation.kt rename to processing-tests/ksp-java-tests/src/jvmTest/kotlin/com/livefront/sealedenum/testing/Compilation.kt diff --git a/processing-tests/processor-tests/README.md b/processing-tests/processor-tests/README.md new file mode 100644 index 00000000..81b0cb49 --- /dev/null +++ b/processing-tests/processor-tests/README.md @@ -0,0 +1,5 @@ +# processor-tests + +Tests that verify the KAPT processor's functionality. + +This module uses shared `commonMain`, `jvmMain`, `commonTest` and `jvmTest` code from [common/src](../common/src) diff --git a/processing-tests/processor-tests/build.gradle.kts b/processing-tests/processor-tests/build.gradle.kts index 6271a7f5..3a0dfde8 100644 --- a/processing-tests/processor-tests/build.gradle.kts +++ b/processing-tests/processor-tests/build.gradle.kts @@ -5,43 +5,64 @@ plugins { } /** - * Swap to `true` to allow debugging `ksp-tests` + * Swap to `true` to allow debugging other tests that share code */ -val debugKsp = false +val disableForSharedCode = false kotlin { jvm() sourceSets { + val commonMain by getting { + dependencies { + implementation(projects.runtime) + } + if (!disableForSharedCode) { + kotlin.srcDir("$rootDir/processing-tests/common/src/commonMain") + } + } + val commonTest by getting { dependencies { implementation(kotlin("reflect")) implementation(kotlin("test")) - implementation(projects.runtime) } - if (!debugKsp) { + if (!disableForSharedCode) { kotlin.srcDir("$rootDir/processing-tests/common/src/commonTest") } } + val jvmMain by getting { + configurations["kapt"].dependencies.add(projects.processor) + if (!disableForSharedCode) { + kotlin.srcDir("$rootDir/processing-tests/common/src/jvmMain") + } + } + val jvmTest by getting { dependencies { implementation(libs.junit.jupiter) implementation(libs.kotlinCompileTesting.base) implementation(projects.processor) - configurations["kaptTest"].dependencies.add(projects.processor) } - if (!debugKsp) { - // Add the processing common commonTest directly to jvmTest, to allow kapt to pick up and process - // annotations + if (!disableForSharedCode) { kotlin.srcDir("$rootDir/processing-tests/common/src/jvmTest") } } } } -if (!debugKsp) { +kapt { + includeCompileClasspath = false +} + +if (!disableForSharedCode) { sourceSets { + main { + java { + srcDir("$rootDir/processing-tests/common/src/jvmMain/java") + } + } test { java { srcDir("$rootDir/processing-tests/common/src/jvmTest/java") @@ -52,9 +73,14 @@ if (!debugKsp) { detekt { source = files( + "src/commonMain/kotlin", + "src/commonTest/kotlin", "src/jvmMain/kotlin", "src/jvmTest/kotlin", + "$rootDir/processing-tests/common/src/commonMain/kotlin", "$rootDir/processing-tests/common/src/commonTest/kotlin", + "$rootDir/processing-tests/common/src/jvmMain/java", + "$rootDir/processing-tests/common/src/jvmMain/kotlin", "$rootDir/processing-tests/common/src/jvmTest/java", "$rootDir/processing-tests/common/src/jvmTest/kotlin" ) diff --git a/processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaFirstBaseClass.java b/processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaFirstBaseClass.java similarity index 100% rename from processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaFirstBaseClass.java rename to processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaFirstBaseClass.java diff --git a/processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface1.java b/processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface1.java similarity index 100% rename from processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface1.java rename to processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface1.java diff --git a/processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface2.java b/processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface2.java similarity index 100% rename from processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface2.java rename to processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface2.java diff --git a/processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface3.java b/processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface3.java similarity index 100% rename from processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface3.java rename to processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface3.java diff --git a/processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface4.java b/processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface4.java similarity index 100% rename from processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface4.java rename to processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface4.java diff --git a/processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface5.java b/processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface5.java similarity index 76% rename from processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface5.java rename to processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface5.java index c9899dd8..82e23563 100644 --- a/processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface5.java +++ b/processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaInterface5.java @@ -1,6 +1,4 @@ package com.livefront.sealedenum.compilation.kitchensink; -import java.util.Collection; - public interface JavaInterface5 { } diff --git a/processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaSecondBaseClass.java b/processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaSecondBaseClass.java similarity index 100% rename from processing-tests/processor-tests/src/jvmTest/java/com/livefront/sealedenum/compilation/kitchensink/JavaSecondBaseClass.java rename to processing-tests/processor-tests/src/jvmMain/java/com/livefront/sealedenum/compilation/kitchensink/JavaSecondBaseClass.java diff --git a/processing-tests/processor-tests/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/kitchensink/JavaBaseClasses.kt b/processing-tests/processor-tests/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/kitchensink/JavaBaseClasses.kt similarity index 90% rename from processing-tests/processor-tests/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/kitchensink/JavaBaseClasses.kt rename to processing-tests/processor-tests/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/kitchensink/JavaBaseClasses.kt index f1b9925d..27ec06e9 100644 --- a/processing-tests/processor-tests/src/jvmTest/kotlin/com/livefront/sealedenum/compilation/kitchensink/JavaBaseClasses.kt +++ b/processing-tests/processor-tests/src/jvmMain/kotlin/com/livefront/sealedenum/compilation/kitchensink/JavaBaseClasses.kt @@ -3,11 +3,11 @@ package com.livefront.sealedenum.compilation.kitchensink import com.livefront.sealedenum.GenSealedEnum import org.intellij.lang.annotations.Language -interface KotlinInterface1 +public interface KotlinInterface1 -interface KotlinInterface2 +public interface KotlinInterface2 -interface KotlinInterface3 +public interface KotlinInterface3 internal interface KotlinInterface4 @@ -15,31 +15,32 @@ internal interface KotlinInterface5 internal interface KotlinInterface6 -interface KotlinInterface7 +public interface KotlinInterface7 -open class KotlinFirstBaseClass> : +public open class KotlinFirstBaseClass> : KotlinInterface1, KotlinInterface3, JavaInterface4 -open class KotlinSecondBaseClass, D> : +public open class KotlinSecondBaseClass, D> : JavaFirstBaseClass(), KotlinInterface4, KotlinInterface6, JavaInterface2, JavaInterface5>>> -sealed class JavaBaseClassesSealedClass> : +public sealed class JavaBaseClassesSealedClass> : JavaSecondBaseClass>(), KotlinInterface7 { - object FirstObject : JavaBaseClassesSealedClass>() + public object FirstObject : JavaBaseClassesSealedClass>() - object SecondObject : JavaBaseClassesSealedClass>() + public object SecondObject : JavaBaseClassesSealedClass>() @GenSealedEnum(generateEnum = true) - companion object + public companion object } +@Suppress("MaxLineLength") @Language("kotlin") -val javaBaseClassesSealedClassGenerated = """ +public val javaBaseClassesSealedClassGenerated: String = """ package com.livefront.sealedenum.compilation.kitchensink import com.livefront.sealedenum.EnumForSealedEnumProvider diff --git a/processing-tests/processor-tests/src/jvmTest/kotlin/com/livefront/sealedenum/testing/Compilation.kt b/processing-tests/processor-tests/src/jvmTest/kotlin/com/livefront/sealedenum/testing/Compilation.kt index 8460cb08..f19bc820 100644 --- a/processing-tests/processor-tests/src/jvmTest/kotlin/com/livefront/sealedenum/testing/Compilation.kt +++ b/processing-tests/processor-tests/src/jvmTest/kotlin/com/livefront/sealedenum/testing/Compilation.kt @@ -12,5 +12,4 @@ internal fun compile(vararg sourceFiles: SourceFile): KotlinCompilation.Result = sources = sourceFiles.toList() annotationProcessors = listOf(SealedEnumProcessor()) inheritClassPath = true - kotlincArguments = listOf("-language-version", "1.5") }.compile() diff --git a/settings.gradle.kts b/settings.gradle.kts index 51a59b66..86f3919e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,5 +19,6 @@ include(":processing-common") include(":processor") include(":ksp") include(":processing-tests:processor-tests") -include(":processing-tests:ksp-tests") +include(":processing-tests:ksp-common-tests") +include(":processing-tests:ksp-java-tests") rootProject.name = "sealed-enum"