mirror of
https://github.com/sbt/sbt.git
synced 2026-08-22 06:07:24 +02:00
remove some format: off comments
This commit is contained in:
@@ -63,10 +63,8 @@ private[sbt] final class ArbitraryCommand(
|
|||||||
new ArbitraryCommand(parser, help, tags.put(key, value))
|
new ArbitraryCommand(parser, help, tags.put(key, value))
|
||||||
}
|
}
|
||||||
|
|
||||||
// format: off
|
|
||||||
|
|
||||||
object Command {
|
object Command {
|
||||||
import DefaultParsers._
|
import DefaultParsers.*
|
||||||
|
|
||||||
// Lowest-level command construction
|
// Lowest-level command construction
|
||||||
|
|
||||||
@@ -152,8 +150,7 @@ object Command {
|
|||||||
|
|
||||||
def combine(cmds: Seq[Command]): State => Parser[() => State] = {
|
def combine(cmds: Seq[Command]): State => Parser[() => State] = {
|
||||||
val (simple, arbs) = separateCommands(cmds)
|
val (simple, arbs) = separateCommands(cmds)
|
||||||
state =>
|
state => arbs.map(_.parser(state)).foldLeft(simpleParser(simple)(state))(_ | _)
|
||||||
arbs.map(_.parser(state)).foldLeft(simpleParser(simple)(state))(_ | _)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private def separateCommands(
|
private def separateCommands(
|
||||||
@@ -168,8 +165,7 @@ object Command {
|
|||||||
|
|
||||||
private def argParser(sc: SimpleCommand): State => Parser[() => State] = {
|
private def argParser(sc: SimpleCommand): State => Parser[() => State] = {
|
||||||
def usageError = s"${sc.name} usage:" + Help.message(sc.help0, None)
|
def usageError = s"${sc.name} usage:" + Help.message(sc.help0, None)
|
||||||
s =>
|
s => (Parser.softFailure(usageError, definitive = true): Parser[() => State]) | sc.parser(s)
|
||||||
(Parser.softFailure(usageError, definitive = true): Parser[() => State]) | sc.parser(s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def simpleParser(
|
def simpleParser(
|
||||||
@@ -188,7 +184,7 @@ object Command {
|
|||||||
|
|
||||||
def process(command: String, state: State, onParseError: String => Unit): State = {
|
def process(command: String, state: State, onParseError: String => Unit): State = {
|
||||||
(if (command.contains(";")) parse(command, state.combinedParser)
|
(if (command.contains(";")) parse(command, state.combinedParser)
|
||||||
else parse(command, state.nonMultiParser)) match {
|
else parse(command, state.nonMultiParser)) match {
|
||||||
case Right(s) => s() // apply command. command side effects happen here
|
case Right(s) => s() // apply command. command side effects happen here
|
||||||
case Left(errMsg) =>
|
case Left(errMsg) =>
|
||||||
state.log.error(errMsg)
|
state.log.error(errMsg)
|
||||||
@@ -211,7 +207,9 @@ object Command {
|
|||||||
maxDistance: Int = 3,
|
maxDistance: Int = 3,
|
||||||
maxSuggestions: Int = 3
|
maxSuggestions: Int = 3
|
||||||
): Seq[String] =
|
): Seq[String] =
|
||||||
bs map (b => (b, distance(a, b))) filter (_._2 <= maxDistance) sortBy (_._2) take (maxSuggestions) map (_._1)
|
bs map (b =>
|
||||||
|
(b, distance(a, b))
|
||||||
|
) filter (_._2 <= maxDistance) sortBy (_._2) take (maxSuggestions) map (_._1)
|
||||||
|
|
||||||
def distance(a: String, b: String): Int =
|
def distance(a: String, b: String): Int =
|
||||||
EditDistance.levenshtein(
|
EditDistance.levenshtein(
|
||||||
@@ -228,11 +226,9 @@ object Command {
|
|||||||
def spacedAny(name: String): Parser[String] = spacedC(name, any)
|
def spacedAny(name: String): Parser[String] = spacedC(name, any)
|
||||||
|
|
||||||
def spacedC(name: String, c: Parser[Char]): Parser[String] =
|
def spacedC(name: String, c: Parser[Char]): Parser[String] =
|
||||||
((c & opOrIDSpaced(name)) ~ c.+) map { (f, rem) => (f +: rem).mkString }
|
((c & opOrIDSpaced(name)) ~ c.+) map { (f, rem) => (f +: rem).mkString }
|
||||||
}
|
}
|
||||||
|
|
||||||
// format: on
|
|
||||||
|
|
||||||
trait Help {
|
trait Help {
|
||||||
def detail: Map[String, String]
|
def detail: Map[String, String]
|
||||||
def brief: Seq[(String, String)]
|
def brief: Seq[(String, String)]
|
||||||
|
|||||||
@@ -339,8 +339,7 @@ object Scoped:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private[sbt] trait Syntax:
|
private[sbt] trait Syntax:
|
||||||
|
|
||||||
// format: off
|
|
||||||
// richInitialize
|
// richInitialize
|
||||||
extension [A1](init: Initialize[A1])
|
extension [A1](init: Initialize[A1])
|
||||||
@targetName("mapTaskInitialize")
|
@targetName("mapTaskInitialize")
|
||||||
@@ -348,7 +347,6 @@ object Scoped:
|
|||||||
|
|
||||||
@targetName("flatMapValueInitialize")
|
@targetName("flatMapValueInitialize")
|
||||||
def flatMapTaskValue[A2](f: A1 => Task[A2]): Initialize[Task[A2]] = init(f)
|
def flatMapTaskValue[A2](f: A1 => Task[A2]): Initialize[Task[A2]] = init(f)
|
||||||
// format: on
|
|
||||||
|
|
||||||
// richInitializeTask
|
// richInitializeTask
|
||||||
extension [A1](init: Initialize[Task[A1]])
|
extension [A1](init: Initialize[Task[A1]])
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import scala.quoted.*
|
|||||||
*/
|
*/
|
||||||
object FileChangesMacro:
|
object FileChangesMacro:
|
||||||
|
|
||||||
// format: off
|
|
||||||
extension [A](in: TaskKey[A])
|
extension [A](in: TaskKey[A])
|
||||||
@compileTimeOnly(
|
@compileTimeOnly(
|
||||||
"`inputFileChanges` can only be called on a task within a task definition macro, such as :=, +=, ++=, or Def.task."
|
"`inputFileChanges` can only be called on a task within a task definition macro, such as :=, +=, ++=, or Def.task."
|
||||||
@@ -50,7 +49,7 @@ object FileChangesMacro:
|
|||||||
)
|
)
|
||||||
inline def outputFiles: Seq[NioPath] =
|
inline def outputFiles: Seq[NioPath] =
|
||||||
${ FileChangesMacro.outputFilesImpl[A]('in) }
|
${ FileChangesMacro.outputFilesImpl[A]('in) }
|
||||||
// format: on
|
|
||||||
def changedInputFilesImpl[A: Type](in: Expr[TaskKey[A]])(using qctx: Quotes): Expr[FileChanges] =
|
def changedInputFilesImpl[A: Type](in: Expr[TaskKey[A]])(using qctx: Quotes): Expr[FileChanges] =
|
||||||
impl[A](
|
impl[A](
|
||||||
in = in,
|
in = in,
|
||||||
|
|||||||
Reference in New Issue
Block a user