mirror of https://github.com/sbt/sbt.git
Merge pull request #3603 from eed3si9n/wip/zerozerozero
Fixes Zero / Zero / Zero / name handling
This commit is contained in:
commit
dae4694f46
|
|
@ -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] =
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package sbt
|
||||
|
||||
import sbt.librarymanagement.Configuration
|
||||
import sbt.internal.util.AttributeKey
|
||||
|
||||
/**
|
||||
* SlashSyntax implements the slash syntax to scope keys for build.sbt DSL.
|
||||
|
|
@ -57,7 +58,12 @@ object SlashSyntax {
|
|||
}
|
||||
|
||||
/** RichConfiguration wraps a configuration to provide the `/` operator for scoping. */
|
||||
final class RichConfiguration(protected val scope: Scope) extends RichScopeLike
|
||||
final class RichConfiguration(protected val scope: Scope) extends RichScopeLike {
|
||||
|
||||
// This is for handling `Zero / Zero / Zero / name`.
|
||||
def /(taskAxis: ScopeAxis[AttributeKey[_]]): RichScope =
|
||||
new RichScope(scope.copy(task = taskAxis))
|
||||
}
|
||||
|
||||
/** Both `Scoped.ScopingSetting` and `Scoped` are parents of `SettingKey`, `TaskKey` and
|
||||
* `InputKey`. We'll need both, so this is a convenient type alias. */
|
||||
|
|
@ -91,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}"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ lazy val root = (project in file("."))
|
|||
Compile / console / scalacOptions += "-Ywarn-numeric-widen",
|
||||
projA / Compile / console / scalacOptions += "-feature",
|
||||
Zero / Zero / name := "foo",
|
||||
Zero / Zero / Zero / name := "foo",
|
||||
|
||||
libraryDependencies += uTest % Test,
|
||||
testFrameworks += new TestFramework("utest.runner.Framework"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue