From c03ecf3333ea630156c6d18c2549d5b665ddd445 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 2 Oct 2024 14:13:42 +0200 Subject: [PATCH] refactor(model): Extract a `dependenciesAccessor()` function for reuse Signed-off-by: Sebastian Schuberth --- model/src/main/kotlin/DependencyGraphNavigator.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/model/src/main/kotlin/DependencyGraphNavigator.kt b/model/src/main/kotlin/DependencyGraphNavigator.kt index 42c09b4479cb8..69bd7156fd715 100644 --- a/model/src/main/kotlin/DependencyGraphNavigator.kt +++ b/model/src/main/kotlin/DependencyGraphNavigator.kt @@ -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 + ): Sequence { + val rootDependencies = rootIndices.map { rootIndex -> + referenceFor(manager, rootIndex) } return dependenciesSequence(graph, rootDependencies)