split load-time project structure scope resolution into two phases

first phase resolves referenced build URIs as each build is loaded
second phase resolves references without an explicit project ID
  (this requires the whole structure to be known and this isn't available during the first phase)
setting resolution is unchanged (done after both phases)
This commit is contained in:
Mark Harrah 2011-01-25 22:14:02 -05:00
parent ba9c2c0e14
commit d906455aed
1 changed files with 6 additions and 11 deletions

View File

@ -4,8 +4,6 @@
package sbt
import Types._
import annotation.tailrec
import collection.mutable
sealed trait Settings[Scope]
{
@ -98,9 +96,12 @@ trait Init[Scope]
def delegate(sMap: ScopedMap)(implicit delegates: Scope => Seq[Scope]): ScopedMap =
{
val md = memoDelegates(delegates)
def refMap(refKey: ScopedKey[_]) = new (ScopedKey ~> ScopedKey) { def apply[T](k: ScopedKey[T]) = delegateForKey(sMap, k, md(k.scope), refKey) }
val f = new (SettingSeq ~> SettingSeq) { def apply[T](ks: Seq[Setting[T]]) = ks.map{ s => s mapReferenced refMap(s.key) } }
def refMap(refKey: ScopedKey[_]) = new (ScopedKey ~> ScopedKey) { def apply[T](k: ScopedKey[T]) =
delegateForKey(sMap, k, delegates(k.scope), refKey)
}
val f = new (SettingSeq ~> SettingSeq) { def apply[T](ks: Seq[Setting[T]]) =
ks.map{ s => s mapReferenced refMap(s.key) }
}
sMap mapValues f
}
private[this] def delegateForKey[T](sMap: ScopedMap, k: ScopedKey[T], scopes: Seq[Scope], refKey: ScopedKey[_]): ScopedKey[T] =
@ -121,12 +122,6 @@ trait Init[Scope]
private[this] def applyInits(ordered: Seq[Compiled])(implicit delegates: Scope => Seq[Scope]): Settings[Scope] =
(empty /: ordered){ (m, comp) => comp.eval(m) }
private[this] def memoDelegates(implicit delegates: Scope => Seq[Scope]): Scope => Seq[Scope] =
{
val dcache = new mutable.HashMap[Scope, Seq[Scope]]
(scope: Scope) => dcache.getOrElseUpdate(scope, delegates(scope))
}
private[this] def applySetting[T](map: Settings[Scope], setting: Setting[T]): Settings[Scope] =
{
def execK[HL <: HList, M[_]](a: KApply[HL, M, T]) =