Skip to content

Commit

Permalink
extractModules refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
d10xa committed Mar 21, 2021
1 parent 6f8a5c5 commit 4e98016
Showing 1 changed file with 12 additions and 19 deletions.
Expand Up @@ -117,27 +117,20 @@ object SbtArtifactsParser {
.sumCounter
.map(appendTree)

def extractModules(items: Vector[SbtTree]): WithCounter[Vector[SbtTree]] = {
val res = items.map {
case Scope(Some(innerName), innerItems) =>
val (modules, others) = innerItems.partition(_.isInstanceOf[Module])
(
modules.foldLeft(0, Vector.empty[Module])((acc, module) =>
module match {
case m: Module =>
(acc._1 + 1, acc._2 :+ m)
}
),
Scope(Some(innerName), others)
)
case x => ((0, Vector.empty[Module]), x)
}
res
.foldLeft(0, Vector.empty[(Vector[Module], SbtTree)]) { (acc, cur) =>
(acc._1 + cur._1._1, acc._2 :+ (cur._1._2, cur._2))
def extractModules(items: Vector[SbtTree]): WithCounter[Vector[SbtTree]] =
items
.map {
case Scope(Some(innerName), innerItems) =>
val (modules, others) = innerItems.partition(_.isInstanceOf[Module])
val extractedModules = modules.collect { case m: Module => m }
(
extractedModules.size,
(extractedModules, Scope(Some(innerName), others))
)
case x => (0, (Vector.empty[Module], x))
}
.sumCounter
.map(appendTree)
}

def substituteNearModuleWithLocalValue(
items: Vector[SbtTree]
Expand Down

0 comments on commit 4e98016

Please sign in to comment.