mirror of https://github.com/sbt/sbt.git
Implement toString for keys
toString added for REPL testing: ``` scala> Zero / Zero / Zero / name res0: sbt.SlashSyntax.ScopeAndKey[sbt.SettingKey[String]] = Zero / Zero / Zero / name ```
This commit is contained in:
parent
53bbb99617
commit
60f2498c0a
|
|
@ -24,6 +24,11 @@ final case class Scope(project: ScopeAxis[Reference],
|
|||
def in(project: Reference): Scope = copy(project = Select(project))
|
||||
def in(config: ConfigKey): Scope = copy(config = Select(config))
|
||||
def in(task: AttributeKey[_]): Scope = copy(task = Select(task))
|
||||
|
||||
override def toString: String = {
|
||||
if (extra == This) s"$project / $config / $task"
|
||||
else s"Scope($project, $config, $task, $extra)"
|
||||
}
|
||||
}
|
||||
object Scope {
|
||||
val ThisScope: Scope = Scope(This, This, This, This)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ sealed abstract class SettingKey[T]
|
|||
|
||||
val key: AttributeKey[T]
|
||||
|
||||
override def toString: String = s"SettingKey($scope / $key)"
|
||||
|
||||
final def toTask: Initialize[Task[T]] = this apply inlineTask
|
||||
|
||||
final def scopedKey: ScopedKey[T] = ScopedKey(scope, key)
|
||||
|
|
@ -105,6 +107,8 @@ sealed abstract class TaskKey[T]
|
|||
|
||||
val key: AttributeKey[Task[T]]
|
||||
|
||||
override def toString: String = s"TaskKey($scope / $key)"
|
||||
|
||||
def toTask: Initialize[Task[T]] = this
|
||||
|
||||
def scopedKey: ScopedKey[Task[T]] = ScopedKey(scope, key)
|
||||
|
|
@ -172,6 +176,8 @@ sealed trait InputKey[T]
|
|||
|
||||
val key: AttributeKey[InputTask[T]]
|
||||
|
||||
override def toString: String = s"InputKey($scope / $key)"
|
||||
|
||||
def scopedKey: ScopedKey[InputTask[T]] = ScopedKey(scope, key)
|
||||
|
||||
def in(scope: Scope): InputKey[T] =
|
||||
|
|
|
|||
|
|
@ -97,6 +97,10 @@ object SlashSyntax {
|
|||
final class ScopeAndKey[K <: Key[K]](scope: Scope, key: K) {
|
||||
private[sbt] def materialize: K = key in scope
|
||||
private[sbt] def rescope: TerminalScope = new TerminalScope(scope in key.key)
|
||||
|
||||
override def toString: String = {
|
||||
s"$scope / ${key.key}"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue