Skip to content

Commit

Permalink
rename @ComposeDestination annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielittner committed Sep 25, 2023
1 parent 21daa9d commit b151c1d
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ internal class FileGeneratorTestCompose {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.compose.ComposeDestination
import com.freeletics.khonshu.codegen.compose.NavDestination
import com.freeletics.khonshu.codegen.compose.DestinationType
import com.test.destination.TestDestinationScope
import com.test.parent.TestParentRoute
@ComposeDestination(
@NavDestination(
route = TestRoute::class,
parentScope = TestParentRoute::class,
stateMachine = TestStateMachine::class,
Expand Down Expand Up @@ -229,10 +229,10 @@ internal class FileGeneratorTestCompose {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.compose.ComposeDestination
import com.freeletics.khonshu.codegen.compose.NavDestination
import com.freeletics.khonshu.codegen.compose.DestinationType
@ComposeDestination(
@NavDestination(
route = TestRoute::class,
stateMachine = TestStateMachine::class,
destinationType = DestinationType.SCREEN,
Expand Down Expand Up @@ -413,13 +413,13 @@ internal class FileGeneratorTestCompose {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.compose.ComposeDestination
import com.freeletics.khonshu.codegen.compose.NavDestination
import com.freeletics.khonshu.codegen.compose.DestinationType
import com.test.destination.TestDestinationScope
import com.test.other.TestClass2
import com.test.parent.TestParentRoute
@ComposeDestination(
@NavDestination(
route = TestRoute::class,
parentScope = TestParentRoute::class,
stateMachine = TestStateMachine::class,
Expand Down Expand Up @@ -609,12 +609,12 @@ internal class FileGeneratorTestCompose {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.compose.ComposeDestination
import com.freeletics.khonshu.codegen.compose.NavDestination
import com.freeletics.khonshu.codegen.compose.DestinationType
import com.test.destination.TestDestinationScope
import com.test.parent.TestParentRoute
@ComposeDestination(
@NavDestination(
route = TestRoute::class,
parentScope = TestParentRoute::class,
stateMachine = TestStateMachine::class,
Expand Down Expand Up @@ -775,12 +775,12 @@ internal class FileGeneratorTestCompose {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.compose.ComposeDestination
import com.freeletics.khonshu.codegen.compose.NavDestination
import com.freeletics.khonshu.codegen.compose.DestinationType
import com.test.destination.TestDestinationScope
import com.test.parent.TestParentRoute
@ComposeDestination(
@NavDestination(
route = TestRoute::class,
parentScope = TestParentRoute::class,
stateMachine = TestStateMachine::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ internal class FileGeneratorTestComposeFragment {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.fragment.ComposeDestination
import com.freeletics.khonshu.codegen.fragment.ComposeFragmentDestination
import com.freeletics.khonshu.codegen.fragment.DestinationType
import com.test.destination.TestDestinationScope
import com.test.parent.TestParentRoute
@ComposeDestination(
@ComposeFragmentDestination(
route = TestRoute::class,
parentScope = TestParentRoute::class,
stateMachine = TestStateMachine::class,
Expand Down Expand Up @@ -251,10 +251,10 @@ internal class FileGeneratorTestComposeFragment {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.fragment.ComposeDestination
import com.freeletics.khonshu.codegen.fragment.ComposeFragmentDestination
import com.freeletics.khonshu.codegen.fragment.DestinationType
@ComposeDestination(
@ComposeFragmentDestination(
route = TestRoute::class,
stateMachine = TestStateMachine::class,
)
Expand Down Expand Up @@ -442,12 +442,12 @@ internal class FileGeneratorTestComposeFragment {
import androidx.compose.runtime.Composable
import androidx.fragment.app.DialogFragment
import com.freeletics.khonshu.codegen.fragment.ComposeDestination
import com.freeletics.khonshu.codegen.fragment.ComposeFragmentDestination
import com.freeletics.khonshu.codegen.fragment.DestinationType
import com.test.destination.TestDestinationScope
import com.test.parent.TestParentRoute
@ComposeDestination(
@ComposeFragmentDestination(
route = TestRoute::class,
parentScope = TestParentRoute::class,
stateMachine = TestStateMachine::class,
Expand Down Expand Up @@ -653,13 +653,13 @@ internal class FileGeneratorTestComposeFragment {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.fragment.ComposeDestination
import com.freeletics.khonshu.codegen.fragment.ComposeFragmentDestination
import com.freeletics.khonshu.codegen.fragment.DestinationType
import com.test.destination.TestDestinationScope
import com.test.other.TestClass2
import com.test.parent.TestParentRoute
@ComposeDestination(
@ComposeFragmentDestination(
route = TestRoute::class,
parentScope = TestParentRoute::class,
stateMachine = TestStateMachine::class,
Expand Down Expand Up @@ -870,12 +870,12 @@ internal class FileGeneratorTestComposeFragment {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.fragment.ComposeDestination
import com.freeletics.khonshu.codegen.fragment.ComposeFragmentDestination
import com.freeletics.khonshu.codegen.fragment.DestinationType
import com.test.destination.TestDestinationScope
import com.test.parent.TestParentRoute
@ComposeDestination(
@ComposeFragmentDestination(
route = TestRoute::class,
parentScope = TestParentRoute::class,
stateMachine = TestStateMachine::class,
Expand Down Expand Up @@ -1057,12 +1057,12 @@ internal class FileGeneratorTestComposeFragment {
package com.test
import androidx.compose.runtime.Composable
import com.freeletics.khonshu.codegen.fragment.ComposeDestination
import com.freeletics.khonshu.codegen.fragment.ComposeFragmentDestination
import com.freeletics.khonshu.codegen.fragment.DestinationType
import com.test.destination.TestDestinationScope
import com.test.parent.TestParentRoute
@ComposeDestination(
@ComposeFragmentDestination(
route = TestRoute::class,
parentScope = TestParentRoute::class,
stateMachine = TestStateMachine::class,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.freeletics.khonshu.codegen

import com.freeletics.khonshu.codegen.codegen.FileGenerator
import com.freeletics.khonshu.codegen.compose.ComposeDestination
import com.freeletics.khonshu.codegen.compose.NavDestination
import com.freeletics.khonshu.codegen.compose.NavHostActivity
import com.freeletics.khonshu.codegen.fragment.ComposeDestination as ComposeFragmentDestination
import com.freeletics.khonshu.codegen.fragment.ComposeFragmentDestination as ComposeFragmentDestination
import com.freeletics.khonshu.codegen.fragment.RendererDestination
import com.freeletics.khonshu.codegen.parser.ksp.toComposeFragmentDestinationData
import com.freeletics.khonshu.codegen.parser.ksp.toComposeScreenDestinationData
Expand Down Expand Up @@ -38,7 +38,7 @@ public class KhonshuSymbolProcessor(
private val fileGenerator = FileGenerator()

override fun process(resolver: Resolver): List<KSAnnotated> {
resolver.generateCodeForAnnotation<KSFunctionDeclaration, ComposeDestination> {
resolver.generateCodeForAnnotation<KSFunctionDeclaration, NavDestination> {
toComposeScreenDestinationData(it, resolver, logger)
}
resolver.generateCodeForAnnotation<KSClassDeclaration, RendererDestination> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import org.jetbrains.kotlin.name.FqName
// Codegen Public API
internal val rendererFragmentDestination = ClassName("com.freeletics.khonshu.codegen.fragment", "RendererDestination")
internal val rendererFragmentDestinationFqName = FqName(rendererFragmentDestination.canonicalName)
internal val composeFragmentDestination = ClassName("com.freeletics.khonshu.codegen.fragment", "ComposeDestination")
internal val composeFragmentDestination = ClassName("com.freeletics.khonshu.codegen.fragment", "ComposeFragmentDestination")
internal val composeFragmentDestinationFqName = FqName(composeFragmentDestination.canonicalName)
internal val codegenComposeDestination = ClassName("com.freeletics.khonshu.codegen.compose", "ComposeDestination")
internal val codegenComposeDestinationFqName = FqName(codegenComposeDestination.canonicalName)
internal val navDestination = ClassName("com.freeletics.khonshu.codegen.compose", "NavDestination")
internal val navDestinationFqName = FqName(navDestination.canonicalName)
internal val navHostActivity = ClassName("com.freeletics.khonshu.codegen.compose", "NavHostActivity")
internal val navHostActivityFqName = FqName(navHostActivity.canonicalName)
internal val appScope = ClassName("com.freeletics.khonshu.codegen", "AppScope")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package com.freeletics.khonshu.codegen.parser.anvil
import com.freeletics.khonshu.codegen.ComposeScreenData
import com.freeletics.khonshu.codegen.NavHostActivityData
import com.freeletics.khonshu.codegen.Navigation
import com.freeletics.khonshu.codegen.codegen.util.codegenComposeDestinationFqName
import com.freeletics.khonshu.codegen.codegen.util.navDestinationFqName
import com.freeletics.khonshu.codegen.codegen.util.navHostActivityFqName
import com.freeletics.khonshu.codegen.compose.DestinationType
import com.squareup.anvil.compiler.internal.reference.TopLevelFunctionReference
import com.squareup.anvil.compiler.internal.reference.asClassName

internal fun TopLevelFunctionReference.toComposeScreenDestinationData(): ComposeScreenData? {
val annotation = findAnnotation(codegenComposeDestinationFqName) ?: return null
val annotation = findAnnotation(navDestinationFqName) ?: return null

val stateMachine = annotation.stateMachineReference
val (stateParameter, actionParameter) = stateMachine.stateMachineParameters()
Expand Down
18 changes: 9 additions & 9 deletions codegen/api/android/codegen.api
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ public abstract interface class com/freeletics/khonshu/codegen/ActivityScope {
public abstract interface class com/freeletics/khonshu/codegen/AppScope {
}

public abstract interface annotation class com/freeletics/khonshu/codegen/compose/ComposeDestination : java/lang/annotation/Annotation {
public abstract fun destinationScope ()Ljava/lang/Class;
public abstract fun destinationType ()Lcom/freeletics/khonshu/codegen/compose/DestinationType;
public abstract fun parentScope ()Ljava/lang/Class;
public abstract fun route ()Ljava/lang/Class;
public abstract fun stateMachine ()Ljava/lang/Class;
}

public final class com/freeletics/khonshu/codegen/compose/DestinationType : java/lang/Enum {
public static final field OVERLAY Lcom/freeletics/khonshu/codegen/compose/DestinationType;
public static final field SCREEN Lcom/freeletics/khonshu/codegen/compose/DestinationType;
Expand All @@ -20,14 +12,22 @@ public final class com/freeletics/khonshu/codegen/compose/DestinationType : java
public static fun values ()[Lcom/freeletics/khonshu/codegen/compose/DestinationType;
}

public abstract interface annotation class com/freeletics/khonshu/codegen/compose/NavDestination : java/lang/annotation/Annotation {
public abstract fun destinationScope ()Ljava/lang/Class;
public abstract fun destinationType ()Lcom/freeletics/khonshu/codegen/compose/DestinationType;
public abstract fun parentScope ()Ljava/lang/Class;
public abstract fun route ()Ljava/lang/Class;
public abstract fun stateMachine ()Ljava/lang/Class;
}

public abstract interface annotation class com/freeletics/khonshu/codegen/compose/NavHostActivity : java/lang/annotation/Annotation {
public abstract fun activityBaseClass ()Ljava/lang/Class;
public abstract fun parentScope ()Ljava/lang/Class;
public abstract fun scope ()Ljava/lang/Class;
public abstract fun stateMachine ()Ljava/lang/Class;
}

public abstract interface annotation class com/freeletics/khonshu/codegen/fragment/ComposeDestination : java/lang/annotation/Annotation {
public abstract interface annotation class com/freeletics/khonshu/codegen/fragment/ComposeFragmentDestination : java/lang/annotation/Annotation {
public abstract fun destinationScope ()Ljava/lang/Class;
public abstract fun destinationType ()Lcom/freeletics/khonshu/codegen/fragment/DestinationType;
public abstract fun fragmentBaseClass ()Ljava/lang/Class;
Expand Down
18 changes: 9 additions & 9 deletions codegen/api/jvm/codegen.api
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ public abstract interface class com/freeletics/khonshu/codegen/ActivityScope {
public abstract interface class com/freeletics/khonshu/codegen/AppScope {
}

public abstract interface annotation class com/freeletics/khonshu/codegen/compose/ComposeDestination : java/lang/annotation/Annotation {
public abstract fun destinationScope ()Ljava/lang/Class;
public abstract fun destinationType ()Lcom/freeletics/khonshu/codegen/compose/DestinationType;
public abstract fun parentScope ()Ljava/lang/Class;
public abstract fun route ()Ljava/lang/Class;
public abstract fun stateMachine ()Ljava/lang/Class;
}

public final class com/freeletics/khonshu/codegen/compose/DestinationType : java/lang/Enum {
public static final field OVERLAY Lcom/freeletics/khonshu/codegen/compose/DestinationType;
public static final field SCREEN Lcom/freeletics/khonshu/codegen/compose/DestinationType;
Expand All @@ -20,14 +12,22 @@ public final class com/freeletics/khonshu/codegen/compose/DestinationType : java
public static fun values ()[Lcom/freeletics/khonshu/codegen/compose/DestinationType;
}

public abstract interface annotation class com/freeletics/khonshu/codegen/compose/NavDestination : java/lang/annotation/Annotation {
public abstract fun destinationScope ()Ljava/lang/Class;
public abstract fun destinationType ()Lcom/freeletics/khonshu/codegen/compose/DestinationType;
public abstract fun parentScope ()Ljava/lang/Class;
public abstract fun route ()Ljava/lang/Class;
public abstract fun stateMachine ()Ljava/lang/Class;
}

public abstract interface annotation class com/freeletics/khonshu/codegen/compose/NavHostActivity : java/lang/annotation/Annotation {
public abstract fun activityBaseClass ()Ljava/lang/Class;
public abstract fun parentScope ()Ljava/lang/Class;
public abstract fun scope ()Ljava/lang/Class;
public abstract fun stateMachine ()Ljava/lang/Class;
}

public abstract interface annotation class com/freeletics/khonshu/codegen/fragment/ComposeDestination : java/lang/annotation/Annotation {
public abstract interface annotation class com/freeletics/khonshu/codegen/fragment/ComposeFragmentDestination : java/lang/annotation/Annotation {
public abstract fun destinationScope ()Ljava/lang/Class;
public abstract fun destinationType ()Lcom/freeletics/khonshu/codegen/fragment/DestinationType;
public abstract fun fragmentBaseClass ()Ljava/lang/Class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import kotlin.reflect.KClass
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
public annotation class ComposeDestination(
public annotation class NavDestination(
val route: KClass<out BaseRoute>,
val parentScope: KClass<*> = AppScope::class,
val stateMachine: KClass<out StateMachine<*, *>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlin.reflect.KClass
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
public annotation class ComposeDestination(
public annotation class ComposeFragmentDestination(
val route: KClass<out BaseRoute>,
val parentScope: KClass<*> = AppScope::class,
val stateMachine: KClass<out StateMachine<*, *>>,
Expand Down

0 comments on commit b151c1d

Please sign in to comment.