From bdf643f57a3016444e1b2ec466323201ef068a81 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 2 Feb 2011 19:27:55 -0500 Subject: [PATCH] minor rearranging --- main/Project.scala | 8 +++++++- main/Scope.scala | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main/Project.scala b/main/Project.scala index 60d6ad717..b78401005 100644 --- a/main/Project.scala +++ b/main/Project.scala @@ -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 "") + ")" + (ref.id getOrElse "") def mapScope(f: Scope => Scope) = new (ScopedKey ~> ScopedKey) { def apply[T](key: ScopedKey[T]) = ScopedKey( f(key.scope), key.key) diff --git a/main/Scope.scala b/main/Scope.scala index 8eb8c7e24..dcefbf502 100644 --- a/main/Scope.scala +++ b/main/Scope.scala @@ -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 "") + ")" + (ref.id getOrElse "") 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)