mirror of https://github.com/sbt/sbt.git
Merge pull request #6283 from eed3si9n/wip/tab_completion
Fix configuration identifier completion
This commit is contained in:
commit
01b5cb1bf4
|
|
@ -18,6 +18,7 @@ import java.net.URI
|
|||
import sbt.internal.CommandStrings.{ MultiTaskCommand, ShowCommand, PrintCommand }
|
||||
import sbt.internal.util.{ AttributeEntry, AttributeKey, AttributeMap, IMap, Settings, Util }
|
||||
import sbt.util.Show
|
||||
import scala.collection.mutable
|
||||
|
||||
final class ParsedKey(val key: ScopedKey[_], val mask: ScopeMask)
|
||||
|
||||
|
|
@ -73,14 +74,19 @@ object Act {
|
|||
defaultConfigs: Option[ResolvedReference] => Seq[String],
|
||||
keyMap: Map[String, AttributeKey[_]]
|
||||
): Parser[Seq[Parser[ParsedKey]]] = {
|
||||
val confParserCache: mutable.Map[Option[sbt.ResolvedReference], Parser[ParsedAxis[String]]] =
|
||||
mutable.Map.empty
|
||||
def fullKey =
|
||||
for {
|
||||
rawProject <- optProjectRef(index, current)
|
||||
proj = resolveProject(rawProject, current)
|
||||
confAmb <- configIdent(
|
||||
index configs proj,
|
||||
index configIdents proj,
|
||||
index.fromConfigIdent(proj)
|
||||
confAmb <- confParserCache.getOrElseUpdate(
|
||||
proj,
|
||||
configIdent(
|
||||
index.configs(proj),
|
||||
index.configIdents(proj),
|
||||
index.fromConfigIdent(proj)
|
||||
)
|
||||
)
|
||||
partialMask = ScopeMask(rawProject.isExplicit, confAmb.isExplicit, false, false)
|
||||
} yield taskKeyExtra(index, defaultConfigs, keyMap, proj, confAmb, partialMask)
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ private[sbt] final class ConfigIndex(
|
|||
}
|
||||
|
||||
def configs: Set[String] = data.keySet
|
||||
private[sbt] lazy val idents: Set[String] = configIdentToName.keySet
|
||||
|
||||
// guess Configuration name from an identifier.
|
||||
// There's a guessing involved because we could have scoped key that Project is not aware of.
|
||||
|
|
@ -201,6 +202,7 @@ private[sbt] final class ConfigIndex(
|
|||
configIdentToName.getOrElse(ident, Scope.unguessConfigIdent(ident))
|
||||
}
|
||||
private[sbt] object ConfigIndex
|
||||
|
||||
private[sbt] final class ProjectIndex(val data: Map[Option[String], ConfigIndex]) {
|
||||
def add(
|
||||
id: Option[String],
|
||||
|
|
@ -234,7 +236,7 @@ private[sbt] final class KeyIndex0(val data: BuildIndex) extends ExtendableKeyIn
|
|||
def configs(project: Option[ResolvedReference]): Set[String] = confIndex(project).configs
|
||||
|
||||
private[sbt] def configIdents(project: Option[ResolvedReference]): Set[String] =
|
||||
confIndex(project).configs
|
||||
confIndex(project).idents
|
||||
|
||||
private[sbt] def fromConfigIdent(proj: Option[ResolvedReference])(configIdent: String): String =
|
||||
confIndex(proj).fromConfigIdent(configIdent)
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ object CompletionSpec extends Properties {
|
|||
property("can complete any project", TestBuild.nonEmptyId.forAll.map { id =>
|
||||
complete(projectID = id, line = id.head.toString, expected = id)
|
||||
}),
|
||||
// property(
|
||||
// "can complete any configuration",
|
||||
// TestBuild.nonEmptyId.forAll.map { name =>
|
||||
// val cap = name.capitalize
|
||||
// complete(configName = name, line = cap.head.toString, expected = cap)
|
||||
// }
|
||||
// ),
|
||||
property(
|
||||
"can complete any configuration",
|
||||
TestBuild.nonEmptyId.forAll.map { name =>
|
||||
val cap = name.capitalize
|
||||
complete(configName = name, line = cap.head.toString, expected = cap)
|
||||
}
|
||||
),
|
||||
// property("can complete any attribute", TestBuild.kebabIdGen.forAll.map { name =>
|
||||
// complete(attributeName = name, line = name.head.toString, expected = name)
|
||||
// })
|
||||
|
|
|
|||
Loading…
Reference in New Issue