mirror of https://github.com/sbt/sbt.git
Migrate postfix ops
**Problem** There are a few places in the code that's using postfix ops. **Solution** This rewrites the expressions to use normal dot notaiton.
This commit is contained in:
parent
ecca26175e
commit
63ba90d198
|
|
@ -393,8 +393,7 @@ object Index {
|
||||||
case (k, xs) if xs.size > 1 => (k, xs)
|
case (k, xs) if xs.size > 1 => (k, xs)
|
||||||
}
|
}
|
||||||
.toVector
|
.toVector
|
||||||
if (duplicates.isEmpty)
|
if duplicates.isEmpty then multiMap.collect { case (k, v) if validID(k) => (k, v.head) }.toMap
|
||||||
multiMap.collect { case (k, v) if validID(k) => (k, v.head) } toMap
|
|
||||||
else
|
else
|
||||||
sys.error(
|
sys.error(
|
||||||
duplicates map { case (k, tps) =>
|
duplicates map { case (k, tps) =>
|
||||||
|
|
|
||||||
|
|
@ -408,9 +408,11 @@ object Scope {
|
||||||
projectInherit: ProjectRef => Seq[ProjectRef],
|
projectInherit: ProjectRef => Seq[ProjectRef],
|
||||||
configInherit: (ResolvedReference, ConfigKey) => Seq[ConfigKey]
|
configInherit: (ResolvedReference, ConfigKey) => Seq[ConfigKey]
|
||||||
): DelegateIndex = {
|
): DelegateIndex = {
|
||||||
val pDelegates = refs map { case (ref, project) =>
|
val pDelegates = refs
|
||||||
(ref, delegateIndex(ref, configurations(project))(projectInherit, configInherit))
|
.map:
|
||||||
} toMap;
|
case (ref, project) =>
|
||||||
|
(ref, delegateIndex(ref, configurations(project))(projectInherit, configInherit))
|
||||||
|
.toMap
|
||||||
new DelegateIndex0(pDelegates)
|
new DelegateIndex0(pDelegates)
|
||||||
}
|
}
|
||||||
private[this] def delegateIndex(ref: ProjectRef, confs: Seq[ConfigKey])(
|
private[this] def delegateIndex(ref: ProjectRef, confs: Seq[ConfigKey])(
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ object Cross {
|
||||||
private def crossRestoreSessionParser: Parser[String] = token(CrossRestoreSessionCommand)
|
private def crossRestoreSessionParser: Parser[String] = token(CrossRestoreSessionCommand)
|
||||||
|
|
||||||
private[sbt] def requireSession[T](p: State => Parser[T]): State => Parser[T] =
|
private[sbt] def requireSession[T](p: State => Parser[T]): State => Parser[T] =
|
||||||
s => if (s get sessionSettings isEmpty) failure("No project loaded") else p(s)
|
s => if s.get(sessionSettings).isEmpty then failure("No project loaded") else p(s)
|
||||||
|
|
||||||
private def resolveAggregates(extracted: Extracted): Seq[ProjectRef] = {
|
private def resolveAggregates(extracted: Extracted): Seq[ProjectRef] = {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2944,8 +2944,8 @@ object Classpaths {
|
||||||
unmanagedJars := findUnmanagedJars(
|
unmanagedJars := findUnmanagedJars(
|
||||||
configuration.value,
|
configuration.value,
|
||||||
unmanagedBase.value,
|
unmanagedBase.value,
|
||||||
(unmanagedJars / includeFilter) value,
|
(unmanagedJars / includeFilter).value,
|
||||||
(unmanagedJars / excludeFilter) value,
|
(unmanagedJars / excludeFilter).value,
|
||||||
fileConverter.value,
|
fileConverter.value,
|
||||||
)
|
)
|
||||||
).map(exportVirtualClasspath) ++ Seq(
|
).map(exportVirtualClasspath) ++ Seq(
|
||||||
|
|
@ -3606,7 +3606,7 @@ object Classpaths {
|
||||||
|
|
||||||
private[sbt] def defaultProjectID: Initialize[ModuleID] = Def.setting {
|
private[sbt] def defaultProjectID: Initialize[ModuleID] = Def.setting {
|
||||||
val p0 = ModuleID(organization.value, moduleName.value, version.value)
|
val p0 = ModuleID(organization.value, moduleName.value, version.value)
|
||||||
.cross((projectID / crossVersion) value)
|
.cross((projectID / crossVersion).value)
|
||||||
.artifacts(artifacts.value: _*)
|
.artifacts(artifacts.value: _*)
|
||||||
val p1 = apiURL.value match {
|
val p1 = apiURL.value match {
|
||||||
case Some(u) => p0.extra(SbtPomExtraProperties.POM_API_KEY -> u.toExternalForm)
|
case Some(u) => p0.extra(SbtPomExtraProperties.POM_API_KEY -> u.toExternalForm)
|
||||||
|
|
@ -4227,7 +4227,7 @@ object Classpaths {
|
||||||
(proj / ivyModule).get(data)
|
(proj / ivyModule).get(data)
|
||||||
}.join
|
}.join
|
||||||
ivyModules.mapN { mod =>
|
ivyModules.mapN { mod =>
|
||||||
mod map { _.dependencyMapping(log) } toMap;
|
mod.map { _.dependencyMapping(log) }.toMap
|
||||||
}
|
}
|
||||||
|
|
||||||
def projectResolverTask: Initialize[Task[Resolver]] =
|
def projectResolverTask: Initialize[Task[Resolver]] =
|
||||||
|
|
|
||||||
|
|
@ -304,11 +304,11 @@ trait ProjectExtra extends Scoped.Syntax:
|
||||||
val msg = (ref / Keys.onLoadMessage) get structure.data getOrElse ""
|
val msg = (ref / Keys.onLoadMessage) get structure.data getOrElse ""
|
||||||
if (!msg.isEmpty) s.log.info(msg)
|
if (!msg.isEmpty) s.log.info(msg)
|
||||||
def get[T](k: SettingKey[T]): Option[T] = (ref / k) get structure.data
|
def get[T](k: SettingKey[T]): Option[T] = (ref / k) get structure.data
|
||||||
def commandsIn(axis: ResolvedReference) = (axis / commands) get structure.data toList
|
def commandsIn(axis: ResolvedReference) = (axis / commands).get(structure.data).toList
|
||||||
|
|
||||||
val allCommands = commandsIn(ref) ++ commandsIn(
|
val allCommands = commandsIn(ref) ++ commandsIn(
|
||||||
BuildRef(ref.build)
|
BuildRef(ref.build)
|
||||||
) ++ ((Global / commands) get structure.data toList)
|
) ++ (Global / commands).get(structure.data).toList
|
||||||
val history = get(historyPath).flatMap(identity)
|
val history = get(historyPath).flatMap(identity)
|
||||||
val prompt = get(shellPrompt)
|
val prompt = get(shellPrompt)
|
||||||
val newPrompt = get(colorShellPrompt)
|
val newPrompt = get(colorShellPrompt)
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ object Resolvers {
|
||||||
if (Util.isNonCygwinWindows) "cmd" +: "/c" +: command
|
if (Util.isNonCygwinWindows) "cmd" +: "/c" +: command
|
||||||
else command,
|
else command,
|
||||||
cwd
|
cwd
|
||||||
) !;
|
).!
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
sys.error("Nonzero exit code (" + result + "): " + command.mkString(" "))
|
sys.error("Nonzero exit code (" + result + "): " + command.mkString(" "))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ object ScriptedPlugin extends AutoPlugin {
|
||||||
sys.props(org.apache.logging.log4j.util.LoaderUtil.IGNORE_TCCL_PROPERTY) = "true"
|
sys.props(org.apache.logging.log4j.util.LoaderUtil.IGNORE_TCCL_PROPERTY) = "true"
|
||||||
|
|
||||||
object autoImport {
|
object autoImport {
|
||||||
val ScriptedConf = Configurations.config("scripted-sbt") hide
|
val ScriptedConf = Configurations.config("scripted-sbt").hide
|
||||||
val ScriptedLaunchConf = Configurations.config("scripted-sbt-launch") hide
|
val ScriptedLaunchConf = Configurations.config("scripted-sbt-launch").hide
|
||||||
|
|
||||||
val scriptedSbt = settingKey[String]("")
|
val scriptedSbt = settingKey[String]("")
|
||||||
val sbtLauncher = taskKey[File]("")
|
val sbtLauncher = taskKey[File]("")
|
||||||
|
|
|
||||||
|
|
@ -596,7 +596,7 @@ object Act {
|
||||||
else data.get(scope, key)
|
else data.get(scope, key)
|
||||||
|
|
||||||
def requireSession[T](s: State, p: => Parser[T]): Parser[T] =
|
def requireSession[T](s: State, p: => Parser[T]): Parser[T] =
|
||||||
if (s get sessionSettings isEmpty) failure("No project loaded") else p
|
if s.get(sessionSettings).isEmpty then failure("No project loaded") else p
|
||||||
|
|
||||||
sealed trait ParsedAxis[+T] {
|
sealed trait ParsedAxis[+T] {
|
||||||
final def isExplicit = this != Omitted
|
final def isExplicit = this != Omitted
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,8 @@ object Aggregation {
|
||||||
|
|
||||||
val extracted = Project extract s
|
val extracted = Project extract s
|
||||||
import extracted.structure
|
import extracted.structure
|
||||||
val toRun = ts map { case KeyValue(k, t) => t.map(v => KeyValue(k, v)) } join;
|
val toRun = ts.map { case KeyValue(k, t) => t.map(v => KeyValue(k, v)) }.join
|
||||||
val roots = ts map { case KeyValue(k, _) => k }
|
val roots = ts.map { case KeyValue(k, _) => k }
|
||||||
val config = extractedTaskConfig(extracted, structure, s)
|
val config = extractedTaskConfig(extracted, structure, s)
|
||||||
|
|
||||||
val start = System.currentTimeMillis
|
val start = System.currentTimeMillis
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ private[sbt] object ClasspathImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
def union[A, B](maps: Seq[A => Seq[B]]): A => Seq[B] =
|
def union[A, B](maps: Seq[A => Seq[B]]): A => Seq[B] =
|
||||||
a => maps.foldLeft(Seq[B]()) { _ ++ _(a) } distinct;
|
a => maps.foldLeft(Seq[B]()) { _ ++ _(a) }.distinct
|
||||||
|
|
||||||
def parseList(s: String, allConfs: Seq[String]): Seq[String] =
|
def parseList(s: String, allConfs: Seq[String]): Seq[String] =
|
||||||
(trim(s split ",") flatMap replaceWildcard(allConfs)).distinct
|
(trim(s split ",") flatMap replaceWildcard(allConfs)).distinct
|
||||||
|
|
|
||||||
|
|
@ -1466,9 +1466,10 @@ private[sbt] object Load {
|
||||||
def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = {
|
def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = {
|
||||||
val session = s get Keys.sessionSettings
|
val session = s get Keys.sessionSettings
|
||||||
val currentProject = session map (_.currentProject) getOrElse Map.empty
|
val currentProject = session map (_.currentProject) getOrElse Map.empty
|
||||||
val currentBuild = session map (_.currentBuild) filter (uri =>
|
val currentBuild = session
|
||||||
structure.units.keys exists (uri ==)
|
.map(_.currentBuild)
|
||||||
) getOrElse structure.root
|
.filter(uri => structure.units.keys.exists(uri == _))
|
||||||
|
.getOrElse(structure.root)
|
||||||
new SessionSettings(
|
new SessionSettings(
|
||||||
currentBuild,
|
currentBuild,
|
||||||
projectMap(structure, currentProject),
|
projectMap(structure, currentProject),
|
||||||
|
|
|
||||||
|
|
@ -183,9 +183,9 @@ object PluginDiscovery:
|
||||||
|
|
||||||
private[this] def incompatiblePlugins(data: PluginData, t: LinkageError): Nothing = {
|
private[this] def incompatiblePlugins(data: PluginData, t: LinkageError): Nothing = {
|
||||||
val evicted = data.report.toList.flatMap(_.configurations.flatMap(_.evicted))
|
val evicted = data.report.toList.flatMap(_.configurations.flatMap(_.evicted))
|
||||||
val evictedModules = evicted map { id =>
|
val evictedModules = evicted.map { id =>
|
||||||
(id.organization, id.name)
|
(id.organization, id.name)
|
||||||
} distinct;
|
}.distinct
|
||||||
val evictedStrings = evictedModules map { case (o, n) => o + ":" + n }
|
val evictedStrings = evictedModules map { case (o, n) => o + ":" + n }
|
||||||
val msgBase = "Binary incompatibility in plugins detected."
|
val msgBase = "Binary incompatibility in plugins detected."
|
||||||
val msgExtra =
|
val msgExtra =
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ private[sbt] object PluginsDebug {
|
||||||
|
|
||||||
private[this] def includeAll[T <: Basic](basic: Set[T]): Plugins = And(basic.toList)
|
private[this] def includeAll[T <: Basic](basic: Set[T]): Plugins = And(basic.toList)
|
||||||
private[this] def excludeAll(plugins: Set[AutoPlugin]): Plugins =
|
private[this] def excludeAll(plugins: Set[AutoPlugin]): Plugins =
|
||||||
And(plugins map (p => Exclude(p)) toList)
|
And(plugins.map(p => Exclude(p)).toList)
|
||||||
|
|
||||||
private[this] def excludes(bs: Seq[Basic]): Set[AutoPlugin] =
|
private[this] def excludes(bs: Seq[Basic]): Set[AutoPlugin] =
|
||||||
bs.collect { case Exclude(b) => b }.toSet
|
bs.collect { case Exclude(b) => b }.toSet
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import sbt.ProjectExtra.{ extract, updateCurrent }
|
||||||
|
|
||||||
object ProjectNavigation {
|
object ProjectNavigation {
|
||||||
def command(s: State): Parser[() => State] =
|
def command(s: State): Parser[() => State] =
|
||||||
if (s get sessionSettings isEmpty) failure("No project loaded")
|
if s.get(sessionSettings).isEmpty then failure("No project loaded")
|
||||||
else (new ProjectNavigation(s)).command
|
else (new ProjectNavigation(s)).command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -866,8 +866,8 @@ object BuildServerProtocol {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val jsonParser: Parser[JValue] = (Parsers.any *).map(_.mkString)
|
private val jsonParser: Parser[JValue] = (Parsers.any.*).map(_.mkString)
|
||||||
.map(JsonParser.parseUnsafe)
|
.map(JsonParser.parseUnsafe)
|
||||||
|
|
||||||
private def bspRunTask: Def.Initialize[InputTask[Unit]] =
|
private def bspRunTask: Def.Initialize[InputTask[Unit]] =
|
||||||
Def.input((s: State) => jsonParser).flatMapTask { json =>
|
Def.input((s: State) => jsonParser).flatMapTask { json =>
|
||||||
|
|
|
||||||
|
|
@ -189,9 +189,7 @@ abstract class TestBuild {
|
||||||
}
|
}
|
||||||
|
|
||||||
def mapBy[K, T](s: Seq[T])(f: T => K): Map[K, T] =
|
def mapBy[K, T](s: Seq[T])(f: T => K): Map[K, T] =
|
||||||
s map { t =>
|
s.map(t => (f(t), t)).toMap
|
||||||
(f(t), t)
|
|
||||||
} toMap;
|
|
||||||
|
|
||||||
lazy val keysGen: Gen[TestKeys] =
|
lazy val keysGen: Gen[TestKeys] =
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
|
|
@ -9,28 +9,28 @@ object HouseRulesPlugin extends AutoPlugin {
|
||||||
|
|
||||||
lazy val baseSettings: Seq[Def.Setting[_]] = Seq(
|
lazy val baseSettings: Seq[Def.Setting[_]] = Seq(
|
||||||
scalacOptions ++= Seq("-encoding", "utf8"),
|
scalacOptions ++= Seq("-encoding", "utf8"),
|
||||||
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xlint"),
|
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked"),
|
||||||
scalacOptions += "-language:higherKinds",
|
scalacOptions += "-language:higherKinds",
|
||||||
scalacOptions += "-language:implicitConversions",
|
scalacOptions += "-language:implicitConversions",
|
||||||
scalacOptions ++= "-Xfuture".ifScala213OrMinus.value.toList,
|
scalacOptions ++= "-Xfuture".ifScala213OrMinus.value.toList,
|
||||||
scalacOptions += "-Xlint",
|
scalacOptions ++= "-Xlint".ifScala2.value.toList,
|
||||||
|
// TODO: uncomment once we can build without warnings on Scala 3
|
||||||
// scalacOptions ++= "-Xfatal-warnings"
|
// scalacOptions ++= "-Xfatal-warnings"
|
||||||
// .ifScala(v => {
|
// .ifScala3x(_ => {
|
||||||
// sys.props.get("sbt.build.fatal") match {
|
// sys.props.get("sbt.build.fatal") match {
|
||||||
// case Some(_) => java.lang.Boolean.getBoolean("sbt.build.fatal")
|
// case Some(_) => java.lang.Boolean.getBoolean("sbt.build.fatal")
|
||||||
// case _ => v == 12
|
// case _ => true
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// .value
|
// .value
|
||||||
// .toList,
|
// .toList,
|
||||||
scalacOptions ++= "-Ykind-projector".ifScala3.value.toList,
|
scalacOptions ++= "-Ykind-projector".ifScala3.value.toList,
|
||||||
scalacOptions ++= "-Ysemanticdb".ifScala3.value.toList,
|
|
||||||
scalacOptions ++= "-Yinline-warnings".ifScala211OrMinus.value.toList,
|
scalacOptions ++= "-Yinline-warnings".ifScala211OrMinus.value.toList,
|
||||||
scalacOptions ++= "-Yno-adapted-args".ifScala212OrMinus.value.toList,
|
scalacOptions ++= "-Yno-adapted-args".ifScala212OrMinus.value.toList,
|
||||||
scalacOptions += "-Ywarn-dead-code",
|
scalacOptions ++= "-Ywarn-dead-code".ifScala2.value.toList,
|
||||||
scalacOptions += "-Ywarn-numeric-widen",
|
scalacOptions ++= "-Ywarn-numeric-widen".ifScala2.value.toList,
|
||||||
scalacOptions += "-Ywarn-value-discard",
|
scalacOptions ++= "-Ywarn-value-discard".ifScala2.value.toList,
|
||||||
scalacOptions ++= "-Ywarn-unused-import".ifScala(v => 11 <= v && v <= 12).value.toList
|
scalacOptions ++= "-Ywarn-unused-import".ifScala2x(v => 11 <= v && v <= 12).value.toList
|
||||||
) ++ Seq(Compile, Test).flatMap(c =>
|
) ++ Seq(Compile, Test).flatMap(c =>
|
||||||
(c / console / scalacOptions) --= Seq("-Ywarn-unused-import", "-Xlint")
|
(c / console / scalacOptions) --= Seq("-Ywarn-unused-import", "-Xlint")
|
||||||
)
|
)
|
||||||
|
|
@ -38,14 +38,17 @@ object HouseRulesPlugin extends AutoPlugin {
|
||||||
private def scalaPartV = Def setting (CrossVersion partialVersion scalaVersion.value)
|
private def scalaPartV = Def setting (CrossVersion partialVersion scalaVersion.value)
|
||||||
|
|
||||||
private implicit final class AnyWithIfScala[A](val __x: A) {
|
private implicit final class AnyWithIfScala[A](val __x: A) {
|
||||||
def ifScala(p: Long => Boolean) =
|
def ifScala2x(p: Long => Boolean) =
|
||||||
Def setting (scalaPartV.value collect { case (2, y) if p(y) => __x })
|
Def.setting(scalaPartV.value collect { case (2, y) if p(y) => __x })
|
||||||
def ifScalaLte(v: Long) = ifScala(_ <= v)
|
def ifScala3x(p: Long => Boolean) =
|
||||||
def ifScalaGte(v: Long) = ifScala(_ >= v)
|
Def.setting(scalaPartV.value collect { case (3, y) if p(y) => __x })
|
||||||
|
def ifScalaLte(v: Long) = ifScala2x(_ <= v)
|
||||||
|
def ifScalaGte(v: Long) = ifScala2x(_ >= v)
|
||||||
def ifScala211OrMinus = ifScalaLte(11)
|
def ifScala211OrMinus = ifScalaLte(11)
|
||||||
def ifScala211OrPlus = ifScalaGte(11)
|
def ifScala211OrPlus = ifScalaGte(11)
|
||||||
def ifScala212OrMinus = ifScalaLte(12)
|
def ifScala212OrMinus = ifScalaLte(12)
|
||||||
def ifScala213OrMinus = ifScalaLte(13)
|
def ifScala213OrMinus = ifScalaLte(13)
|
||||||
|
def ifScala2 = ifScala2x(_ => true)
|
||||||
def ifScala3 = Def.setting(
|
def ifScala3 = Def.setting(
|
||||||
if (scalaBinaryVersion.value == "3") Seq(__x)
|
if (scalaBinaryVersion.value == "3") Seq(__x)
|
||||||
else Nil
|
else Nil
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,6 @@ object Util {
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val baseScalacOptions = Seq(
|
lazy val baseScalacOptions = Seq(
|
||||||
scalacOptions ++= Seq(
|
|
||||||
"-Xelide-below",
|
|
||||||
"0",
|
|
||||||
"-language:existentials",
|
|
||||||
"-language:postfixOps",
|
|
||||||
"-Yrangepos",
|
|
||||||
"-Wconf:cat=unused-nowarn:s",
|
|
||||||
),
|
|
||||||
Compile / doc / scalacOptions -= "-Xlint",
|
Compile / doc / scalacOptions -= "-Xlint",
|
||||||
Compile / doc / scalacOptions -= "-Xfatal-warnings",
|
Compile / doc / scalacOptions -= "-Xfatal-warnings",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue