From 70d7ddb25801703c59bcaac3cd56c411ad2c1bb4 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 24 Nov 2024 23:57:11 -0500 Subject: [PATCH] Refactor slash syntax to mostly use methods **Problem** Slash syntax is currently implemented via a series of implicit converters (Conversion), which is not nice, partly because the behavior is difficult to follow. **Solution** This removes all the implicit converters and moves the slashes into: 1. / methods under Reference for subproject scoping. 2. / methods under ScopeAxis with Reference type constraint for the initial Zero scoping. 3. Return RefThenConfig structure for intermediate config scoping. 4. / method under `Scoped`, which is base trait for the keys to implement task scoping e.g. `compile / scalacOptions`. 5. Extension methods for ConfigKey. 6. Extension methods for AttributeKey. --- .../sbt/internal/EvaluateConfigurations.scala | 1 - .../src/main/scala/sbt/Previous.scala | 1 - .../src/main/scala/sbt/Reference.scala | 11 ++- main-settings/src/main/scala/sbt/Scope.scala | 3 + .../src/main/scala/sbt/ScopeAxis.scala | 28 +++++++ .../src/main/scala/sbt/SlashSyntax.scala | 84 ++++--------------- .../src/main/scala/sbt/Structure.scala | 12 +-- .../src/test/scala/sbt/AppendSpec.scala | 1 - .../src/test/scala/sbt/SlashSyntaxSpec.scala | 25 +++++- .../src/test/scala/sbt/SlashSyntaxTest.scala | 1 + main/src/main/scala/sbt/Cross.scala | 1 - main/src/main/scala/sbt/Defaults.scala | 2 +- main/src/main/scala/sbt/EvaluateTask.scala | 1 - main/src/main/scala/sbt/Extracted.scala | 1 - main/src/main/scala/sbt/PluginCross.scala | 1 - main/src/main/scala/sbt/ProjectExtra.scala | 1 - main/src/main/scala/sbt/RemoteCache.scala | 2 +- main/src/main/scala/sbt/ScriptedPlugin.scala | 2 +- .../main/scala/sbt/internal/Aggregation.scala | 1 - .../scala/sbt/internal/BuildStructure.scala | 1 - .../scala/sbt/internal/ClassLoaders.scala | 1 - main/src/main/scala/sbt/internal/Clean.scala | 3 +- .../main/scala/sbt/internal/Continuous.scala | 1 - .../main/scala/sbt/internal/CrossJava.scala | 1 - .../DefaultBackgroundJobService.scala | 1 - .../scala/sbt/internal/GlobalPlugin.scala | 2 +- .../main/scala/sbt/internal/IvyConsole.scala | 2 +- .../main/scala/sbt/internal/LintUnused.scala | 1 - main/src/main/scala/sbt/internal/Load.scala | 2 +- .../main/scala/sbt/internal/LogManager.scala | 1 - main/src/main/scala/sbt/internal/Script.scala | 2 +- .../sbt/internal/SettingCompletions.scala | 1 - .../WatchTransitiveDependencies.scala | 1 - .../internal/server/BuildServerProtocol.scala | 1 - .../sbt/internal/server/NetworkChannel.scala | 1 - .../scala/sbt/nio/CheckBuildSources.scala | 1 - main/src/main/scala/sbt/nio/Settings.scala | 1 - 37 files changed, 86 insertions(+), 117 deletions(-) diff --git a/buildfile/src/main/scala/sbt/internal/EvaluateConfigurations.scala b/buildfile/src/main/scala/sbt/internal/EvaluateConfigurations.scala index c55aabac3..fe94d7e8f 100644 --- a/buildfile/src/main/scala/sbt/internal/EvaluateConfigurations.scala +++ b/buildfile/src/main/scala/sbt/internal/EvaluateConfigurations.scala @@ -16,7 +16,6 @@ import java.nio.file.Path import sbt.internal.util.complete.DefaultParsers.validID import Def.{ ScopedKey, Setting, Settings } import Scope.GlobalScope -import sbt.SlashSyntax0.given import sbt.internal.parser.SbtParser import sbt.io.IO import scala.jdk.CollectionConverters.* diff --git a/main-settings/src/main/scala/sbt/Previous.scala b/main-settings/src/main/scala/sbt/Previous.scala index bfcb3685a..5a8025c9e 100644 --- a/main-settings/src/main/scala/sbt/Previous.scala +++ b/main-settings/src/main/scala/sbt/Previous.scala @@ -12,7 +12,6 @@ import sbt.Def.{ Initialize, ScopedKey } import sbt.Previous._ import sbt.Scope.Global import sbt.ScopeAxis.Select -import sbt.SlashSyntax0.given import sbt.internal.util._ import sbt.std.TaskExtra._ import sbt.util.StampedFormat diff --git a/main-settings/src/main/scala/sbt/Reference.scala b/main-settings/src/main/scala/sbt/Reference.scala index f2c8781d4..bff8edec7 100644 --- a/main-settings/src/main/scala/sbt/Reference.scala +++ b/main-settings/src/main/scala/sbt/Reference.scala @@ -14,8 +14,7 @@ import java.net.URI import sbt.internal.util.AttributeKey import sbt.io.IO import sbt.librarymanagement.Configuration -import sbt.ScopeAxis.{ Select, This } -import sbt.SlashSyntax.RichConfiguration +import sbt.ScopeAxis.{ Select, This, RefThenConfig } // in all of these, the URI must be resolved and normalized before it is definitive @@ -26,13 +25,13 @@ sealed trait Reference: private[sbt] def asScope: Scope = Scope(asScopeAxis, This, This, This) - def /(c: ConfigKey): RichConfiguration = RichConfiguration(asScope.rescope(c)) + def /(c: ConfigKey): RefThenConfig = RefThenConfig(asScope.rescope(c)) - def /(c: Configuration): RichConfiguration = RichConfiguration(asScope.rescope(c)) + def /(c: Configuration): RefThenConfig = RefThenConfig(asScope.rescope(c)) // This is for handling `Zero / Zero / name`. - def /(configAxis: ScopeAxis[ConfigKey]): RichConfiguration = - new RichConfiguration(asScope.copy(config = configAxis)) + def /(configAxis: ScopeAxis[ConfigKey]): RefThenConfig = + RefThenConfig(asScope.copy(config = configAxis)) final def /[K](key: Scoped.ScopingSetting[K]): K = key.rescope(asScope) diff --git a/main-settings/src/main/scala/sbt/Scope.scala b/main-settings/src/main/scala/sbt/Scope.scala index e2fa52917..79e2647ce 100644 --- a/main-settings/src/main/scala/sbt/Scope.scala +++ b/main-settings/src/main/scala/sbt/Scope.scala @@ -32,6 +32,9 @@ final case class Scope private ( def rescope(config: ConfigKey): Scope = copy(config = Select(config)) def rescope(task: AttributeKey[?]): Scope = copy(task = Select(task)) + final def /[K](key: Scoped.ScopingSetting[K]): K = scope(key) + def scope[K](key: Scoped.ScopingSetting[K]): K = key.rescope(this) + def copy( project: ScopeAxis[Reference] = this.project, config: ScopeAxis[ConfigKey] = this.config, diff --git a/main-settings/src/main/scala/sbt/ScopeAxis.scala b/main-settings/src/main/scala/sbt/ScopeAxis.scala index 62f216186..a0feee375 100644 --- a/main-settings/src/main/scala/sbt/ScopeAxis.scala +++ b/main-settings/src/main/scala/sbt/ScopeAxis.scala @@ -9,8 +9,12 @@ package sbt import sbt.internal.util.Util.* +import sbt.librarymanagement.Configuration +import sbt.internal.util.AttributeKey enum ScopeAxis[+A1]: + import ScopeAxis.RefThenConfig + /** * Select is a type constructor that is used to wrap type `S` * to make a scope component, equivalent of Some in Option. @@ -46,6 +50,19 @@ enum ScopeAxis[+A1]: def map[A2](f: A1 => A2): ScopeAxis[A2] = foldStrict(s => Select(f(s)): ScopeAxis[A2], Zero: ScopeAxis[A2], This: ScopeAxis[A2]) + + def asScope(using A1 <:< Reference): Scope = + Scope(this.asInstanceOf[ScopeAxis[Reference]], This, This, This) + + inline def /[K](key: Scoped.ScopingSetting[K])(using A1 <:< Reference): K = key.rescope(asScope) + + inline def /(c: ConfigKey)(using A1 <:< Reference): RefThenConfig = + RefThenConfig(asScope.rescope(c)) + inline def /(c: Configuration)(using A1 <:< Reference): RefThenConfig = + RefThenConfig(asScope.rescope(c)) + // This is for handling `Zero / Zero / name`. + inline def /(configAxis: ScopeAxis[ConfigKey])(using A1 <:< Reference): RefThenConfig = + RefThenConfig(asScope.copy(config = configAxis)) end ScopeAxis object ScopeAxis: @@ -55,4 +72,15 @@ object ScopeAxis: def fromOption[A1](o: Option[A1]): ScopeAxis[A1] = o match case Some(v) => ScopeAxis.Select(v) case None => ScopeAxis.Zero + + /** Temporary data structure to capture first two axis using slash syntax. */ + class RefThenConfig(val scope: Scope): + override def toString(): String = scope.toString() + inline def /[K](key: Scoped.ScopingSetting[K]): K = scope / key + + inline def /(task: AttributeKey[?]): Scope = scope.copy(task = Select(task)) + + /** This is for handling `Zero / Zero / Zero / name`. */ + inline def /(taskAxis: ScopeAxis[AttributeKey[?]]): Scope = scope.copy(task = taskAxis) + end RefThenConfig end ScopeAxis diff --git a/main-settings/src/main/scala/sbt/SlashSyntax.scala b/main-settings/src/main/scala/sbt/SlashSyntax.scala index 041cb5627..1eef153cf 100644 --- a/main-settings/src/main/scala/sbt/SlashSyntax.scala +++ b/main-settings/src/main/scala/sbt/SlashSyntax.scala @@ -13,88 +13,32 @@ import sbt.internal.util.AttributeKey import sbt.ScopeAxis.{ Select, This } /** - * SlashSyntax implements the slash syntax to scope keys for build.sbt DSL. - * The implicits are set up such that the order that the scope components - * must appear in the order of the project axis, the configuration axis, and - * the task axis. This ordering is the same as the shell syntax. + * SlashSyntax implements part of the slash syntax to scope keys for build.sbt DSL. * * @example * {{{ - * Global / cancelable := true - * ThisBuild / scalaVersion := "2.12.2" * Test / test := () - * console / scalacOptions += "-deprecation" + * console.key / scalacOptions += "-deprecation" * Compile / console / scalacOptions += "-Ywarn-numeric-widen" - * projA / Compile / console / scalacOptions += "-feature" - * Zero / Zero / name := "foo" * }}} */ trait SlashSyntax: - import SlashSyntax.* - - given Conversion[ScopeAxis[Reference], RichReference] = - (a: ScopeAxis[Reference]) => RichReference(Scope(a, This, This, This)) - - given Conversion[ConfigKey, RichConfiguration] = - (c: ConfigKey) => RichConfiguration(Scope(This, Select(c), This, This)) - - given Conversion[Configuration, RichConfiguration] = - (c: Configuration) => (c: ConfigKey) - /** - * This handles task scoping an existing scoped key (such as `Compile / test`) - * into a task scoping in `(Compile / test) / name`. + * Handles slash syntax for `key.key / key`. */ - given Conversion[Scoped, Scope] = - (t: Scoped) => t.scope.copy(task = Select(t.key)) + extension [A1](a: AttributeKey[A1]) + def asScope: Scope = Scope(This, This, Select(a), This) + def /[K](key: Scoped.ScopingSetting[K]): K = a.asScope.scope(key) - given Conversion[Scoped, RichScope] = - (t: Scoped) => RichScope(t: Scope) - - given [A1]: Conversion[AttributeKey[A1], Scope] = - (a: AttributeKey[A1]) => Scope(This, This, Select(a), This) - - given [A1]: Conversion[AttributeKey[A1], RichScope] = - (a: AttributeKey[A1]) => RichScope(a: Scope) - - given Conversion[Scope, RichScope] = - (scope: Scope) => RichScope(scope) -end SlashSyntax - -object SlashSyntax: - - sealed trait HasSlashKey { - protected def scope: Scope - def /[K](key: Scoped.ScopingSetting[K]): K = key.rescope(scope) - } - - sealed trait HasSlashKeyOrAttrKey extends HasSlashKey { - def /(key: AttributeKey[?]): Scope = scope.rescope(key) - } - - /** RichReference wraps a reference to provide the `/` operator for scoping. */ - final class RichReference(protected val scope: Scope) extends HasSlashKeyOrAttrKey { - def /(c: ConfigKey): RichConfiguration = new RichConfiguration(scope.rescope(c)) - - def /(c: Configuration): RichConfiguration = new RichConfiguration(scope.rescope(c)) - - // This is for handling `Zero / Zero / name`. - def /(configAxis: ScopeAxis[ConfigKey]): RichConfiguration = - new RichConfiguration(scope.copy(config = configAxis)) - } - - /** RichConfiguration wraps a configuration to provide the `/` operator for scoping. */ - final class RichConfiguration(protected val scope: Scope) extends HasSlashKeyOrAttrKey { - // This is for handling `Zero / Zero / Zero / name`. - def /(taskAxis: ScopeAxis[AttributeKey[?]]): Scope = - scope.copy(task = taskAxis) - } - - /** - * RichScope wraps a general scope to provide the `/` operator for scoping. - */ - final class RichScope(protected val scope: Scope) extends HasSlashKeyOrAttrKey + extension (c: ConfigKey) + def asScope: Scope = Scope(This, Select(c), This, This) + def /[K](key: Scoped.ScopingSetting[K]): K = c.asScope.scope(key) + def /(task: AttributeKey[?]): Scope = c.asScope.copy(task = Select(task)) + extension (c: Configuration) + def asScope: Scope = (c: ConfigKey).asScope + def /[K](key: Scoped.ScopingSetting[K]): K = (c: ConfigKey) / key + def /(task: AttributeKey[?]): Scope = (c: ConfigKey) / task end SlashSyntax private[sbt] object SlashSyntax0 extends SlashSyntax diff --git a/main-settings/src/main/scala/sbt/Structure.scala b/main-settings/src/main/scala/sbt/Structure.scala index 0b4757731..55cc0dd8c 100644 --- a/main-settings/src/main/scala/sbt/Structure.scala +++ b/main-settings/src/main/scala/sbt/Structure.scala @@ -33,6 +33,9 @@ sealed trait Scoped extends Equals: }) override def hashCode(): Int = (scope, key).## + + final def /[K](subkey: Scoped.ScopingSetting[K]): K = + scope.copy(task = Select(key)).scope(subkey) end Scoped /** A SettingKey, TaskKey or `Initialize[Task]` that can be converted into an `Initialize[Task]`. */ @@ -76,9 +79,6 @@ sealed abstract class SettingKey[A1] private[sbt] final inline def rescope(scope: Scope): SettingKey[A1] = Scoped.scopedSetting(Scope.replaceThis(this.scope)(scope), this.key) - final def /[A1](subkey: Scoped.ScopingSetting[A1]): A1 = - subkey.rescope(scope.copy(task = Select(key))) - /** Internal function for the setting macro. */ inline def settingMacro[A](inline a: A): Initialize[A] = ${ std.SettingMacro.settingMacroImpl[A]('a) } @@ -157,9 +157,6 @@ sealed abstract class TaskKey[A1] private[sbt] final inline def rescope(scope: Scope): TaskKey[A1] = Scoped.scopedTask(Scope.replaceThis(this.scope)(scope), this.key) - final def /[A1](subkey: Scoped.ScopingSetting[A1]): A1 = - subkey.rescope(scope.copy(task = Select(key))) - inline def +=[A2](inline v: A2)(using Append.Value[A1, A2]): Setting[Task[A1]] = append1[A2](taskMacro(v)) @@ -240,9 +237,6 @@ sealed trait InputKey[A1] private[sbt] final inline def rescope(scope: Scope): InputKey[A1] = Scoped.scopedInput(Scope.replaceThis(this.scope)(scope), this.key) - final def /[A1](subkey: Scoped.ScopingSetting[A1]): A1 = - subkey.rescope(scope.copy(task = Select(key))) - private inline def inputTaskMacro[A2](inline a: A2): Def.Initialize[InputTask[A2]] = ${ std.InputTaskMacro.inputTaskMacroImpl('a) } diff --git a/main-settings/src/test/scala/sbt/AppendSpec.scala b/main-settings/src/test/scala/sbt/AppendSpec.scala index 7b224f5b1..b3ecb23ae 100644 --- a/main-settings/src/test/scala/sbt/AppendSpec.scala +++ b/main-settings/src/test/scala/sbt/AppendSpec.scala @@ -11,7 +11,6 @@ object AppendSpec { val onLoad = SettingKey[State => State]("onLoad") import Scope.Global - import SlashSyntax0.given def doSideEffect(): Unit = () diff --git a/main-settings/src/test/scala/sbt/SlashSyntaxSpec.scala b/main-settings/src/test/scala/sbt/SlashSyntaxSpec.scala index 943ffe2f5..88c3fac2e 100644 --- a/main-settings/src/test/scala/sbt/SlashSyntaxSpec.scala +++ b/main-settings/src/test/scala/sbt/SlashSyntaxSpec.scala @@ -13,7 +13,7 @@ import hedgehog.* import hedgehog.runner.* import Scope.{ Global, ThisScope } import ScopeAxis.{ Select, This, Zero } -import SlashSyntax0.given +import SlashSyntax0.* import BuildSettingsInstances.given import _root_.sbt.internal.util.AttributeKey @@ -23,6 +23,7 @@ object SlashSyntaxSpec extends Properties: example("Zero / compile", zeroCompile), property("Reference / key", propReferenceKey), property("Reference / Config / key", propReferenceConfigKey), + example("Zero / Zero / compile", zeroZeroCompile), property("Reference / task.key / key", propReferenceAttrKeyKey), property("Reference / task / key", propReferenceTaskKey), property("Reference / inputtask / key", propReferenceInputTaskKey), @@ -37,6 +38,7 @@ object SlashSyntaxSpec extends Properties: property("task / key", propTaskKey), property("inputtask / key", propInputTaskKey), property("Scope / key", propScopeKey), + property("Reference / Config? / key", propReferenceConfigAxisKey), property("Reference? / key", propReferenceAxisKey), property("Reference? / Config? / key", propReferenceAxisConfigAxisKey), // property("Reference? / task.key? / key", propReferenceAxisAttrKeyAxisKey), @@ -65,6 +67,10 @@ object SlashSyntaxSpec extends Properties: val actual = Zero / compile Result.assert(actual.scope.project == Zero && actual.key == compile.key) + def zeroZeroCompile: Result = + val actual = Zero / Zero / compile + Result.assert(actual.scope.project == Zero && actual.key == compile.key) + def propReferenceKey: Property = for ref <- gen[Reference].forAll @@ -330,6 +336,23 @@ object SlashSyntaxSpec extends Properties: else true) ) + def propReferenceConfigAxisKey: Property = + for + ref <- gen[Reference].forAll + config <- gen[ScopeAxis[ConfigKey]].forAll + k <- genKey[Unit].forAll + actual = k match + case k: InputKey[?] => ref / config / k + case k: TaskKey[?] => ref / config / k + case k: SettingKey[?] => ref / config / k + yield Result.assert( + actual.key == k.key && + (if k.scope.project == This then actual.scope.project == Select(ref) + else true) && + (if k.scope.config == This then actual.scope.config == config + else true) + ) + def propReferenceAxisKey: Property = for ref <- gen[ScopeAxis[Reference]].forAll diff --git a/main-settings/src/test/scala/sbt/SlashSyntaxTest.scala b/main-settings/src/test/scala/sbt/SlashSyntaxTest.scala index a91c60503..89e30c763 100644 --- a/main-settings/src/test/scala/sbt/SlashSyntaxTest.scala +++ b/main-settings/src/test/scala/sbt/SlashSyntaxTest.scala @@ -13,6 +13,7 @@ import sjsonnew._ import sbt.Def.{ Setting, inputKey, settingKey, taskKey } import sbt.Scope.Global import sbt.ScopeAxis.Zero +import sbt.SlashSyntax0.* import sbt.librarymanagement.ModuleID import sbt.librarymanagement.syntax._ import sbt.{ LocalProject, ProjectReference, ThisBuild } diff --git a/main/src/main/scala/sbt/Cross.scala b/main/src/main/scala/sbt/Cross.scala index 76c6bfc2a..0b28e0a07 100644 --- a/main/src/main/scala/sbt/Cross.scala +++ b/main/src/main/scala/sbt/Cross.scala @@ -13,7 +13,6 @@ import sbt.Def.{ ScopedKey, Setting } import sbt.Keys._ import sbt.ProjectExtra.extract import sbt.ScopeAxis.{ Select, Zero } -import sbt.SlashSyntax0.given import sbt.internal.Act import sbt.internal.CommandStrings._ import sbt.internal.inc.ScalaInstance diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 0049adfad..8afe51adf 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -98,7 +98,7 @@ import scala.util.control.NonFatal import scala.xml.NodeSeq // incremental compiler -import sbt.SlashSyntax0.given +import sbt.SlashSyntax0.* import sbt.internal.inc.{ Analysis, AnalyzingCompiler, diff --git a/main/src/main/scala/sbt/EvaluateTask.scala b/main/src/main/scala/sbt/EvaluateTask.scala index c6a438681..69345b326 100644 --- a/main/src/main/scala/sbt/EvaluateTask.scala +++ b/main/src/main/scala/sbt/EvaluateTask.scala @@ -16,7 +16,6 @@ import sbt.Keys.{ TaskProgress => _, name => _, _ } import sbt.BuildExtra.* import sbt.ProjectExtra.* import sbt.Scope.Global -import sbt.SlashSyntax0.given import sbt.internal.Aggregation.KeyValue import sbt.internal.TaskName._ import sbt.internal._ diff --git a/main/src/main/scala/sbt/Extracted.scala b/main/src/main/scala/sbt/Extracted.scala index cbe4251ba..b7df96d8f 100644 --- a/main/src/main/scala/sbt/Extracted.scala +++ b/main/src/main/scala/sbt/Extracted.scala @@ -17,7 +17,6 @@ import sbt.util.Show import std.Transform.DummyTaskMap import sbt.EvaluateTask.extractedTaskConfig import sbt.ProjectExtra.setProject -import sbt.SlashSyntax0.given final case class Extracted( structure: BuildStructure, diff --git a/main/src/main/scala/sbt/PluginCross.scala b/main/src/main/scala/sbt/PluginCross.scala index d63c2c44e..0a1fab254 100644 --- a/main/src/main/scala/sbt/PluginCross.scala +++ b/main/src/main/scala/sbt/PluginCross.scala @@ -14,7 +14,6 @@ import sbt.Keys._ import Scope.GlobalScope import Def.ScopedKey import sbt.ScopeAxis.Select -import sbt.SlashSyntax0.given import sbt.internal.Load import sbt.internal.CommandStrings._ import Cross.{ spacedFirst, requireSession } diff --git a/main/src/main/scala/sbt/ProjectExtra.scala b/main/src/main/scala/sbt/ProjectExtra.scala index 45c07b136..5b88d37b8 100755 --- a/main/src/main/scala/sbt/ProjectExtra.scala +++ b/main/src/main/scala/sbt/ProjectExtra.scala @@ -38,7 +38,6 @@ import Keys.{ import Project.LoadAction import Scope.{ Global, ThisScope } import sbt.ScopeAxis.Select -import sbt.SlashSyntax0.given import Def.{ Flattened, Initialize, ScopedKey, Setting } import sbt.internal.{ Load, diff --git a/main/src/main/scala/sbt/RemoteCache.scala b/main/src/main/scala/sbt/RemoteCache.scala index dc570e76b..10dc12c3a 100644 --- a/main/src/main/scala/sbt/RemoteCache.scala +++ b/main/src/main/scala/sbt/RemoteCache.scala @@ -22,7 +22,7 @@ import sbt.Project.{ inConfig => _, * } import sbt.ProjectExtra.* import sbt.ScopeFilter.Make._ import sbt.ScopeAxis.Select -import sbt.SlashSyntax0.given +import sbt.SlashSyntax0.* import sbt.coursierint.LMCoursier import sbt.internal.inc.{ HashUtil, JarUtils } import sbt.internal.librarymanagement._ diff --git a/main/src/main/scala/sbt/ScriptedPlugin.scala b/main/src/main/scala/sbt/ScriptedPlugin.scala index cc6fbdfcf..1df1ea451 100644 --- a/main/src/main/scala/sbt/ScriptedPlugin.scala +++ b/main/src/main/scala/sbt/ScriptedPlugin.scala @@ -15,7 +15,7 @@ import sbt.Keys._ import sbt.nio.Keys._ import sbt.ProjectExtra.* import sbt.ScopeFilter.Make._ -import sbt.SlashSyntax0.given +import sbt.SlashSyntax0.* import sbt.internal.inc.ModuleUtilities import sbt.internal.inc.classpath.ClasspathUtil import sbt.internal.librarymanagement.cross.CrossVersionUtil diff --git a/main/src/main/scala/sbt/internal/Aggregation.scala b/main/src/main/scala/sbt/internal/Aggregation.scala index 084051bba..84bfb935f 100644 --- a/main/src/main/scala/sbt/internal/Aggregation.scala +++ b/main/src/main/scala/sbt/internal/Aggregation.scala @@ -15,7 +15,6 @@ import sbt.Def.{ ScopedKey, Settings } import sbt.Keys.{ showSuccess, showTiming, timingFormat } import sbt.ProjectExtra.* import sbt.ScopeAxis.{ Select, Zero } -import sbt.SlashSyntax0.given import sbt.internal.util.complete.Parser import sbt.internal.util.complete.Parser.{ failure, seq, success } import sbt.internal.util._ diff --git a/main/src/main/scala/sbt/internal/BuildStructure.scala b/main/src/main/scala/sbt/internal/BuildStructure.scala index 319a3e32c..669406cfb 100644 --- a/main/src/main/scala/sbt/internal/BuildStructure.scala +++ b/main/src/main/scala/sbt/internal/BuildStructure.scala @@ -17,7 +17,6 @@ import Def.{ ScopeLocal, ScopedKey, Setting, displayFull } import BuildPaths.outputDirectory import Scope.GlobalScope import sbt.ScopeAxis.{ Select, This, Zero } -import sbt.SlashSyntax0.given import BuildStreams.Streams import sbt.io.syntax._ import sbt.internal.inc.MappedFileConverter diff --git a/main/src/main/scala/sbt/internal/ClassLoaders.scala b/main/src/main/scala/sbt/internal/ClassLoaders.scala index 9849c26c4..476a581ae 100644 --- a/main/src/main/scala/sbt/internal/ClassLoaders.scala +++ b/main/src/main/scala/sbt/internal/ClassLoaders.scala @@ -14,7 +14,6 @@ import java.net.URL import java.nio.file.Path import sbt.ClassLoaderLayeringStrategy._ import sbt.Keys._ -import sbt.SlashSyntax0.given import sbt.internal.classpath.ClassLoaderCache import sbt.internal.inc.ScalaInstance import sbt.internal.inc.classpath.ClasspathUtil diff --git a/main/src/main/scala/sbt/internal/Clean.scala b/main/src/main/scala/sbt/internal/Clean.scala index 117132deb..54af4b7e9 100644 --- a/main/src/main/scala/sbt/internal/Clean.scala +++ b/main/src/main/scala/sbt/internal/Clean.scala @@ -17,7 +17,6 @@ import sbt.Keys._ // import sbt.Project.richInitializeTask import sbt.ProjectExtra.* import sbt.ScopeAxis.Zero -import sbt.SlashSyntax0.given import sbt.io.syntax._ import sbt.nio.Keys._ import sbt.nio.file._ @@ -162,7 +161,7 @@ private[sbt] object Clean { ): Def.Initialize[Task[Unit]] = (Def .task { - taskKey.scope / taskKey.key + taskKey.scope.rescope(taskKey.key) }) .flatMapTask { case scope => Def.task { diff --git a/main/src/main/scala/sbt/internal/Continuous.scala b/main/src/main/scala/sbt/internal/Continuous.scala index 4d0c0c6ce..3ce6d4289 100644 --- a/main/src/main/scala/sbt/internal/Continuous.scala +++ b/main/src/main/scala/sbt/internal/Continuous.scala @@ -24,7 +24,6 @@ import sbt.BasicCommandStrings._ import sbt.Def._ import sbt.Keys._ import sbt.ProjectExtra.extract -import sbt.SlashSyntax0.given import sbt.internal.Continuous.{ ContinuousState, FileStampRepository } import sbt.internal.LabeledFunctions._ import sbt.internal.io.WatchState diff --git a/main/src/main/scala/sbt/internal/CrossJava.scala b/main/src/main/scala/sbt/internal/CrossJava.scala index bfb206e13..244f137d1 100644 --- a/main/src/main/scala/sbt/internal/CrossJava.scala +++ b/main/src/main/scala/sbt/internal/CrossJava.scala @@ -19,7 +19,6 @@ import sbt.Cross._ import sbt.Def.{ ScopedKey, Setting } import sbt.ProjectExtra.extract import sbt.ScopeAxis.{ Select, Zero } -import sbt.SlashSyntax0.given import sbt.internal.util.complete.DefaultParsers._ import sbt.internal.util.AttributeKey import sbt.internal.util.complete.{ DefaultParsers, Parser } diff --git a/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala b/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala index dfb61a447..babc844cd 100644 --- a/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala +++ b/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala @@ -19,7 +19,6 @@ import java.util.concurrent.atomic.{ AtomicLong, AtomicReference } import sbt.Def.{ Classpath, ScopedKey, Setting } import sbt.ProjectExtra.extract import sbt.Scope.GlobalScope -import sbt.SlashSyntax0.given import sbt.internal.inc.classpath.ClasspathFilter import sbt.internal.util.{ Attributed, ManagedLogger } import sbt.io.syntax._ diff --git a/main/src/main/scala/sbt/internal/GlobalPlugin.scala b/main/src/main/scala/sbt/internal/GlobalPlugin.scala index 0fe096a8e..00aca3350 100644 --- a/main/src/main/scala/sbt/internal/GlobalPlugin.scala +++ b/main/src/main/scala/sbt/internal/GlobalPlugin.scala @@ -22,7 +22,7 @@ import Def.{ ScopedKey, Setting } import Keys._ import Configurations.{ Compile, Runtime } import sbt.ProjectExtra.{ extract, runUnloadHooks, setProject } -import sbt.SlashSyntax0.given +import sbt.SlashSyntax0.* import java.io.File import org.apache.ivy.core.module.{ descriptor, id } import descriptor.ModuleDescriptor, id.ModuleRevisionId diff --git a/main/src/main/scala/sbt/internal/IvyConsole.scala b/main/src/main/scala/sbt/internal/IvyConsole.scala index cbd45a7aa..09fc271d2 100644 --- a/main/src/main/scala/sbt/internal/IvyConsole.scala +++ b/main/src/main/scala/sbt/internal/IvyConsole.scala @@ -26,7 +26,7 @@ import Def.Setting import Keys._ import Scope.Global import sbt.ProjectExtra.{ extract, setProject } -import sbt.SlashSyntax0.given +import sbt.SlashSyntax0.* import sbt.io.IO import xsbti.HashedVirtualFileRef diff --git a/main/src/main/scala/sbt/internal/LintUnused.scala b/main/src/main/scala/sbt/internal/LintUnused.scala index 4ad806e4a..35945e901 100644 --- a/main/src/main/scala/sbt/internal/LintUnused.scala +++ b/main/src/main/scala/sbt/internal/LintUnused.scala @@ -14,7 +14,6 @@ import sbt.internal.util.{ FilePosition, NoPosition, SourcePosition } import java.io.File import ProjectExtra.{ extract, scopedKeyData } import Scope.Global -import sbt.SlashSyntax0.given import sbt.Def._ object LintUnused { diff --git a/main/src/main/scala/sbt/internal/Load.scala b/main/src/main/scala/sbt/internal/Load.scala index 6a56c09f0..02077b92f 100755 --- a/main/src/main/scala/sbt/internal/Load.scala +++ b/main/src/main/scala/sbt/internal/Load.scala @@ -16,7 +16,7 @@ import sbt.Project.inScope import sbt.ProjectExtra.{ prefixConfigs, setProject, showLoadingKey, structure } import sbt.Scope.GlobalScope import sbt.ScopeAxis.{ Select, Zero } -import sbt.SlashSyntax0.given +import sbt.SlashSyntax0.* import sbt.internal.BuildStreams._ import sbt.internal.inc.classpath.ClasspathUtil import sbt.internal.inc.{ MappedFileConverter, ScalaInstance, ZincLmUtil, ZincUtil } diff --git a/main/src/main/scala/sbt/internal/LogManager.scala b/main/src/main/scala/sbt/internal/LogManager.scala index 544f72689..b3446954e 100644 --- a/main/src/main/scala/sbt/internal/LogManager.scala +++ b/main/src/main/scala/sbt/internal/LogManager.scala @@ -14,7 +14,6 @@ import sbt.Keys._ import sbt.ProjectExtra.showContextKey import sbt.Scope.Global import sbt.ScopeAxis.{ Select, Zero } -import sbt.SlashSyntax0.given import sbt.internal.util.MainAppender._ import sbt.internal.util.{ Terminal => ITerminal, _ } import sbt.util.{ Level, Logger, LoggerContext } diff --git a/main/src/main/scala/sbt/internal/Script.scala b/main/src/main/scala/sbt/internal/Script.scala index c51bfa40d..80961ce2b 100644 --- a/main/src/main/scala/sbt/internal/Script.scala +++ b/main/src/main/scala/sbt/internal/Script.scala @@ -19,7 +19,7 @@ import EvaluateConfigurations.{ evaluateConfiguration => evaluate } import Configurations.Compile import Scope.Global import sbt.ProjectExtra.{ extract, setProject } -import sbt.SlashSyntax0.given +import sbt.SlashSyntax0.* import sbt.io.{ Hash, IO } diff --git a/main/src/main/scala/sbt/internal/SettingCompletions.scala b/main/src/main/scala/sbt/internal/SettingCompletions.scala index b4d5d00cc..f19264b17 100644 --- a/main/src/main/scala/sbt/internal/SettingCompletions.scala +++ b/main/src/main/scala/sbt/internal/SettingCompletions.scala @@ -17,7 +17,6 @@ import ProjectExtra.{ relation } import Def.{ ScopedKey, Setting } import Scope.Global import sbt.ScopeAxis.{ Select, This, Zero } -import sbt.SlashSyntax0.given import complete._ import DefaultParsers._ diff --git a/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala b/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala index f8954e163..e0b458686 100644 --- a/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala +++ b/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala @@ -14,7 +14,6 @@ import sbt.Keys._ // import sbt.Project.richInitializeTask import sbt.ProjectExtra.* import sbt.ScopeAxis.Zero -import sbt.SlashSyntax0.given import sbt.internal.io.Source import sbt.internal.nio.Globs import sbt.internal.util.complete.Parser diff --git a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala index 0d534dcd1..8346f8cbf 100644 --- a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala @@ -18,7 +18,6 @@ import sbt.Keys._ import sbt.ProjectExtra.* import sbt.ScopeFilter.Make._ import sbt.Scoped.richTaskSeq -import sbt.SlashSyntax0.given import sbt.StandardMain.exchange import sbt.internal.bsp._ import sbt.internal.langserver.ErrorCodes diff --git a/main/src/main/scala/sbt/internal/server/NetworkChannel.scala b/main/src/main/scala/sbt/internal/server/NetworkChannel.scala index 13cfb77cc..9c5344c07 100644 --- a/main/src/main/scala/sbt/internal/server/NetworkChannel.scala +++ b/main/src/main/scala/sbt/internal/server/NetworkChannel.scala @@ -23,7 +23,6 @@ import java.util.concurrent.atomic.{ AtomicBoolean, AtomicReference } import sbt.BasicCommandStrings.{ Shutdown, TerminateAction } import sbt.ProjectExtra.extract -import sbt.SlashSyntax0.given import sbt.internal.langserver.{ CancelRequestParams, ErrorCodes, LogMessageParams, MessageType } import sbt.internal.protocol.{ JsonRpcNotificationMessage, diff --git a/main/src/main/scala/sbt/nio/CheckBuildSources.scala b/main/src/main/scala/sbt/nio/CheckBuildSources.scala index a8cf3dabc..48332b438 100644 --- a/main/src/main/scala/sbt/nio/CheckBuildSources.scala +++ b/main/src/main/scala/sbt/nio/CheckBuildSources.scala @@ -15,7 +15,6 @@ import sbt.BasicCommandStrings.{ RebootCommand, Shutdown, TerminateAction } import sbt.Keys.{ baseDirectory, pollInterval, state } import sbt.ProjectExtra.extract import sbt.Scope.Global -import sbt.SlashSyntax0.given import sbt.internal.CommandStrings.LoadProject import sbt.internal.SysProp import sbt.internal.util.{ AttributeKey, Terminal } diff --git a/main/src/main/scala/sbt/nio/Settings.scala b/main/src/main/scala/sbt/nio/Settings.scala index 63e9634d5..9a1ca993f 100644 --- a/main/src/main/scala/sbt/nio/Settings.scala +++ b/main/src/main/scala/sbt/nio/Settings.scala @@ -14,7 +14,6 @@ import java.util.concurrent.ConcurrentHashMap import sbt.Keys._ import sbt.ScopeAxis.{ Select, Zero } -import sbt.SlashSyntax0.given import sbt.internal.Clean.ToSeqPath import sbt.internal.Continuous.FileStampRepository import sbt.internal.util.KeyTag