diff --git a/komposable-architecture-compiler/src/main/kotlin/processors/ActionMappingSymbolProcessor.kt b/komposable-architecture-compiler/src/main/kotlin/processors/ActionMappingSymbolProcessor.kt index 44ed3db..a9a459f 100644 --- a/komposable-architecture-compiler/src/main/kotlin/processors/ActionMappingSymbolProcessor.kt +++ b/komposable-architecture-compiler/src/main/kotlin/processors/ActionMappingSymbolProcessor.kt @@ -73,11 +73,14 @@ class ActionMappingSymbolProcessor( } } - private fun KSClassDeclaration.actionMappingFileBuilder() = - FileSpec.builder( - packageName = packageName.getQualifier(), - fileName = "${toClassName().simpleName}ActionMappings", + private fun KSClassDeclaration.actionMappingFileBuilder(): FileSpec.Builder { + val className = toClassName() + + return FileSpec.builder( + packageName = className.packageName, + fileName = "${className.simpleName}ActionMappings", ) + } } class ActionMappingSymbolProcessorProvider : SymbolProcessorProvider { diff --git a/komposable-architecture-compiler/src/test/kotlin/ActionMappingSymbolProcessorTests.kt b/komposable-architecture-compiler/src/test/kotlin/ActionMappingSymbolProcessorTests.kt index efae1ad..49e543d 100644 --- a/komposable-architecture-compiler/src/test/kotlin/ActionMappingSymbolProcessorTests.kt +++ b/komposable-architecture-compiler/src/test/kotlin/ActionMappingSymbolProcessorTests.kt @@ -23,7 +23,7 @@ class ActionMappingSymbolProcessorTests { val sources = result.kspGeneratedSources() sources.size.shouldBe(1) - sources.single().readText().contentEquals(SourceFiles.generatedSettingsFile) + sources.single().readText().shouldBe(SourceFiles.generatedActionExtensionsFile) } @Test @@ -44,7 +44,7 @@ class ActionMappingSymbolProcessorTests { val sources = result.kspGeneratedSources() sources.size.shouldBe(1) - sources.single().readText().contentEquals(SourceFiles.generatedSettingsFileWithoutPackage) + sources.single().readText().shouldBe(SourceFiles.generatedActionExtensionsFileWithoutPackage) } @Test diff --git a/komposable-architecture-compiler/src/test/kotlin/SourceFiles.kt b/komposable-architecture-compiler/src/test/kotlin/SourceFiles.kt index 3b3da9d..348ac9f 100644 --- a/komposable-architecture-compiler/src/test/kotlin/SourceFiles.kt +++ b/komposable-architecture-compiler/src/test/kotlin/SourceFiles.kt @@ -6,7 +6,7 @@ object SourceFiles { val settingsAction = SourceFile.kotlin( "SettingsAction.kt", """ - package com.toggl.komposable.compiler.testing + package com.toggl.komposable.compiler sealed interface SettingsAction { data class ChangeSomeSetting(val newValue: Boolean) : SettingsAction @@ -26,7 +26,7 @@ object SourceFiles { val appAction = SourceFile.kotlin( "AppAction.kt", """ - package com.toggl.komposable.compiler.testing + package com.toggl.komposable.compiler import com.toggl.komposable.architecture.WrapperAction @@ -56,7 +56,7 @@ object SourceFiles { val appActionWithMultipleProperties = SourceFile.kotlin( "AppAction.kt", """ - package com.toggl.komposable.compiler.testing + package com.toggl.komposable.compiler import com.toggl.komposable.architecture.WrapperAction @@ -70,25 +70,24 @@ object SourceFiles { ) @Language("kotlin") - val generatedSettingsFile = """ - package com.toggl.komposable.compiler.testing - - import AppAction.Settings - - public fun mapAppActionToSettingsAction(appAction: AppAction): SettingsAction? = if(appAction is - AppAction.Settings) appAction.settingsAction else null - - public fun mapSettingsActionToAppAction(settingsAction: SettingsAction): AppAction.Settings = - AppAction.Settings(settingsAction) - """.trimIndent() + val generatedActionExtensionsFile = """package com.toggl.komposable.compiler + +import com.toggl.komposable.compiler.AppAction.Settings + +public fun mapAppActionToSettingsAction(appAction: AppAction): SettingsAction? = if(appAction is + AppAction.Settings) appAction.settingsAction else null + +public fun mapSettingsActionToAppAction(settingsAction: SettingsAction): AppAction.Settings = + AppAction.Settings(settingsAction) +""" @Language("kotlin") - val generatedSettingsFileWithoutPackage = """import AppAction.Settings + val generatedActionExtensionsFileWithoutPackage = """import AppAction.Settings public fun mapAppActionToSettingsAction(appAction: AppAction): SettingsAction? = if(appAction is AppAction.Settings) appAction.settingsAction else null public fun mapSettingsActionToAppAction(settingsAction: SettingsAction): AppAction.Settings = AppAction.Settings(settingsAction) - """.trimIndent() +""" }