From f3d18f051f6d78ae7352af4581fb037a7954bb6a Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sat, 16 Apr 2011 20:05:15 -0400 Subject: [PATCH] delegates cleanup --- main/Scope.scala | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/main/Scope.scala b/main/Scope.scala index 2e5dc36ee..708d0d708 100644 --- a/main/Scope.scala +++ b/main/Scope.scala @@ -123,24 +123,26 @@ object Scope extraInherit: (ResolvedReference, AttributeMap) => Seq[AttributeMap])(rawScope: Scope): Seq[Scope] = { val scope = Scope.replaceThis(GlobalScope)(rawScope) + + def nonProjectScopes(resolvedProj: ResolvedReference)(px: ScopeAxis[ResolvedReference]) = + { + val p = px.toOption getOrElse resolvedProj + val cLin = linearize(scope.config)(configInherit(p, _)) + val tLin = linearize(scope.task)(taskInherit(p,_)) + val eLin = linearize(scope.extra)(extraInherit(p,_)) + for(c <- cLin; t <- tLin; e <- eLin) yield Scope(px, c, t, e) + } scope.project match { case Global => withGlobalScope(scope) case This => withGlobalScope(scope.copy(project = Global)) case Select(proj) => val resolvedProj = resolve(proj) - val prod = - for { - px <- withRawBuilds(linearize(scope.project map resolve, Nil)(projectInherit)).distinct - p = px.toOption getOrElse resolvedProj - c <- linearize(scope.config)(configInherit(p, _)) - t <- linearize(scope.task)(taskInherit(p,_)) - e <- linearize(scope.extra)(extraInherit(p,_)) - } yield - Scope(px,c,t,e) + val prod = withRawBuilds(linearize(scope.project map resolve, Nil)(projectInherit)) flatMap nonProjectScopes(resolvedProj) (prod :+ GlobalScope).distinct } } + def withGlobalScope(base: Scope): Seq[Scope] = if(base == GlobalScope) GlobalScope :: Nil else base :: GlobalScope :: Nil def withRawBuilds(ps: Seq[ScopeAxis[ResolvedReference]]): Seq[ScopeAxis[ResolvedReference]] = (ps ++ (ps flatMap rawBuilds).map(Select.apply) :+ Global).distinct