Skip to content

Commit

Permalink
Fix some formatting and build issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
TadeasKriz committed Jan 17, 2025
1 parent f900ac6 commit 8301134
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 2 additions & 0 deletions example-skie-subplugin-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ plugins {
}

kotlin {
jvmToolchain(11)

androidTarget()
iosX64()
iosArm64()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import co.touchlab.skie.phases.InitPhase
import co.touchlab.skie.phases.swift.ConvertSirIrFilesToSourceFilesPhase
import co.touchlab.skie.spi.SkiePluginRegistrar

class ExampleSkieSubplugin: SkiePluginRegistrar {
class ExampleSkieSubplugin : SkiePluginRegistrar {
override val customConfigurationKeys: Set<ConfigurationKey<*>> = setOf(
IdentifiableConfigurationKey,
IdentifiableConfigurationKey
)

override fun register(initPhaseContext: InitPhase.Context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import co.touchlab.skie.sir.element.SirExtension
import co.touchlab.skie.sir.element.SirGetter
import co.touchlab.skie.sir.element.SirProperty

object GenerateIdentifiableConformancesPhase: SirPhase {
object GenerateIdentifiableConformancesPhase : SirPhase {
context(SirPhase.Context)
override suspend fun execute() {
val identifiableProtocol = SirClass(
Expand All @@ -18,11 +18,15 @@ object GenerateIdentifiableConformancesPhase: SirPhase {
)

kirProvider.kotlinClasses.forEach { kirClass ->
val identifiableConfig = kirClass.configuration[IdentifiableConfigurationKey] ?: return@forEach
val identifiableConfig = kirClass.configuration[IdentifiableConfigurationKey]
?: return@forEach
val identityProperty = identifiableConfig.propertyName?.let { propertyName ->
kirClass.callableDeclarations
.filterIsInstance<KirProperty>()
.singleOrNull { it.kotlinName == propertyName } ?: error("Property $propertyName not found in class ${kirClass.kotlinFqName}!")
.singleOrNull {
it.kotlinName == propertyName
}
?: error("Property $propertyName not found in class ${kirClass.kotlinFqName}!")
}
val sirClass = kirClass.primarySirClass
val sirIdentityProperty = identityProperty?.primarySirProperty
Expand All @@ -31,13 +35,13 @@ object GenerateIdentifiableConformancesPhase: SirPhase {
SirExtension(
classDeclaration = sirClass,
superTypes = listOf(
identifiableProtocol.defaultType,
),
identifiableProtocol.defaultType
)
).apply {
if (sirIdentityProperty != null) {
SirProperty(
identifier = "id",
type = sirIdentityProperty.type,
type = sirIdentityProperty.type
).apply {
SirGetter().apply {
bodyBuilder.add {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package co.touchlab.example

data class IdentifiableConfig(
val propertyName: String?,
val propertyName: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import co.touchlab.skie.configuration.ConfigurationScope
import co.touchlab.skie.configuration.ConfigurationTarget
import co.touchlab.skie.configuration.findAnnotation

object IdentifiableConfigurationKey: ConfigurationKey<IdentifiableConfig?>, ConfigurationScope.Class {
object IdentifiableConfigurationKey :
ConfigurationKey<IdentifiableConfig?>, ConfigurationScope.Class {
override fun deserialize(value: String?): IdentifiableConfig? {
return when (value) {
null -> null
Expand Down

0 comments on commit 8301134

Please sign in to comment.