Check for the case the project doesn't exist after reload.

This commit is contained in:
Eugene Vigdorchik 2012-01-31 21:15:18 +04:00
parent 8daa6d3279
commit 0dafd5ef26
1 changed files with 11 additions and 5 deletions

16
main/Load.scala Normal file → Executable file
View File

@ -534,17 +534,23 @@ object Load
}
def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = {
val current = s get Keys.sessionSettings map (_.currentProject)
new SessionSettings(structure.root, projectMap(structure.units, current), structure.settings, Map.empty, Nil, rootEval)
val current = s get Keys.sessionSettings map (_.currentProject) getOrElse Map.empty
new SessionSettings(structure.root, projectMap(structure, current), structure.settings, Map.empty, Nil, rootEval)
}
def initialSession(structure: BuildStructure, rootEval: () => Eval): SessionSettings =
new SessionSettings(structure.root, projectMap(structure.units, None), structure.settings, Map.empty, Nil, rootEval)
new SessionSettings(structure.root, projectMap(structure, Map.empty), structure.settings, Map.empty, Nil, rootEval)
def projectMap(units: Map[URI, LoadedBuildUnit], current: Option[Map[URI, String]]): Map[URI, String] =
def projectMap(structure: BuildStructure, current: Map[URI, String]): Map[URI, String] =
{
val units = structure.units
val getRoot = getRootProject(units)
units.keys.map(uri => (uri, current.flatMap(_ get uri) getOrElse getRoot(uri))).toMap
def project(uri: URI) = {
current get uri map {
p => if (structure allProjects uri map (_.id) contains p) p else getRoot(uri)
} getOrElse getRoot(uri)
}
units.keys.map(uri => (uri, project(uri))).toMap
}
def defaultEvalOptions: Seq[String] = Nil