'inspect actual <key>' for actual dependencies, 'inspect <key>' for declared

This commit is contained in:
Mark Harrah 2011-03-29 20:25:12 -04:00
parent 4821f16eb3
commit 2b37df87b5
3 changed files with 7 additions and 6 deletions

View File

@ -241,8 +241,8 @@ object BuiltinCommands
val newSession = session.appendSettings( append map (a => (a, arg)))
reapply(newSession, structure, s)
}
def inspect = Command(InspectCommand, inspectBrief, inspectDetailed)(spacedKeyParser) { (s,sk) =>
val detailString = Project.details(Project.structure(s), sk.scope, sk.key)
def inspect = Command(InspectCommand, inspectBrief, inspectDetailed)(inspectParser) { case (s,(actual,sk)) =>
val detailString = Project.details(Project.structure(s), actual, sk.scope, sk.key)
logger(s).info(detailString)
s
}
@ -250,6 +250,7 @@ object BuiltinCommands
Output.lastGrep(sk, Project.structure(s).streams, pattern)
s
}
def inspectParser = (s: State) => token((Space ~> ("actual" ^^^ true)) ?? false) ~ spacedKeyParser(s)
val spacedKeyParser = (s: State) => Act.requireSession(s, token(Space) ~> Act.scopedKeyParser(s))
val optSpacedKeyParser = (s: State) => spacedKeyParser(s).?
def lastGrepParser(s: State) = Act.requireSession(s, (token(Space) ~> token(NotSpace, "<pattern>")) ~ optSpacedKeyParser(s))

View File

@ -158,7 +158,7 @@ object Project extends Init[Scope]
def delegates(structure: Load.BuildStructure, scope: Scope, key: AttributeKey[_]): Seq[ScopedKey[_]] =
structure.delegates(scope).map(d => ScopedKey(d, key))
def details(structure: Load.BuildStructure, scope: Scope, key: AttributeKey[_]): String =
def details(structure: Load.BuildStructure, actual: Boolean, scope: Scope, key: AttributeKey[_]): String =
{
val scoped = ScopedKey(scope,key)
val value =
@ -169,7 +169,7 @@ object Project extends Init[Scope]
case Some(v) => "Value:\n\t" + v.toString
}
val definedIn = structure.data.definingScope(scope, key) match { case Some(sc) => "Provided by:\n\t" + Scope.display(sc, key.label); case None => "" }
val cMap = compiled(structure.settings)(structure.delegates, structure.scopeLocal)
val cMap = compiled(structure.settings, actual)(structure.delegates, structure.scopeLocal)
val related = cMap.keys.filter(k => k.key == key && k.scope != scope)
val depends = cMap.get(scoped) match { case Some(c) => c.dependencies.toSet; case None => Set.empty }
val reverse = reverseDependencies(cMap, scoped)

View File

@ -69,14 +69,14 @@ trait Init[Scope]
def getValue[T](s: Settings[Scope], k: ScopedKey[T]) = s.get(k.scope, k.key).get
def asFunction[T](s: Settings[Scope]): ScopedKey[T] => T = k => getValue(s, k)
def compiled(init: Seq[Setting[_]])(implicit delegates: Scope => Seq[Scope], scopeLocal: ScopeLocal): CompiledMap =
def compiled(init: Seq[Setting[_]], actual: Boolean = true)(implicit delegates: Scope => Seq[Scope], scopeLocal: ScopeLocal): CompiledMap =
{
// prepend per-scope settings
val withLocal = addLocal(init)(scopeLocal)
// group by Scope/Key, dropping dead initializations
val sMap: ScopedMap = grouped(withLocal)
// delegate references to undefined values according to 'delegates'
val dMap: ScopedMap = delegate(sMap)(delegates)
val dMap: ScopedMap = if(actual) delegate(sMap)(delegates) else sMap
// merge Seq[Setting[_]] into Compiled
compile(dMap)
}