Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename @ComposeDestination annotation #545

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,11 @@ 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