Skip to content

Commit

Permalink
Fixed condition to not generate graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
raamcosta committed Mar 13, 2024
1 parent 2d2e7eb commit 0026b0d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class ModuleOutputWriter(
navGraphs: List<RawNavGraphGenParams>,
destinations: List<CodeGenProcessedDestination>
) {
val navGraphTrees = if (codeGenConfig.generateNavGraphs && destinations.any { it.navGraphInfo != null }) {
val navGraphTrees = if (codeGenConfig.generateNavGraphs && navGraphsHaveRoutes(navGraphs, destinations)) {
val graphTrees = makeNavGraphTrees(navGraphs, destinations)
navGraphsSingleObjectWriter.write(graphTrees, destinations)
mermaidGraphWriter.write(submodules, graphTrees)
Expand All @@ -43,6 +43,17 @@ internal class ModuleOutputWriter(
moduleRegistryWriter.write(destinations, navGraphTrees)
}

private fun navGraphsHaveRoutes(
navGraphs: List<RawNavGraphGenParams>,
destinations: List<CodeGenProcessedDestination>
): Boolean {
val anyDestinationHasNavGraph = destinations.any { it.navGraphInfo != null }
val anyNavGraphHasParent = navGraphs.any { it.parent != null }
val anyNavGraphHasExternalRoutes = navGraphs.any { it.externalRoutes.isNotEmpty() }

return anyDestinationHasNavGraph || anyNavGraphHasParent || anyNavGraphHasExternalRoutes
}

private fun List<RawNavGraphTree>.flatten(): List<RawNavGraphTree> {
return this + flatMap { it.nestedGraphs.flatten() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import kotlin.reflect.KClass
* to control parameters available with that annotation for that specific [DestinationSpec]
*/
@Repeatable
@Retention(AnnotationRetention.BINARY)
@Retention(AnnotationRetention.SOURCE)
annotation class ExternalModuleDestinations<T: ModuleDestinationsContainer>(
val overriding: Array<OverrideDestination<out DestinationSpec>> = []
)
Expand Down

0 comments on commit 0026b0d

Please sign in to comment.