mirror of https://github.com/sbt/sbt.git
Merge pull request #8183 from eed3si9n/wip/cleanup
[2.x] Remove unused code
This commit is contained in:
commit
c8fa434eb3
|
|
@ -20,21 +20,6 @@ object Inputs {
|
|||
configurations
|
||||
.map(cfg => Configuration(cfg.name) -> cfg.extendsConfigs.map(c => Configuration(c.name)))
|
||||
|
||||
@deprecated("Now unused internally, to be removed in the future", "2.0.0-RC6-5")
|
||||
def configExtends(
|
||||
configurations: Seq[sbt.librarymanagement.Configuration]
|
||||
): Map[Configuration, Seq[Configuration]] =
|
||||
configurations
|
||||
.map(cfg => Configuration(cfg.name) -> cfg.extendsConfigs.map(c => Configuration(c.name)))
|
||||
.toMap
|
||||
|
||||
@deprecated("Use coursierConfigurationsMap instead", "2.0.0-RC6-5")
|
||||
def coursierConfigurations(
|
||||
configurations: Seq[sbt.librarymanagement.Configuration],
|
||||
shadedConfigOpt: Option[String] = None
|
||||
): Map[Configuration, Set[Configuration]] =
|
||||
coursierConfigurationsMap(configurations)
|
||||
|
||||
def coursierConfigurationsMap(
|
||||
configurations: Seq[sbt.librarymanagement.Configuration]
|
||||
): Map[Configuration, Set[Configuration]] = {
|
||||
|
|
|
|||
|
|
@ -43,9 +43,6 @@ trait BuildSyntax:
|
|||
extension [A1](inline in: Task[A1])
|
||||
inline def value: A1 = std.InputWrapper.`wrapTask_\u2603\u2603`[A1](in)
|
||||
|
||||
// implicit def macroValueIn[T](@deprecated("unused", "") in: InputTask[T]): std.InputEvaluated[T] =
|
||||
// ???
|
||||
|
||||
extension [A1](inline in: Parser[A1])
|
||||
inline def parsed: A1 = ParserInput.`parser_\u2603\u2603`[A1](Def.toSParser(in))
|
||||
|
||||
|
|
@ -377,8 +374,6 @@ object Def extends BuildSyntax with Init with InitializeImplicits:
|
|||
// The following conversions enable the types Initialize[T], Initialize[Task[T]], and Task[T] to
|
||||
// be used in task and setting macros as inputs with an ultimate result of type T
|
||||
|
||||
// implicit def macroValueI[T](@deprecated("unused", "") in: Initialize[T]): MacroValue[T] = ???
|
||||
|
||||
extension [A1](inline in: Initialize[A1])
|
||||
inline def value: A1 = InputWrapper.`wrapInit_\u2603\u2603`[A1](in)
|
||||
|
||||
|
|
@ -392,10 +387,6 @@ object Def extends BuildSyntax with Init with InitializeImplicits:
|
|||
*/
|
||||
inline def taskValue: Task[A1] = InputWrapper.`wrapInit_\u2603\u2603`[Task[A1]](in)
|
||||
|
||||
// implicit def macroValueIInT[T](
|
||||
// @deprecated("unused", "") in: Initialize[InputTask[T]]
|
||||
// ): InputEvaluated[T] = ???
|
||||
|
||||
inline def flatMapTask[A2](f: A1 => Initialize[Task[A2]]): Initialize[Task[A2]] =
|
||||
std.FullInstance.initializeTaskMonad.flatMap(in)(f)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,43 +35,8 @@ final class InputTask[A1] private (val parser: State => Parser[Task[A1]]):
|
|||
end InputTask
|
||||
|
||||
object InputTask:
|
||||
/*
|
||||
implicit class InitializeInput[T](i: Initialize[InputTask[T]]) {
|
||||
def partialInput(in: String): Initialize[InputTask[T]] = i(_ partialInput in)
|
||||
def fullInput(in: String): Initialize[InputTask[T]] = i(_ fullInput in)
|
||||
|
||||
import std.FullInstance._
|
||||
def toTask(in: String): Initialize[Task[T]] = flatten(
|
||||
(Def.stateKey zipWith i)((sTask, it) =>
|
||||
sTask map (s =>
|
||||
Parser.parse(in, it.parser(s)) match {
|
||||
case Right(t) => Def.value(t)
|
||||
case Left(msg) =>
|
||||
val indented = msg.linesIterator.map(" " + _).mkString("\n")
|
||||
sys.error(s"Invalid programmatic input:\n$indented")
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
implicit def inputTaskParsed[T](
|
||||
@deprecated("unused", "") in: InputTask[T]
|
||||
): std.ParserInputTask[T] = ???
|
||||
|
||||
implicit def inputTaskInitParsed[T](
|
||||
@deprecated("unused", "") in: Initialize[InputTask[T]]
|
||||
): std.ParserInputTask[T] = ???
|
||||
*/
|
||||
|
||||
def make[A1](p: State => Parser[Task[A1]]): InputTask[A1] = new InputTask[A1](p)
|
||||
|
||||
/*
|
||||
def static[T](p: Parser[Task[T]]): InputTask[T] = free(_ => p)
|
||||
|
||||
def static[I, T](p: Parser[I])(c: I => Task[T]): InputTask[T] = static(p map c)
|
||||
*/
|
||||
|
||||
def free[A1](p: State => Parser[Task[A1]]): InputTask[A1] = make(p)
|
||||
|
||||
def free[A1, A2](p: State => Parser[A1])(c: A1 => Task[A2]): InputTask[A2] =
|
||||
|
|
@ -110,80 +75,6 @@ object InputTask:
|
|||
def emptyParser: State => Parser[Unit] =
|
||||
Types.const(sbt.internal.util.complete.DefaultParsers.success(()))
|
||||
|
||||
/*
|
||||
/** Implementation detail that is public because it is used by a macro. */
|
||||
def parserAsInput[T](p: Parser[T]): Initialize[State => Parser[T]] =
|
||||
Def.valueStrict(Types.const(p))
|
||||
|
||||
/** Implementation detail that is public because it is used by a macro. */
|
||||
def initParserAsInput[T](i: Initialize[Parser[T]]): Initialize[State => Parser[T]] =
|
||||
i(Types.const[State, Parser[T]])
|
||||
|
||||
@deprecated("Use another InputTask constructor or the `Def.inputTask` macro.", "0.13.0")
|
||||
def apply[I, T](
|
||||
p: Initialize[State => Parser[I]]
|
||||
)(action: TaskKey[I] => Initialize[Task[T]]): Initialize[InputTask[T]] = {
|
||||
val dummyKey = localKey[Task[I]]
|
||||
val (marker, dummy) = dummyTask[I]
|
||||
val it = action(TaskKey(dummyKey)) mapConstant subResultForDummy(dummyKey, dummy)
|
||||
val act = it { tsk => (value: I) =>
|
||||
subForDummy(marker, value, tsk)
|
||||
}
|
||||
separate(p)(act)
|
||||
}
|
||||
|
||||
/**
|
||||
* The proper solution is to have a Manifest context bound and accept slight source incompatibility,
|
||||
* The affected InputTask construction methods are all deprecated and so it is better to keep complete
|
||||
* compatibility. Because the AttributeKey is local, it uses object equality and the manifest is not used.
|
||||
*/
|
||||
private def localKey[T]: AttributeKey[T] =
|
||||
AttributeKey.local[Unit].asInstanceOf[AttributeKey[T]]
|
||||
|
||||
private def subResultForDummy[I](dummyKey: AttributeKey[Task[I]], dummyTask: Task[I]) =
|
||||
new (ScopedKey ~> Option) {
|
||||
def apply[T](sk: ScopedKey[T]) =
|
||||
if (sk.key eq dummyKey) {
|
||||
// sk.key: AttributeKey[T], dummy.key: AttributeKey[Task[I]]
|
||||
// (sk.key eq dummy.key) ==> T == Task[I] because AttributeKey is invariant
|
||||
Some(dummyTask.asInstanceOf[T])
|
||||
} else
|
||||
None
|
||||
}
|
||||
|
||||
private def dummyTask[I]: (AttributeKey[Option[I]], Task[I]) = {
|
||||
val key = localKey[Option[I]]
|
||||
val f: () => I = () =>
|
||||
sys.error(s"Internal sbt error: InputTask stub was not substituted properly.")
|
||||
val t: Task[I] = Task(Info[I]().set(key, none), Pure(f, false))
|
||||
(key, t)
|
||||
}
|
||||
|
||||
private def subForDummy[I, T](
|
||||
marker: AttributeKey[Option[I]],
|
||||
value: I,
|
||||
task: Task[T]
|
||||
): Task[T] = {
|
||||
val seen = new java.util.IdentityHashMap[Task[_], Task[_]]
|
||||
lazy val f: Task ~> Task = new (Task ~> Task) {
|
||||
def apply[A](t: Task[A]): Task[A] = {
|
||||
val t0 = seen.get(t)
|
||||
if (t0 == null) {
|
||||
val newAction =
|
||||
if (t.info.get(marker).isDefined)
|
||||
(Pure[A](() => value.asInstanceOf[A], inline = true): Action[A])
|
||||
else
|
||||
t.work.mapTask(f)
|
||||
val newTask = Task(t.info, newAction)
|
||||
seen.put(t, newTask)
|
||||
newTask
|
||||
} else t0.asInstanceOf[Task[A]]
|
||||
}
|
||||
}
|
||||
f(task)
|
||||
}
|
||||
*/
|
||||
|
||||
given inputTaskApplicative: Applicative[InputTask] with
|
||||
type F[a] = InputTask[a]
|
||||
override def pure[A1](a: () => A1): InputTask[A1] = InputTask.createFreeFromAction(a)
|
||||
|
|
|
|||
|
|
@ -71,140 +71,8 @@ object InputWrapper:
|
|||
private def implDetailError =
|
||||
sys.error("This method is an implementation detail and should not be referenced.")
|
||||
|
||||
/*
|
||||
private[std] def wrapInitInputTask[T: c.WeakTypeTag](using qctx: Quotes)(
|
||||
ts: c.Expr[Any],
|
||||
pos: c.Position
|
||||
): c.Expr[T] =
|
||||
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInitInputName)(ts, pos)
|
||||
|
||||
private[std] def wrapInputTask[T: c.WeakTypeTag](using qctx: Quotes)(
|
||||
ts: c.Expr[Any],
|
||||
pos: c.Position
|
||||
): c.Expr[T] =
|
||||
wrapImpl[T, InputWrapper.type](c, InputWrapper, WrapInputName)(ts, pos)
|
||||
|
||||
private[std] def wrapPrevious[T: c.WeakTypeTag](using qctx: Quotes)(
|
||||
ts: c.Expr[Any],
|
||||
pos: c.Position
|
||||
): c.Expr[Option[T]] =
|
||||
wrapImpl[Option[T], InputWrapper.type](c, InputWrapper, WrapPreviousName)(ts, pos)
|
||||
|
||||
/**
|
||||
* Wraps an arbitrary Tree in a call to the `<s>.<wrapName>` method of this module for later processing by an enclosing macro.
|
||||
* The resulting Tree is the manually constructed version of:
|
||||
*
|
||||
* `c.universe.reify { <s>.<wrapName>[T](ts.splice) }`
|
||||
*/
|
||||
def wrapImpl[T: c.WeakTypeTag, S <: AnyRef with Singleton](
|
||||
using qctx: Quotes,
|
||||
s: S,
|
||||
wrapName: String
|
||||
)(ts: c.Expr[Any], pos: c.Position)(implicit it: c.TypeTag[s.type]): c.Expr[T] = {
|
||||
import c.universe.{ Apply => ApplyTree, _ }
|
||||
import internal.decorators._
|
||||
val util = new ContextUtil[c.type](c)
|
||||
val iw = util.singleton(s)
|
||||
val tpe = c.weakTypeOf[T]
|
||||
val nme = TermName(wrapName).encodedName
|
||||
val sel = Select(Ident(iw), nme)
|
||||
sel.setPos(
|
||||
pos
|
||||
) // need to set the position on Select, because that is where the compileTimeOnly check looks
|
||||
val tree = ApplyTree(TypeApply(sel, TypeTree(tpe) :: Nil), ts.tree :: Nil)
|
||||
tree.setPos(ts.tree.pos)
|
||||
// JZ: I'm not sure why we need to do this. Presumably a caller is wrapping this tree in a
|
||||
// typed tree *before* handing the whole thing back to the macro engine. One must never splice
|
||||
// untyped trees under typed trees, as the type checker doesn't descend if `tree.tpe == null`.
|
||||
//
|
||||
// #1031 The previous attempt to fix this just set the type on `tree`, which worked in cases when the
|
||||
// call to `.value` was inside a task macro and eliminated before the end of the typer phase.
|
||||
// But, if a "naked" call to `.value` left the typer, the superaccessors phase would freak out when
|
||||
// if hit the untyped trees, before we could get to refchecks and the desired @compileTimeOnly warning.
|
||||
val typedTree = c.typecheck(tree)
|
||||
c.Expr[T](typedTree)
|
||||
}
|
||||
|
||||
def valueMacroImpl[A1: Type](using qctx: Quotes): Expr[A1] =
|
||||
ContextUtil.selectMacroImpl[A1](c) { (ts, pos) =>
|
||||
ts.tree.tpe match {
|
||||
case tpe if tpe <:< c.weakTypeOf[Initialize[T]] =>
|
||||
if (c.weakTypeOf[T] <:< c.weakTypeOf[InputTask[_]]) {
|
||||
c.abort(
|
||||
pos,
|
||||
"""`value` is removed from input tasks. Use `evaluated` or `inputTaskValue`.
|
||||
|See https://www.scala-sbt.org/1.x/docs/Input-Tasks.html for more details.""".stripMargin
|
||||
)
|
||||
}
|
||||
InputWrapper.wrapInit[A1](c)(ts, pos)
|
||||
case tpe if tpe <:< c.weakTypeOf[Initialize[Task[T]]] =>
|
||||
InputWrapper.wrapInitTask[A1](c)(ts, pos)
|
||||
case tpe if tpe <:< c.weakTypeOf[Task[T]] => InputWrapper.wrapTask[T](c)(ts, pos)
|
||||
case tpe if tpe <:< c.weakTypeOf[InputTask[T]] => InputWrapper.wrapInputTask[T](c)(ts, pos)
|
||||
case tpe if tpe <:< c.weakTypeOf[Initialize[InputTask[T]]] =>
|
||||
InputWrapper.wrapInitInputTask[A1](c)(ts, pos)
|
||||
case tpe => unexpectedType(c)(pos, tpe)
|
||||
}
|
||||
}
|
||||
|
||||
def inputTaskValueMacroImpl[T: c.WeakTypeTag](using qctx: Quotes): c.Expr[InputTask[T]] =
|
||||
ContextUtil.selectMacroImpl[InputTask[T]](c) { (ts, pos) =>
|
||||
InputWrapper.wrapInit[InputTask[T]](c)(ts, pos)
|
||||
}
|
||||
def taskValueMacroImpl[T: c.WeakTypeTag](using qctx: Quotes): c.Expr[Task[T]] =
|
||||
ContextUtil.selectMacroImpl[Task[T]](c) { (ts, pos) =>
|
||||
val tpe = ts.tree.tpe
|
||||
if (tpe <:< c.weakTypeOf[Initialize[Task[T]]])
|
||||
InputWrapper.wrapInit[Task[T]](c)(ts, pos)
|
||||
else
|
||||
unexpectedType(c)(pos, tpe)
|
||||
}
|
||||
|
||||
private def unexpectedType(using qctx: Quotes)(pos: c.Position, tpe: c.Type) =
|
||||
c.abort(pos, s"Internal sbt error. Unexpected type ${tpe.widen}")
|
||||
*/
|
||||
end InputWrapper
|
||||
|
||||
/*
|
||||
sealed abstract class MacroTaskValue[T] {
|
||||
@compileTimeOnly(
|
||||
"`taskValue` can only be used within a setting macro, such as :=, +=, ++=, or Def.setting."
|
||||
)
|
||||
def taskValue: Task[T] = macro InputWrapper.taskValueMacroImpl[T]
|
||||
}
|
||||
|
||||
sealed abstract class MacroValue[A1] {
|
||||
@compileTimeOnly(
|
||||
"`value` can only be used within a task or setting macro, such as :=, +=, ++=, Def.task, or Def.setting."
|
||||
)
|
||||
def value: A1 = macro InputWrapper.valueMacroImpl[A1]
|
||||
}
|
||||
|
||||
sealed abstract class InputEvaluated[T] {
|
||||
@compileTimeOnly(
|
||||
"`evaluated` can only be used within an input task macro, such as := or Def.inputTask."
|
||||
)
|
||||
def evaluated: T = macro InputWrapper.valueMacroImpl[T]
|
||||
@compileTimeOnly(
|
||||
"`inputTaskValue` can only be used within an input task macro, such as := or Def.inputTask."
|
||||
)
|
||||
def inputTaskValue: InputTask[T] = macro InputWrapper.inputTaskValueMacroImpl[T]
|
||||
}
|
||||
sealed abstract class ParserInputTask[T] {
|
||||
@compileTimeOnly(
|
||||
"`parsed` can only be used within an input task macro, such as := or Def.inputTask."
|
||||
)
|
||||
def parsed: Task[T] = macro ParserInput.parsedInputMacroImpl[T]
|
||||
}
|
||||
sealed abstract class MacroPrevious[T] {
|
||||
// @compileTimeOnly(
|
||||
// "`previous` can only be used within a task macro, such as :=, +=, ++=, or Def.task."
|
||||
// )
|
||||
// def previous(implicit format: sjsonnew.JsonFormat[T]): Option[T] =
|
||||
// macro InputWrapper.previousMacroImpl[T]
|
||||
}
|
||||
*/
|
||||
|
||||
/** Implementation detail. The wrap method temporarily holds the input parser (as a Tree, at compile time) until the input task macro processes it. */
|
||||
object ParserInput:
|
||||
/* The name of the wrapper method should be obscure.
|
||||
|
|
@ -225,64 +93,4 @@ object ParserInput:
|
|||
def `initParser_\u2603\u2603`[T](@deprecated("unused", "") i: Any): T =
|
||||
sys.error("This method is an implementation detail and should not be referenced.")
|
||||
|
||||
/*
|
||||
private[std] def inputParser[T: c.WeakTypeTag](
|
||||
using qctx: Quotes
|
||||
)(t: c.Expr[InputTask[T]]): c.Expr[State => Parser[Task[T]]] =
|
||||
c.universe.reify(t.splice.parser)
|
||||
|
||||
def parsedInputMacroImpl[T: c.WeakTypeTag](using qctx: Quotes): c.Expr[Task[T]] =
|
||||
ContextUtil.selectMacroImpl[Task[T]](c) { (p, pos) =>
|
||||
p.tree.tpe match {
|
||||
case tpe if tpe <:< c.weakTypeOf[InputTask[T]] => wrapInputTask[T](c)(p.tree, pos)
|
||||
case tpe if tpe <:< c.weakTypeOf[Initialize[InputTask[T]]] =>
|
||||
wrapInitInputTask[T](c)(p.tree, pos)
|
||||
case tpe => unexpectedType(c)(pos, tpe, "parsedInputMacroImpl")
|
||||
}
|
||||
}
|
||||
|
||||
private def wrapInputTask[T: c.WeakTypeTag](
|
||||
using qctx: Quotes
|
||||
)(tree: c.Tree, pos: c.Position) = {
|
||||
val e = c.Expr[InputTask[T]](tree)
|
||||
wrap[Task[T]](c)(inputParser(c)(e), pos)
|
||||
}
|
||||
|
||||
private def wrapInitInputTask[T: c.WeakTypeTag](
|
||||
using qctx: Quotes
|
||||
)(tree: c.Tree, pos: c.Position) = {
|
||||
val e = c.Expr[Initialize[InputTask[T]]](tree)
|
||||
wrapInit[Task[T]](c)(c.universe.reify { Def.toIParser(e.splice) }, pos)
|
||||
}
|
||||
|
||||
/** Implements `Parser[T].parsed` by wrapping the Parser with the ParserInput wrapper. */
|
||||
def parsedMacroImpl[T: c.WeakTypeTag](using qctx: Quotes): c.Expr[T] =
|
||||
ContextUtil.selectMacroImpl[T](c) { (p, pos) =>
|
||||
p.tree.tpe match {
|
||||
case tpe if tpe <:< c.weakTypeOf[Parser[T]] => wrapParser[T](c)(p.tree, pos)
|
||||
case tpe if tpe <:< c.weakTypeOf[State => Parser[T]] => wrap[T](c)(p, pos)
|
||||
case tpe if tpe <:< c.weakTypeOf[Initialize[Parser[T]]] =>
|
||||
wrapInitParser[T](c)(p.tree, pos)
|
||||
case tpe if tpe <:< c.weakTypeOf[Initialize[State => Parser[T]]] => wrapInit[T](c)(p, pos)
|
||||
case tpe => unexpectedType(c)(pos, tpe, "parsedMacroImpl")
|
||||
}
|
||||
}
|
||||
|
||||
private def wrapParser[T: c.WeakTypeTag](using qctx: Quotes)(tree: c.Tree, pos: c.Position) = {
|
||||
val e = c.Expr[Parser[T]](tree)
|
||||
wrap[T](c)(c.universe.reify { Def.toSParser(e.splice) }, pos)
|
||||
}
|
||||
|
||||
private def wrapInitParser[T: c.WeakTypeTag](
|
||||
using qctx: Quotes
|
||||
)(tree: c.Tree, pos: c.Position) = {
|
||||
val e = c.Expr[Initialize[Parser[T]]](tree)
|
||||
val es = c.universe.reify { Def.toISParser(e.splice) }
|
||||
wrapInit[T](c)(es, pos)
|
||||
}
|
||||
|
||||
private def unexpectedType(using qctx: Quotes)(pos: c.Position, tpe: c.Type, label: String) =
|
||||
c.abort(pos, s"Internal sbt error. Unexpected type ${tpe.dealias} in $label.")
|
||||
*/
|
||||
|
||||
end ParserInput
|
||||
|
|
|
|||
|
|
@ -29,12 +29,6 @@ end InitializeInstance
|
|||
|
||||
object ParserInstance:
|
||||
type F1[x] = State => Parser[x]
|
||||
// import sbt.internal.util.Classes.Applicative
|
||||
// private implicit val parserApplicative: Applicative[M] = new Applicative[M] {
|
||||
// def apply[S, T](f: M[S => T], v: M[S]): M[A1] = s => (f(s) ~ v(s)) map { case (a, b) => a(b) }
|
||||
// def pure[S](s: => S) = const(Parser.success(s))
|
||||
// def map[S, T](f: S => T, v: M[S]) = s => v(s).map(f)
|
||||
// }
|
||||
|
||||
given parserFunApplicative: Applicative[F1] with
|
||||
type F[x] = State => Parser[x]
|
||||
|
|
|
|||
|
|
@ -11,13 +11,7 @@ package std
|
|||
|
||||
import Def.{ Initialize, Setting }
|
||||
import sbt.internal.util.Types.Id
|
||||
import sbt.internal.util.appmacro.{
|
||||
Cont,
|
||||
// Instance,
|
||||
// LinterDSL,
|
||||
ContextUtil,
|
||||
ContextUtil0,
|
||||
}
|
||||
import sbt.internal.util.appmacro.{ Cont, ContextUtil, ContextUtil0 }
|
||||
import sbt.internal.util.{ LinePosition, NoPosition, SourcePosition }
|
||||
|
||||
import language.experimental.macros
|
||||
|
|
@ -189,23 +183,6 @@ object TaskMacro:
|
|||
$rec.append1[A2]($init)(using $ev)
|
||||
}
|
||||
|
||||
/*
|
||||
private def transformMacroImpl[A](using qctx: Quotes)(init: Expr[A])(
|
||||
newName: String
|
||||
): qctx.reflect.Term = {
|
||||
import qctx.reflect.*
|
||||
// val target =
|
||||
// c.macroApplication match {
|
||||
// case Apply(Select(prefix, _), _) => prefix
|
||||
// case x => ContextUtil.unexpectedTree(x)
|
||||
// }
|
||||
Apply.apply(
|
||||
Select(This, TermName(newName).encodedName),
|
||||
init.asTerm :: sourcePosition.asTerm :: Nil
|
||||
)
|
||||
}
|
||||
*/
|
||||
|
||||
private[sbt] def sourcePosition(using qctx: Quotes): Expr[SourcePosition] =
|
||||
import qctx.reflect.*
|
||||
val pos = Position.ofMacroExpansion
|
||||
|
|
@ -215,25 +192,6 @@ object TaskMacro:
|
|||
'{ LinePosition($name, $line) }
|
||||
else '{ NoPosition }
|
||||
|
||||
/*
|
||||
private def settingSource(c: blackbox.Context, path: String, name: String): String = {
|
||||
@tailrec def inEmptyPackage(s: c.Symbol): Boolean = s != c.universe.NoSymbol && (
|
||||
s.owner == c.mirror.EmptyPackage || s.owner == c.mirror.EmptyPackageClass || inEmptyPackage(
|
||||
s.owner
|
||||
)
|
||||
)
|
||||
c.internal.enclosingOwner match {
|
||||
case ec if !ec.isStatic => name
|
||||
case ec if inEmptyPackage(ec) => path
|
||||
case ec => s"(${ec.fullName}) $name"
|
||||
}
|
||||
}
|
||||
|
||||
private def constant[A1: c.TypeTag](c: blackbox.Context, t: T): c.Expr[A1] = {
|
||||
import c.universe._
|
||||
c.Expr[A1](Literal(Constant(t)))
|
||||
}
|
||||
*/
|
||||
end TaskMacro
|
||||
|
||||
object DefinableTaskMacro:
|
||||
|
|
@ -248,22 +206,3 @@ object DefinableTaskMacro:
|
|||
$rec.set0($app, $pos)
|
||||
}
|
||||
end DefinableTaskMacro
|
||||
|
||||
/*
|
||||
object PlainTaskMacro:
|
||||
def task[A1](t: T): Task[A1] = macro taskImpl[A1]
|
||||
def taskImpl[A1: Type](c: blackbox.Context)(t: c.Expr[A1]): c.Expr[Task[A1]] =
|
||||
Instance.contImpl[A1, Id](c, TaskInstance, TaskConvert, MixedBuilder, OnlyTaskLinterDSL)(
|
||||
Left(t),
|
||||
Instance.idTransform[c.type]
|
||||
)
|
||||
|
||||
def taskDyn[A1](t: Task[A1]): Task[A1] = macro taskDynImpl[A1]
|
||||
def taskDynImpl[A1: Type](c: blackbox.Context)(t: c.Expr[Task[A1]]): c.Expr[Task[A1]] =
|
||||
Instance.contImpl[A1, Id](c, TaskInstance, TaskConvert, MixedBuilder, OnlyTaskDynLinterDSL)(
|
||||
Right(t),
|
||||
Instance.idTransform[c.type]
|
||||
)
|
||||
|
||||
end PlainTaskMacro
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@ trait Import {
|
|||
type URI = java.net.URI
|
||||
type URL = java.net.URL
|
||||
|
||||
@deprecated("Will be removed in sbt 2", "1.0.0-RC3")
|
||||
def Seq2Vector[T](s: Seq[T]): Vector[T] = s.toVector
|
||||
|
||||
// sbt
|
||||
val StdoutOutput = sbt.OutputStrategy.StdoutOutput
|
||||
type BufferedOutput = sbt.OutputStrategy.BufferedOutput
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2023, Scala center
|
||||
* Copyright 2011 - 2022, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under Apache License 2.0 (see LICENSE)
|
||||
*/
|
||||
|
||||
package sbt.internal.util
|
||||
import scala.collection.parallel.ParSeq
|
||||
|
||||
private[util] object Par {
|
||||
def apply[R](s: Seq[R]): ParSeq[R] = s.par
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2023, Scala center
|
||||
* Copyright 2011 - 2022, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under Apache License 2.0 (see LICENSE)
|
||||
*/
|
||||
|
||||
package sbt.internal.util
|
||||
|
||||
import scala.jdk.CollectionConverters.*
|
||||
private[util] class WrappedMap[K, V](val jmap: java.util.Map[K, V]) extends Map[K, V] {
|
||||
def +[V1 >: V](kv: (K, V1)): scala.collection.immutable.Map[K, V1] =
|
||||
jmap.asScala.toMap + kv
|
||||
def -(key: K): scala.collection.immutable.Map[K, V] = jmap.asScala.toMap - key
|
||||
def get(key: K): Option[V] = Option(jmap.get(key))
|
||||
def iterator: Iterator[(K, V)] = jmap.asScala.iterator
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2023, Scala center
|
||||
* Copyright 2011 - 2022, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under Apache License 2.0 (see LICENSE)
|
||||
*/
|
||||
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
|
||||
/**
|
||||
* A minimal heterogeneous list type. For background, see
|
||||
* https://apocalisp.wordpress.com/2010/07/06/type-level-programming-in-scala-part-6a-heterogeneous-list basics/
|
||||
*/
|
||||
sealed trait HList {
|
||||
type Wrap[M[_]] <: HList
|
||||
}
|
||||
|
||||
sealed trait HNil extends HList {
|
||||
type Wrap[M[_]] = HNil
|
||||
def :+:[G](g: G): G :+: HNil = HCons(g, this)
|
||||
|
||||
override def toString = "HNil"
|
||||
}
|
||||
|
||||
object HNil extends HNil
|
||||
|
||||
final case class HCons[H, T <: HList](head: H, tail: T) extends HList {
|
||||
type Wrap[M[_]] = M[H] :+: T#Wrap[M]
|
||||
def :+:[G](g: G): G :+: H :+: T = HCons(g, this)
|
||||
|
||||
override def toString = head.toString + " :+: " + tail.toString
|
||||
}
|
||||
|
||||
object HList {
|
||||
// contains no type information: not even A
|
||||
implicit def fromList[A](list: Traversable[A]): HList =
|
||||
list.foldLeft(HNil: HList)((hl, v) => HCons(v, hl))
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2023, Scala center
|
||||
* Copyright 2011 - 2022, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under Apache License 2.0 (see LICENSE)
|
||||
*/
|
||||
|
||||
package sbt
|
||||
package internal
|
||||
package util
|
||||
|
||||
import sjsonnew._
|
||||
import Types.:+:
|
||||
|
||||
trait HListFormats {
|
||||
implicit val lnilFormat1: JsonFormat[HNil] = forHNil(HNil: HNil)
|
||||
implicit val lnilFormat2: JsonFormat[HNil.type] = forHNil(HNil)
|
||||
|
||||
private def forHNil[A <: HNil](hnil: A): JsonFormat[A] = new JsonFormat[A] {
|
||||
def write[J](x: A, builder: Builder[J]): Unit = {
|
||||
builder.beginArray()
|
||||
builder.endArray()
|
||||
}
|
||||
|
||||
def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): A = jsOpt match {
|
||||
case None => hnil
|
||||
case Some(js) => unbuilder.beginArray(js); unbuilder.endArray(); hnil
|
||||
}
|
||||
}
|
||||
|
||||
implicit def hconsFormat[H, T <: HList](implicit
|
||||
hf: JsonFormat[H],
|
||||
tf: HListJF[T]
|
||||
): JsonFormat[H :+: T] =
|
||||
new JsonFormat[H :+: T] {
|
||||
def write[J](hcons: H :+: T, builder: Builder[J]) = {
|
||||
builder.beginArray()
|
||||
hf.write(hcons.head, builder)
|
||||
tf.write(hcons.tail, builder)
|
||||
builder.endArray()
|
||||
}
|
||||
|
||||
def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]) = jsOpt match {
|
||||
case None => HCons(hf.read(None, unbuilder), tf.read(None, unbuilder))
|
||||
case Some(js) =>
|
||||
unbuilder.beginArray(js)
|
||||
val hcons =
|
||||
HCons(hf.read(Some(unbuilder.nextElement), unbuilder), tf.read(Some(js), unbuilder))
|
||||
unbuilder.endArray()
|
||||
hcons
|
||||
}
|
||||
}
|
||||
|
||||
trait HListJF[A <: HList] {
|
||||
def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): A
|
||||
def write[J](obj: A, builder: Builder[J]): Unit
|
||||
}
|
||||
|
||||
implicit def hconsHListJF[H, T <: HList](implicit
|
||||
hf: JsonFormat[H],
|
||||
tf: HListJF[T]
|
||||
): HListJF[H :+: T] =
|
||||
new HListJF[H :+: T] {
|
||||
def write[J](hcons: H :+: T, builder: Builder[J]) = {
|
||||
hf.write(hcons.head, builder)
|
||||
tf.write(hcons.tail, builder)
|
||||
}
|
||||
|
||||
def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]) = jsOpt match {
|
||||
case None => HCons(hf.read(None, unbuilder), tf.read(None, unbuilder))
|
||||
case Some(js) =>
|
||||
HCons(hf.read(Some(unbuilder.nextElement), unbuilder), tf.read(Some(js), unbuilder))
|
||||
}
|
||||
}
|
||||
|
||||
implicit val lnilHListJF1: HListJF[HNil] = hnilHListJF(HNil: HNil)
|
||||
implicit val lnilHListJF2: HListJF[HNil.type] = hnilHListJF(HNil)
|
||||
|
||||
implicit def hnilHListJF[A <: HNil](hnil: A): HListJF[A] = new HListJF[A] {
|
||||
def write[J](hcons: A, builder: Builder[J]) = ()
|
||||
def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]) = hnil
|
||||
}
|
||||
}
|
||||
|
||||
object HListFormats extends HListFormats
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2023, Scala center
|
||||
* Copyright 2011 - 2022, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under Apache License 2.0 (see LICENSE)
|
||||
*/
|
||||
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
import Classes.Applicative
|
||||
|
||||
/** A higher-kinded heterogeneous list of elements that share the same type constructor `M[_]`. */
|
||||
sealed trait KList[+M[_]] {
|
||||
type Transform[N[_]] <: KList[N]
|
||||
|
||||
/** Apply the natural transformation `f` to each element. */
|
||||
def transform[N[_]](f: M ~> N): Transform[N]
|
||||
|
||||
/** Folds this list using a function that operates on the homogeneous type of the elements of this list. */
|
||||
def foldr[B](f: (M[_], B) => B, init: B): B
|
||||
|
||||
/** Applies `f` to the elements of this list in the applicative functor defined by `ap`. */
|
||||
def apply[N[x] >: M[x], Z](f: Transform[Id] => Z)(implicit ap: Applicative[N]): N[Z]
|
||||
|
||||
/** Equivalent to `transform(f) . apply(x => x)`, this is the essence of the iterator at the level of natural transformations. */
|
||||
def traverse[N[_], P[_]](f: M ~> (N ∙ P)#l)(implicit np: Applicative[N]): N[Transform[P]]
|
||||
|
||||
/** Discards the heterogeneous type information and constructs a plain List from this KList's elements. */
|
||||
def toList: List[M[_]]
|
||||
}
|
||||
object KList {
|
||||
type Aux[+M[_], Transform0[N[_]]] = KList[M] { type Transform[N[_]] = Transform0[N] }
|
||||
}
|
||||
|
||||
final case class KCons[H, +T <: KList[M], +M[_]](head: M[H], tail: T) extends KList[M] {
|
||||
final type Transform[N[_]] = KCons[H, tail.Transform[N], N]
|
||||
|
||||
def transform[N[_]](f: M ~> N) = KCons(f(head), tail.transform(f))
|
||||
def toList: List[M[_]] = head :: tail.toList
|
||||
|
||||
def apply[N[x] >: M[x], Z](f: Transform[Id] => Z)(implicit ap: Applicative[N]): N[Z] = {
|
||||
val g = (t: tail.Transform[Id]) => (h: H) => f(KCons[H, tail.Transform[Id], Id](h, t))
|
||||
ap.apply(tail.apply[N, H => Z](g), head)
|
||||
}
|
||||
|
||||
def traverse[N[_], P[_]](f: M ~> (N ∙ P)#l)(implicit np: Applicative[N]): N[Transform[P]] = {
|
||||
val tt: N[tail.Transform[P]] = tail.traverse[N, P](f)
|
||||
val g = (t: tail.Transform[P]) => (h: P[H]) => KCons(h, t)
|
||||
np.apply(np.map(g, tt), f(head))
|
||||
}
|
||||
|
||||
def :^:[A, N[x] >: M[x]](h: N[A]) = KCons(h, this)
|
||||
override def foldr[B](f: (M[_], B) => B, init: B): B = f(head, tail.foldr(f, init))
|
||||
}
|
||||
|
||||
sealed abstract class KNil extends KList[NothingK] {
|
||||
final type Transform[N[_]] = KNil
|
||||
final def transform[N[_]](f: NothingK ~> N): Transform[N] = KNil
|
||||
final def foldr[B](f: (NothingK[_], B) => B, init: B): B = init
|
||||
final def toList = Nil
|
||||
final def apply[N[x], Z](f: KNil => Z)(implicit ap: Applicative[N]): N[Z] = ap.pure(f(KNil))
|
||||
|
||||
final def traverse[N[_], P[_]](f: NothingK ~> (N ∙ P)#l)(implicit np: Applicative[N]): N[KNil] =
|
||||
np.pure(KNil: KNil)
|
||||
}
|
||||
|
||||
case object KNil extends KNil {
|
||||
def :^:[M[_], H](h: M[H]): KCons[H, KNil, M] = KCons(h, this)
|
||||
}
|
||||
Loading…
Reference in New Issue