Skip to content

Commit

Permalink
refactor(model): Extract a dependenciesAccessor() function for reuse
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Oct 2, 2024
1 parent 7b4177d commit c03ecf3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions model/src/main/kotlin/DependencyGraphNavigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,17 @@ class DependencyGraphNavigator(
"No DependencyGraph for package manager '$manager' available."
}

val rootDependencies = graph.scopes[DependencyGraph.qualifyScope(project, scopeName)].orEmpty().map { root ->
referenceFor(manager, root)
val rootIndices = graph.scopes[DependencyGraph.qualifyScope(project, scopeName)].orEmpty()
return dependenciesAccessor(manager, graph, rootIndices)
}

fun dependenciesAccessor(
manager: String,
graph: DependencyGraph,
rootIndices: List<RootDependencyIndex>
): Sequence<DependencyNode> {
val rootDependencies = rootIndices.map { rootIndex ->
referenceFor(manager, rootIndex)
}

return dependenciesSequence(graph, rootDependencies)
Expand Down

0 comments on commit c03ecf3

Please sign in to comment.