diff --git a/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavDestinationCodegenTest.kt b/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavDestinationCodegenTest.kt index f7c083923..5f83ddeb2 100644 --- a/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavDestinationCodegenTest.kt +++ b/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavDestinationCodegenTest.kt @@ -131,8 +131,7 @@ internal class NavDestinationCodegenTest { @ContributesSubcomponent.Factory public interface Factory { - public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, - @BindsInstance testRoute: TestRoute): KhonshuTestComponent + public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, @BindsInstance testRoute: TestRoute): KhonshuTestComponent } @ContributesTo(TestParentRoute::class) @@ -148,8 +147,7 @@ internal class NavDestinationCodegenTest { entry: StackEntry, snapshot: StackSnapshot, provider: ActivityComponentProvider, - ): KhonshuTestComponent = componentFromParentRoute(entry, snapshot, provider, - TestParentRoute::class) { parentComponent: KhonshuTestComponent.ParentComponent -> + ): KhonshuTestComponent = componentFromParentRoute(entry, snapshot, provider, TestParentRoute::class) { parentComponent: KhonshuTestComponent.ParentComponent -> parentComponent.khonshuTestComponentFactory().create(entry.savedStateHandle, entry.route) } } @@ -200,8 +198,7 @@ internal class NavDestinationCodegenTest { @Provides @IntoSet @OptIn(InternalNavigationCodegenApi::class) - public fun provideNavDestination(): NavDestination = - ScreenDestination(KhonshuTestComponentProvider) { snapshot, route -> + public fun provideNavDestination(): NavDestination = ScreenDestination(KhonshuTestComponentProvider) { snapshot, route -> KhonshuTest(snapshot, route) } } @@ -305,8 +302,7 @@ internal class NavDestinationCodegenTest { @ContributesSubcomponent.Factory public interface Factory { - public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, - @BindsInstance testRoute: TestRoute): KhonshuTestComponent + public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, @BindsInstance testRoute: TestRoute): KhonshuTestComponent } @ContributesTo(ActivityScope::class) @@ -322,8 +318,7 @@ internal class NavDestinationCodegenTest { entry: StackEntry, snapshot: StackSnapshot, provider: ActivityComponentProvider, - ): KhonshuTestComponent = component(entry, provider, ActivityScope::class) { parentComponent: - KhonshuTestComponent.ParentComponent -> + ): KhonshuTestComponent = component(entry, provider, ActivityScope::class) { parentComponent: KhonshuTestComponent.ParentComponent -> parentComponent.khonshuTestComponentFactory().create(entry.savedStateHandle, entry.route) } } @@ -374,8 +369,7 @@ internal class NavDestinationCodegenTest { @Provides @IntoSet @OptIn(InternalNavigationCodegenApi::class) - public fun provideNavDestination(): NavDestination = - ScreenDestination(KhonshuTestComponentProvider) { snapshot, route -> + public fun provideNavDestination(): NavDestination = ScreenDestination(KhonshuTestComponentProvider) { snapshot, route -> KhonshuTest(snapshot, route) } } @@ -482,9 +476,7 @@ internal class NavDestinationCodegenTest { @ContributesSubcomponent.Factory public interface Factory { - public fun create(@BindsInstance @ForScope(TestOverlayRoute::class) - savedStateHandle: SavedStateHandle, @BindsInstance testOverlayRoute: TestOverlayRoute): - KhonshuTestComponent + public fun create(@BindsInstance @ForScope(TestOverlayRoute::class) savedStateHandle: SavedStateHandle, @BindsInstance testOverlayRoute: TestOverlayRoute): KhonshuTestComponent } @ContributesTo(TestParentRoute::class) @@ -494,15 +486,13 @@ internal class NavDestinationCodegenTest { } @OptIn(InternalCodegenApi::class) - public object KhonshuTestComponentProvider : - ComponentProvider { + public object KhonshuTestComponentProvider : ComponentProvider { @OptIn(InternalNavigationCodegenApi::class) override fun provide( entry: StackEntry, snapshot: StackSnapshot, provider: ActivityComponentProvider, - ): KhonshuTestComponent = componentFromParentRoute(entry, snapshot, provider, - TestParentRoute::class) { parentComponent: KhonshuTestComponent.ParentComponent -> + ): KhonshuTestComponent = componentFromParentRoute(entry, snapshot, provider, TestParentRoute::class) { parentComponent: KhonshuTestComponent.ParentComponent -> parentComponent.khonshuTestComponentFactory().create(entry.savedStateHandle, entry.route) } } @@ -553,8 +543,7 @@ internal class NavDestinationCodegenTest { @Provides @IntoSet @OptIn(InternalNavigationCodegenApi::class) - public fun provideNavDestination(): NavDestination = - OverlayDestination(KhonshuTestComponentProvider) { snapshot, route -> + public fun provideNavDestination(): NavDestination = OverlayDestination(KhonshuTestComponentProvider) { snapshot, route -> KhonshuTest(snapshot, route) } } @@ -691,8 +680,7 @@ internal class NavDestinationCodegenTest { @ContributesSubcomponent.Factory public interface Factory { - public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, - @BindsInstance testRoute: TestRoute): KhonshuTest2Component + public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, @BindsInstance testRoute: TestRoute): KhonshuTest2Component } @ContributesTo(TestParentRoute::class) @@ -708,8 +696,7 @@ internal class NavDestinationCodegenTest { entry: StackEntry, snapshot: StackSnapshot, provider: ActivityComponentProvider, - ): KhonshuTest2Component = componentFromParentRoute(entry, snapshot, provider, - TestParentRoute::class) { parentComponent: KhonshuTest2Component.ParentComponent -> + ): KhonshuTest2Component = componentFromParentRoute(entry, snapshot, provider, TestParentRoute::class) { parentComponent: KhonshuTest2Component.ParentComponent -> parentComponent.khonshuTest2ComponentFactory().create(entry.savedStateHandle, entry.route) } } @@ -768,8 +755,7 @@ internal class NavDestinationCodegenTest { @Provides @IntoSet @OptIn(InternalNavigationCodegenApi::class) - public fun provideNavDestination(): NavDestination = - ScreenDestination(KhonshuTest2ComponentProvider) { snapshot, route -> + public fun provideNavDestination(): NavDestination = ScreenDestination(KhonshuTest2ComponentProvider) { snapshot, route -> KhonshuTest2(snapshot, route) } } @@ -867,8 +853,7 @@ internal class NavDestinationCodegenTest { @ContributesSubcomponent.Factory public interface Factory { - public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, - @BindsInstance testRoute: TestRoute): KhonshuTestComponent + public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, @BindsInstance testRoute: TestRoute): KhonshuTestComponent } @ContributesTo(TestParentRoute::class) @@ -884,8 +869,7 @@ internal class NavDestinationCodegenTest { entry: StackEntry, snapshot: StackSnapshot, provider: ActivityComponentProvider, - ): KhonshuTestComponent = componentFromParentRoute(entry, snapshot, provider, - TestParentRoute::class) { parentComponent: KhonshuTestComponent.ParentComponent -> + ): KhonshuTestComponent = componentFromParentRoute(entry, snapshot, provider, TestParentRoute::class) { parentComponent: KhonshuTestComponent.ParentComponent -> parentComponent.khonshuTestComponentFactory().create(entry.savedStateHandle, entry.route) } } @@ -931,8 +915,7 @@ internal class NavDestinationCodegenTest { @Provides @IntoSet @OptIn(InternalNavigationCodegenApi::class) - public fun provideNavDestination(): NavDestination = - ScreenDestination(KhonshuTestComponentProvider) { snapshot, route -> + public fun provideNavDestination(): NavDestination = ScreenDestination(KhonshuTestComponentProvider) { snapshot, route -> KhonshuTest(snapshot, route) } } @@ -1033,8 +1016,7 @@ internal class NavDestinationCodegenTest { @ContributesSubcomponent.Factory public interface Factory { - public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, - @BindsInstance testRoute: TestRoute): KhonshuTestComponent + public fun create(@BindsInstance @ForScope(TestRoute::class) savedStateHandle: SavedStateHandle, @BindsInstance testRoute: TestRoute): KhonshuTestComponent } @ContributesTo(TestParentRoute::class) @@ -1050,8 +1032,7 @@ internal class NavDestinationCodegenTest { entry: StackEntry, snapshot: StackSnapshot, provider: ActivityComponentProvider, - ): KhonshuTestComponent = componentFromParentRoute(entry, snapshot, provider, - TestParentRoute::class) { parentComponent: KhonshuTestComponent.ParentComponent -> + ): KhonshuTestComponent = componentFromParentRoute(entry, snapshot, provider, TestParentRoute::class) { parentComponent: KhonshuTestComponent.ParentComponent -> parentComponent.khonshuTestComponentFactory().create(entry.savedStateHandle, entry.route) } } @@ -1101,8 +1082,7 @@ internal class NavDestinationCodegenTest { @Provides @IntoSet @OptIn(InternalNavigationCodegenApi::class) - public fun provideNavDestination(): NavDestination = - ScreenDestination(KhonshuTestComponentProvider) { snapshot, route -> + public fun provideNavDestination(): NavDestination = ScreenDestination(KhonshuTestComponentProvider) { snapshot, route -> KhonshuTest(snapshot, route) } } diff --git a/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavHostActivityCodegenTest.kt b/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavHostActivityCodegenTest.kt index 52d2990ba..f0b392723 100644 --- a/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavHostActivityCodegenTest.kt +++ b/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavHostActivityCodegenTest.kt @@ -157,13 +157,9 @@ internal class NavHostActivityCodegenTest { public class KhonshuTestComponentProvider( private final val activity: ComponentActivity, ) : ActivityComponentProvider { - override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, - TestParentScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, - savedStateHandle -> - val viewModel = ViewModelProvider(activity, - SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] - parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, - activity.intent) + override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, TestParentScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, savedStateHandle -> + val viewModel = ViewModelProvider(activity, SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] + parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, activity.intent) } } @@ -179,8 +175,7 @@ internal class NavHostActivityCodegenTest { @ContributesTo(TestScreen::class) public object KhonshuTestActivityModule { @Provides - public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards - Set): ImmutableSet = destinations.toImmutableSet() + public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards Set): ImmutableSet = destinations.toImmutableSet() @Provides @SingleIn(TestScreen::class) @@ -363,12 +358,9 @@ internal class NavHostActivityCodegenTest { public class KhonshuTestComponentProvider( private final val activity: ComponentActivity, ) : ActivityComponentProvider { - override fun provide(scope: KClass<*>): C = component(activity, scope, ActivityScope::class, - AppScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, savedStateHandle -> - val viewModel = ViewModelProvider(activity, - SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] - parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, - activity.intent) + override fun provide(scope: KClass<*>): C = component(activity, scope, ActivityScope::class, AppScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, savedStateHandle -> + val viewModel = ViewModelProvider(activity, SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] + parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, activity.intent) } } @@ -384,8 +376,7 @@ internal class NavHostActivityCodegenTest { @ContributesTo(ActivityScope::class) public object KhonshuTestActivityModule { @Provides - public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards - Set): ImmutableSet = destinations.toImmutableSet() + public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards Set): ImmutableSet = destinations.toImmutableSet() @Provides @SingleIn(ActivityScope::class) @@ -603,13 +594,9 @@ internal class NavHostActivityCodegenTest { public class KhonshuTest2ComponentProvider( private final val activity: ComponentActivity, ) : ActivityComponentProvider { - override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, - TestParentScope::class) { parentComponent: KhonshuTest2Component.ParentComponent, - savedStateHandle -> - val viewModel = ViewModelProvider(activity, - SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] - parentComponent.khonshuTest2ComponentFactory().create(viewModel, savedStateHandle, - activity.intent) + override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, TestParentScope::class) { parentComponent: KhonshuTest2Component.ParentComponent, savedStateHandle -> + val viewModel = ViewModelProvider(activity, SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] + parentComponent.khonshuTest2ComponentFactory().create(viewModel, savedStateHandle, activity.intent) } } @@ -625,8 +612,7 @@ internal class NavHostActivityCodegenTest { @ContributesTo(TestScreen::class) public object KhonshuTest2ActivityModule { @Provides - public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards - Set): ImmutableSet = destinations.toImmutableSet() + public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards Set): ImmutableSet = destinations.toImmutableSet() @Provides @SingleIn(TestScreen::class) @@ -813,13 +799,9 @@ internal class NavHostActivityCodegenTest { public class KhonshuTestComponentProvider( private final val activity: ComponentActivity, ) : ActivityComponentProvider { - override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, - TestParentScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, - savedStateHandle -> - val viewModel = ViewModelProvider(activity, - SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] - parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, - activity.intent) + override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, TestParentScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, savedStateHandle -> + val viewModel = ViewModelProvider(activity, SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] + parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, activity.intent) } } @@ -835,8 +817,7 @@ internal class NavHostActivityCodegenTest { @ContributesTo(TestScreen::class) public object KhonshuTestActivityModule { @Provides - public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards - Set): ImmutableSet = destinations.toImmutableSet() + public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards Set): ImmutableSet = destinations.toImmutableSet() @Provides @SingleIn(TestScreen::class) @@ -1013,13 +994,9 @@ internal class NavHostActivityCodegenTest { public class KhonshuTestComponentProvider( private final val activity: ComponentActivity, ) : ActivityComponentProvider { - override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, - TestParentScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, - savedStateHandle -> - val viewModel = ViewModelProvider(activity, - SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] - parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, - activity.intent) + override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, TestParentScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, savedStateHandle -> + val viewModel = ViewModelProvider(activity, SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] + parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, activity.intent) } } @@ -1035,8 +1012,7 @@ internal class NavHostActivityCodegenTest { @ContributesTo(TestScreen::class) public object KhonshuTestActivityModule { @Provides - public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards - Set): ImmutableSet = destinations.toImmutableSet() + public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards Set): ImmutableSet = destinations.toImmutableSet() @Provides @SingleIn(TestScreen::class) @@ -1218,13 +1194,9 @@ internal class NavHostActivityCodegenTest { public class KhonshuTestComponentProvider( private final val activity: ComponentActivity, ) : ActivityComponentProvider { - override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, - TestParentScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, - savedStateHandle -> - val viewModel = ViewModelProvider(activity, - SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] - parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, - activity.intent) + override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, TestParentScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, savedStateHandle -> + val viewModel = ViewModelProvider(activity, SavedStateViewModelFactory())[StackEntryStoreViewModel::class.java] + parentComponent.khonshuTestComponentFactory().create(viewModel, savedStateHandle, activity.intent) } } @@ -1240,8 +1212,7 @@ internal class NavHostActivityCodegenTest { @ContributesTo(TestScreen::class) public object KhonshuTestActivityModule { @Provides - public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards - Set): ImmutableSet = destinations.toImmutableSet() + public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards Set): ImmutableSet = destinations.toImmutableSet() @Provides @SingleIn(TestScreen::class) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 85ade9458..e333bc675 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -25,7 +25,7 @@ uri = "0.0.18" inject = "1" anvil = "0.4.0" ksp = "2.0.21-1.0.26" -kotlinpoet = "1.18.1" +kotlinpoet = "2.0.0" auto-service = "1.1.1" auto-service-ksp = "1.2.0"