-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for kotlin-inject-anvil (#1635)
This introduces support for kotlin-inject + kotlin-inject-anvil. Note that kotlin-inject needs another release with evant/kotlin-inject#414 to work, so I'm game putting this in the release now but mentioning this caveat. Will remove the snapshots use and just disable the new sample project for now. kotlin-inject-anvil has support for options coming too, but in the meantime I think it's actually fine to check in an anvil hint property too as it doesn't require any runtime anvil APIs and can just be compileOnly. **TODO in the future** - [x] Need a new kotlin-inject release for evant/kotlin-inject#414 - [x] Need anvil support for annotation options: amzn/kotlin-inject-anvil#24 - [ ] Migrate STAR sample (can be a later PR if need be)
- Loading branch information
Showing
24 changed files
with
752 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...cuit/codegen/annotations/CircuitInject.kt → ...t/codegen/annotations/CircuitInject.js.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...n/com/slack/circuit/codegen/annotations/ComSlackCircuitCodegenAnnotationsCircuitInject.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (C) 2024 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
@file:Suppress("PackageDirectoryMismatch") | ||
|
||
package amazon.lastmile.inject | ||
|
||
import com.slack.circuit.codegen.annotations.CircuitInject | ||
import kotlin.reflect.KClass | ||
import software.amazon.lastmile.kotlin.inject.anvil.`internal`.Origin | ||
|
||
// TODO temporary until https://github.com/amzn/kotlin-inject-anvil/issues/24 | ||
@Origin(value = CircuitInject::class) | ||
internal val comSlackCircuitCodegenAnnotationsCircuitInject: KClass<CircuitInject> = | ||
CircuitInject::class |
20 changes: 20 additions & 0 deletions
20
...tions/src/nativeMain/kotlin/com/slack/circuit/codegen/annotations/CircuitInject.native.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2024 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.codegen.annotations | ||
|
||
import com.slack.circuit.runtime.screen.Screen | ||
import kotlin.reflect.KClass | ||
import software.amazon.lastmile.kotlin.inject.anvil.extend.ContributingAnnotation | ||
|
||
/** | ||
* Native-specific [CircuitInject]. | ||
* | ||
* For more general information about this annotation, see | ||
* [com.slack.circuit.codegen.annotations.CircuitInject] | ||
*/ | ||
@ContributingAnnotation | ||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) | ||
public actual annotation class CircuitInject( | ||
actual val screen: KClass<out Screen>, | ||
actual val scope: KClass<*>, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
circuit-codegen/src/main/kotlin/com/slack/circuit/codegen/CircuitNames.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (C) 2024 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.codegen | ||
|
||
import com.squareup.kotlinpoet.ClassName | ||
|
||
internal object CircuitNames { | ||
val ASSISTED = ClassName("dagger.assisted", "Assisted") | ||
val ASSISTED_FACTORY = ClassName("dagger.assisted", "AssistedFactory") | ||
val ASSISTED_INJECT = ClassName("dagger.assisted", "AssistedInject") | ||
val INJECT = ClassName("javax.inject", "Inject") | ||
val PROVIDER = ClassName("javax.inject", "Provider") | ||
const val CIRCUIT_RUNTIME_BASE_PACKAGE = "com.slack.circuit.runtime" | ||
const val DAGGER_PACKAGE = "dagger" | ||
const val DAGGER_HILT_PACKAGE = "$DAGGER_PACKAGE.hilt" | ||
const val DAGGER_HILT_CODEGEN_PACKAGE = "$DAGGER_HILT_PACKAGE.codegen" | ||
const val DAGGER_MULTIBINDINGS_PACKAGE = "$DAGGER_PACKAGE.multibindings" | ||
const val CIRCUIT_RUNTIME_UI_PACKAGE = "$CIRCUIT_RUNTIME_BASE_PACKAGE.ui" | ||
const val CIRCUIT_RUNTIME_SCREEN_PACKAGE = "$CIRCUIT_RUNTIME_BASE_PACKAGE.screen" | ||
const val CIRCUIT_RUNTIME_PRESENTER_PACKAGE = "$CIRCUIT_RUNTIME_BASE_PACKAGE.presenter" | ||
val MODIFIER = ClassName("androidx.compose.ui", "Modifier") | ||
val CIRCUIT_INJECT_ANNOTATION = | ||
ClassName("com.slack.circuit.codegen.annotations", "CircuitInject") | ||
val CIRCUIT_PRESENTER = ClassName(CIRCUIT_RUNTIME_PRESENTER_PACKAGE, "Presenter") | ||
val CIRCUIT_PRESENTER_FACTORY = CIRCUIT_PRESENTER.nestedClass("Factory") | ||
val CIRCUIT_UI = ClassName(CIRCUIT_RUNTIME_UI_PACKAGE, "Ui") | ||
val CIRCUIT_UI_FACTORY = CIRCUIT_UI.nestedClass("Factory") | ||
val CIRCUIT_UI_STATE = ClassName(CIRCUIT_RUNTIME_BASE_PACKAGE, "CircuitUiState") | ||
val SCREEN = ClassName(CIRCUIT_RUNTIME_SCREEN_PACKAGE, "Screen") | ||
val NAVIGATOR = ClassName(CIRCUIT_RUNTIME_BASE_PACKAGE, "Navigator") | ||
val CIRCUIT_CONTEXT = ClassName(CIRCUIT_RUNTIME_BASE_PACKAGE, "CircuitContext") | ||
val DAGGER_MODULE = ClassName(DAGGER_PACKAGE, "Module") | ||
val DAGGER_BINDS = ClassName(DAGGER_PACKAGE, "Binds") | ||
val DAGGER_INSTALL_IN = ClassName(DAGGER_HILT_PACKAGE, "InstallIn") | ||
val DAGGER_ORIGINATING_ELEMENT = ClassName(DAGGER_HILT_CODEGEN_PACKAGE, "OriginatingElement") | ||
val DAGGER_INTO_SET = ClassName(DAGGER_MULTIBINDINGS_PACKAGE, "IntoSet") | ||
const val MODULE = "Module" | ||
const val FACTORY = "Factory" | ||
const val CIRCUIT_CODEGEN_MODE = "circuit.codegen.mode" | ||
|
||
object KotlinInject { | ||
private const val ANNOTATIONS_PACKAGE = "me.tatarka.inject.annotations" | ||
val INJECT = ClassName(ANNOTATIONS_PACKAGE, "Inject") | ||
val ASSISTED = ClassName(ANNOTATIONS_PACKAGE, "Assisted") | ||
|
||
object Anvil { | ||
private const val RUNTIME_PACKAGE = "software.amazon.lastmile.kotlin.inject.anvil" | ||
internal val CONTRIBUTES_BINDING = ClassName(RUNTIME_PACKAGE, "ContributesBinding") | ||
} | ||
} | ||
} |
Oops, something went wrong.