Add whitespaces in Show of scoped keys

```
Provided by:
    ProjectRef(uri("...."), "root") / Test / test
Dependencies:
    Test / executeTests
    Test / test / streams
    Test / state
    Test / test / testResultLogger
```
This commit is contained in:
Eugene Yokota 2017-09-28 01:42:23 -04:00
parent 33a01f3ceb
commit b0306b738e
5 changed files with 49 additions and 32 deletions

View File

@ -75,7 +75,7 @@ object Def extends Init[Scope] with TaskMacroExtra {
private[sbt] def displayRelative(current: ProjectRef,
project: Reference,
trailingSlash: Boolean): String = {
val trailing = if (trailingSlash) "/" else ""
val trailing = if (trailingSlash) " /" else ""
project match {
case BuildRef(current.build) => "ThisBuild" + trailing
case `current` => ""
@ -86,9 +86,9 @@ object Def extends Init[Scope] with TaskMacroExtra {
def displayBuildRelative(currentBuild: URI, multi: Boolean, project: Reference): String =
project match {
case BuildRef(`currentBuild`) => "ThisBuild/"
case ProjectRef(`currentBuild`, x) => x + "/"
case _ => Reference.display(project) + "/"
case BuildRef(`currentBuild`) => "ThisBuild /"
case ProjectRef(`currentBuild`, x) => x + " /"
case _ => Reference.display(project) + " /"
}
def displayFull(scoped: ScopedKey[_]): String = displayFull(scoped, None)

View File

@ -91,7 +91,7 @@ object Reference {
case LocalRootProject => "{<this>}<root>"
case LocalProject(id) => "{<this>}" + id
case RootProject(uri) => "{" + uri + " }<root>"
case ProjectRef(uri, id) => s"""ProjectRef(uri("$uri"),"$id")"""
case ProjectRef(uri, id) => s"""ProjectRef(uri("$uri"), "$id")"""
}
def buildURI(ref: ResolvedReference): URI = ref match {

View File

@ -123,7 +123,7 @@ object Scope {
case BuildRef(uri) => BuildRef(resolveBuild(current, uri))
}
def display(config: ConfigKey): String = guessConfigIdent(config.name) + "/"
def display(config: ConfigKey): String = guessConfigIdent(config.name) + " /"
private[sbt] val configIdents: Map[String, String] =
Map(
@ -176,16 +176,24 @@ object Scope {
mask: ScopeMask,
showZeroConfig: Boolean): String = {
import scope.{ project, config, task, extra }
val zeroConfig = if (showZeroConfig) "Zero/" else ""
val zeroConfig = if (showZeroConfig) "Zero /" else ""
val configPrefix = config.foldStrict(display, zeroConfig, "./")
val taskPrefix = task.foldStrict(_.label + "/", "", "./")
val taskPrefix = task.foldStrict(_.label + " /", "", "./")
val extras = extra.foldStrict(_.entries.map(_.toString).toList, Nil, Nil)
val postfix = if (extras.isEmpty) "" else extras.mkString("(", ", ", ")")
if (scope == GlobalScope) "Global/" + sep + postfix
if (scope == GlobalScope) "Global / " + sep + postfix
else
mask.concatShow(projectPrefix(project, showProject), configPrefix, taskPrefix, sep, postfix)
mask.concatShow(appendSpace(projectPrefix(project, showProject)),
appendSpace(configPrefix),
appendSpace(taskPrefix),
sep,
postfix)
}
private[sbt] def appendSpace(s: String): String =
if (s == "") ""
else s + " "
// sbt 0.12 style
def display012StyleMasked(scope: Scope,
sep: String,
@ -196,7 +204,7 @@ object Scope {
val taskPrefix = task.foldStrict(_.label + "::", "", ".::")
val extras = extra.foldStrict(_.entries.map(_.toString).toList, Nil, Nil)
val postfix = if (extras.isEmpty) "" else extras.mkString("(", ", ", ")")
mask.concatShow(projectPrefix012Style(project, showProject),
mask.concatShow(projectPrefix012Style(project, showProject012Style),
configPrefix,
taskPrefix,
sep,
@ -211,13 +219,15 @@ object Scope {
def projectPrefix(project: ScopeAxis[Reference],
show: Reference => String = showProject): String =
project.foldStrict(show, "Zero/", "./")
project.foldStrict(show, "Zero /", "./")
def projectPrefix012Style(project: ScopeAxis[Reference],
show: Reference => String = showProject): String =
project.foldStrict(show, "*/", "./")
def showProject = (ref: Reference) => Reference.display(ref) + "/"
def showProject = (ref: Reference) => Reference.display(ref) + " /"
def showProject012Style = (ref: Reference) => Reference.display(ref) + "/"
def transformTaskName(s: String) = {
val parts = s.split("-+")

View File

@ -202,7 +202,7 @@ object SettingQueryTest extends org.specs2.mutable.Specification {
"scalaVersion" in qko("Not a valid project ID: scalaVersion\\nscalaVersion\\n ^")
"t/scalacOptions" in qko(
s"""Key ProjectRef(uri(\\"$baseUri\\"),\\"t\\")/Compile/scalacOptions is a task, can only query settings""")
s"""Key ProjectRef(uri(\\"$baseUri\\"), \\"t\\") / Compile / scalacOptions is a task, can only query settings""")
"t/fooo" in qko(
"Expected ':' (if selecting a configuration)\\nNot a valid key: fooo (similar: fork)\\nt/fooo\\n ^")
}

View File

@ -21,29 +21,29 @@ lazy val root = (project in file("."))
Description:
\tExecutes all tests.
Provided by:
\tProjectRef(uri("${baseDirectory.value.toURI}"),"root")/Test/test
\tProjectRef(uri("${baseDirectory.value.toURI}"), "root") / Test / test
Defined at:
\t(sbt.Defaults.testTasks) Defaults.scala:670
Dependencies:
\tTest/executeTests
\tTest/test/streams
\tTest/state
\tTest/test/testResultLogger
\tTest / executeTests
\tTest / test / streams
\tTest / state
\tTest / test / testResultLogger
Delegates:
\tTest/test
\tRuntime/test
\tCompile/test
\tTest / test
\tRuntime / test
\tCompile / test
\ttest
\tThisBuild/Test/test
\tThisBuild/Runtime/test
\tThisBuild/Compile/test
\tThisBuild/test
\tZero/Test/test
\tZero/Runtime/test
\tZero/Compile/test
\tGlobal/test
\tThisBuild / Test / test
\tThisBuild / Runtime / test
\tThisBuild / Compile / test
\tThisBuild / test
\tZero / Test / test
\tZero / Runtime / test
\tZero / Compile / test
\tGlobal / test
Related:
\tprojA/Test/test"""
\tprojA / Test / test"""
if (processText(actual) == processText(expected)) ()
else {
@ -52,7 +52,14 @@ $actual
expected:
$expected
""")
diff:
""" +
(
processText(actual)
zip processText(expected)
filter { case ( a, b) => a != b }
))
}
s.log.info(actual)
s