Completion for build-level keys

sbt's shell provided completion only for keys that were relative to a
defined project, but didn't provide completion for keys that belong to
the build definition only.

This commit fixes this issue by defining a new kind of `Parser` (from
which completions are generated) which runs its input simultaneously on
distinct parsers. We now define a parser for project-level keys and
another parser for build-level keys. These two parsers are eventually
combined, and we get the completions of both parsers.

Fixes sbt/sbt#2460
This commit is contained in:
Martin Duhem 2016-02-22 12:12:32 +01:00
parent 0c086a7761
commit 3c9d2ff57a
1 changed files with 16 additions and 6 deletions

View File

@ -49,12 +49,22 @@ object Act {
new ParsedKey(makeScopedKey(proj, conf, task, extra, key), mask)
}
for {
rawProject <- optProjectRef(index, current)
proj = resolveProject(rawProject, current)
confAmb <- config(index configs proj)
partialMask = ScopeMask(rawProject.isExplicit, confAmb.isExplicit, false, false)
} yield taskKeyExtra(proj, confAmb, partialMask)
val projectKeys =
for {
rawProject <- optProjectRef(index, current)
proj = resolveProject(rawProject, current)
confAmb <- config(index configs proj)
partialMask = ScopeMask(rawProject.isExplicit, confAmb.isExplicit, false, false)
} yield taskKeyExtra(proj, confAmb, partialMask)
val build = Some(BuildRef(current.build))
val buildKeys =
for {
confAmb <- config(index configs build)
partialMask = ScopeMask(false, confAmb.isExplicit, false, false)
} yield taskKeyExtra(build, confAmb, partialMask)
buildKeys combinedWith projectKeys map (_.flatten)
}
def makeScopedKey(proj: Option[ResolvedReference], conf: Option[String], task: Option[AttributeKey[_]], extra: ScopeAxis[AttributeMap], key: AttributeKey[_]): ScopedKey[_] =
ScopedKey(Scope(toAxis(proj, Global), toAxis(conf map ConfigKey.apply, Global), toAxis(task, Global), extra), key)