Skip to content

Commit

Permalink
Fixes #631
Browse files Browse the repository at this point in the history
  • Loading branch information
raamcosta committed May 6, 2024
1 parent d28258d commit 4b1bb05
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ interface CodeOutputStreamMaker {
extensionName: String = "kt",
vararg sourceIds: String,
): OutputStream

val packageNamesWrittenTo: List<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ramcosta.composedestinations.codegen.model
data class SubModuleInfo(
val name: String?,
val genPackageName: String,
val hasNavArgsPackage: Boolean,
val topLevelGraphs: List<String>,
val publicResultSenders: List<DestinationResultSenderInfo>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ $VISIBILITY_PLACEHOLDER fun $ARGS_DATA_CLASS_SIMPLE_NAME.toSavedStateHandle(
}

// add nav args packages as imports so we can delegate start route args to submodules generated code
setOfImportable(*submodules.map { "${it.genPackageName}.navargs.*" }.toTypedArray()).forEach {
setOfImportable(
*submodules.mapNotNull { subModule ->
"${subModule.genPackageName}.navargs.*".takeIf { subModule.hasNavArgsPackage }
}.toTypedArray()
).forEach {
importableHelper.addPriorityQualifiedImport(it)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ internal class ModuleRegistryWriter(
annotation class _Info_$registryId(
val moduleName: String,
val packageName: String,
val hasNavArgsPackage: Boolean,
val typeResults: Array<_Destination_Result_Info_$registryId> = emptyArray(),
val topLevelGraphs: Array<String> = emptyArray()
)
Expand All @@ -66,6 +67,7 @@ internal class ModuleRegistryWriter(
@_Info_$registryId(
moduleName = "${codeGenConfig.moduleName ?: ""}",
packageName = "$codeGenBasePackageName",
hasNavArgsPackage = ${"$codeGenBasePackageName.navargs" in codeGenerator.packageNamesWrittenTo},
typeResults = [
%s1
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class KspCodeOutputStreamMaker(
private val sourceMapper: KSFileSourceMapper
) : CodeOutputStreamMaker {

override val packageNamesWrittenTo = mutableListOf<String>()

override fun makeFile(
name: String,
packageName: String,
Expand All @@ -28,11 +30,14 @@ class KspCodeOutputStreamMaker(
)
}

packageNamesWrittenTo.add(packageName)

return codeGenerator.createNewFile(
dependencies = dependencies,
fileName = name,
packageName = packageName,
extensionName = extensionName
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class Processor(
SubModuleInfo(
name = it.findArgumentValue<String>("moduleName"),
genPackageName = it.findArgumentValue<String>("packageName")!!,
hasNavArgsPackage = it.findArgumentValue<Boolean>("hasNavArgsPackage")!!,
topLevelGraphs = it.findArgumentValue<ArrayList<String>>("topLevelGraphs")!!,
publicResultSenders = it.findArgumentValue<ArrayList<KSAnnotation>>(
"typeResults"
Expand Down

0 comments on commit 4b1bb05

Please sign in to comment.