Fix configuration identifier completion

Fixes https://github.com/sbt/sbt/issues/6282
This commit is contained in:
Eugene Yokota 2021-01-23 22:15:06 -05:00
parent 151c170409
commit 5deb1f5994
3 changed files with 12 additions and 10 deletions

View File

@ -78,8 +78,8 @@ object Act {
rawProject <- optProjectRef(index, current)
proj = resolveProject(rawProject, current)
confAmb <- configIdent(
index configs proj,
index configIdents proj,
index.configs(proj),
index.configIdents(proj),
index.fromConfigIdent(proj)
)
partialMask = ScopeMask(rawProject.isExplicit, confAmb.isExplicit, false, false)

View File

@ -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)

View File

@ -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)
// })