minor rearranging

This commit is contained in:
Mark Harrah 2011-02-02 19:27:55 -05:00
parent bff18e7e7a
commit bdf643f57a
2 changed files with 8 additions and 3 deletions

View File

@ -43,7 +43,12 @@ object Project extends Init[Scope]
val st = structure(state)
Extracted(st, se, curi, cid, Load.getRootProject(st.units))
}
def getProject(ref: ProjectRef, structure: Load.BuildStructure): Option[Project] =
ref match {
case ProjectRef(Some(uri), Some(id)) => (structure.units get uri).flatMap(_.defined get id)
case _ => None
}
def current(state: State): (URI, String) = session(state).current
def currentRef(state: State): ProjectRef =
{
@ -77,6 +82,7 @@ object Project extends Init[Scope]
}
}
def display(scoped: ScopedKey[_]): String = Scope.display(scoped.scope, scoped.key.label)
def display(ref: ProjectRef): String = "(" + (ref.uri map (_.toString) getOrElse "<this>") + ")" + (ref.id getOrElse "<root>")
def mapScope(f: Scope => Scope) = new (ScopedKey ~> ScopedKey) { def apply[T](key: ScopedKey[T]) =
ScopedKey( f(key.scope), key.key)

View File

@ -54,11 +54,10 @@ object Scope
}
def display(config: ConfigKey): String = if(config.name == "compile") "" else config.name + ":"
def display(ref: ProjectRef): String = "(" + (ref.uri map (_.toString) getOrElse "<this>") + ")" + (ref.id getOrElse "<root>")
def display(scope: Scope, sep: String): String =
{
import scope.{project, config, task, extra}
val projectPrefix = project.foldStrict(display, "*", ".")
val projectPrefix = project.foldStrict(Project.display, "*", ".")
val configPrefix = config.foldStrict(display, "*:", ".:")
val taskPostfix = task.foldStrict(" for " + _.label, "", "")
val extraPostfix = extra.foldStrict(_.entries.map( _.toString ).toList, Nil, Nil)