mirror of https://github.com/sbt/sbt.git
Merge pull request #7986 from xuwei-k/string-interpolation-format-s
[2.x] use string interpolation instead of `format` method
This commit is contained in:
commit
df6e1bc2aa
|
|
@ -868,7 +868,7 @@ private final class And[T](a: Parser[T], b: Parser[?]) extends ValidParser[T] {
|
|||
def derive(c: Char) = a.derive(c) & b.derive(c)
|
||||
def completions(level: Int) = a.completions(level).filterS(s => apply(b)(s).resultEmpty.isValid)
|
||||
lazy val resultEmpty = a.resultEmpty && b.resultEmpty
|
||||
override def toString = "(%s) && (%s)".format(a, b)
|
||||
override def toString = s"(${a}) && (${b})"
|
||||
}
|
||||
|
||||
private final class Not(delegate: Parser[?], failMessage: String) extends ValidParser[Unit] {
|
||||
|
|
@ -881,7 +881,7 @@ private final class Not(delegate: Parser[?], failMessage: String) extends ValidP
|
|||
case _: Value[_] => mkFailure(failMessage)
|
||||
}
|
||||
|
||||
override def toString = " -(%s)".format(delegate)
|
||||
override def toString = s" -(${delegate})"
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -364,8 +364,7 @@ class MakePom(val log: Logger) {
|
|||
val (g, a) = (m.getOrganisation, m.getName)
|
||||
if (g == null || g.isEmpty || a == null || a.isEmpty)
|
||||
Left(
|
||||
"Skipped generating '<exclusion/>' for %s. Dependency exclusion should have both 'org' and 'module' to comply with Maven POM's schema."
|
||||
.format(m)
|
||||
s"Skipped generating '<exclusion/>' for ${m}. Dependency exclusion should have both 'org' and 'module' to comply with Maven POM's schema."
|
||||
)
|
||||
else
|
||||
Right(
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ object EvaluateTask {
|
|||
Project.showContextKey(state, if (highlight) Some(RED) else None)
|
||||
|
||||
def suppressedMessage(key: ScopedKey[?])(using display: Show[ScopedKey[?]]): String =
|
||||
"Stack trace suppressed. Run 'last %s' for the full log.".format(display.show(key))
|
||||
s"Stack trace suppressed. Run 'last ${display.show(key)}' for the full log."
|
||||
|
||||
def getStreams(key: ScopedKey[?], streams: Streams): TaskStreams =
|
||||
streams(ScopedKey(Project.fillTaskAxis(key).scope, Keys.streams.key))
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ object DefaultOptions {
|
|||
def javac: Seq[String] = compile.encoding("UTF-8")
|
||||
def scalac: Seq[String] = compile.encoding("UTF-8")
|
||||
def javadoc(name: String, version: String): Seq[String] =
|
||||
Seq("-doctitle", "%s %s API".format(name, version))
|
||||
Seq("-doctitle", s"${name} ${version} API")
|
||||
def scaladoc(name: String, version: String): Seq[String] =
|
||||
doc.title(name) ++ doc.version(version)
|
||||
|
||||
|
|
@ -95,11 +95,6 @@ object DefaultOptions {
|
|||
def addCredentials: Setting[?] = Keys.credentials += { credentials(Keys.state.value) }
|
||||
|
||||
def shellPrompt(version: String): State => String =
|
||||
s =>
|
||||
"%s:%s:%s> ".format(
|
||||
s.configuration.provider.id.name,
|
||||
Project.extract(s).currentProject.id,
|
||||
version
|
||||
)
|
||||
s => s"${s.configuration.provider.id.name}:${Project.extract(s).currentProject.id}:${version}> "
|
||||
def setupShellPrompt: Setting[?] = Keys.shellPrompt := { shellPrompt(Keys.version.value) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ private[sbt] object SettingCompletions {
|
|||
val (used, trimU) = lines(strings(affected))
|
||||
val details = if (trimR || trimU) "\n\tRun `last` for details." else ""
|
||||
val valuesString = if (redefined.size == 1) "value" else "values"
|
||||
"Defining %s\nThe new %s will be used by %s%s".format(redef, valuesString, used, details)
|
||||
s"Defining ${redef}\nThe new ${valuesString} will be used by ${used}${details}"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ private[sbt] object SettingCompletions {
|
|||
}
|
||||
|
||||
/** Parser for the `in` method name that slightly augments the naive completion to give a hint of the purpose of `in`. */
|
||||
val inParser = tokenDisplay(Space ~> InMethod, "%s <scope>".format(InMethod))
|
||||
val inParser = tokenDisplay(Space ~> InMethod, s"${InMethod} <scope>")
|
||||
|
||||
/**
|
||||
* Parser for the initialization expression for the assignment method `assign` on the key `sk`.
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ case class SettingGraph(
|
|||
def dependsAscii(defaultWidth: Int): String = Graph.toAscii(
|
||||
this,
|
||||
(x: SettingGraph) => x.depends.toSeq.sortBy(_.name),
|
||||
(x: SettingGraph) => "%s = %s" format (x.definedIn getOrElse { "" }, x.dataString),
|
||||
(x: SettingGraph) => s"${x.definedIn getOrElse { "" }} = ${x.dataString}",
|
||||
defaultWidth
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ object DOT:
|
|||
if (graph.module(e._1).exists(_.isEvicted))
|
||||
s""" [label="Evicted By" style="$EvictedStyle"]"""
|
||||
else ""
|
||||
""" "%s" -> "%s"%s""".format(e._1.idString, e._2.idString, extra)
|
||||
s""" "${e._1.idString}" -> "${e._2.idString}"${extra}"""
|
||||
}
|
||||
}.sorted.mkString("\n")
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ object DependencyTreeSettings {
|
|||
// dot support
|
||||
dependencyDotFile := {
|
||||
val config = configuration.value
|
||||
target.value / "dependencies-%s.dot".format(config.toString)
|
||||
target.value / s"dependencies-${config.toString}.dot"
|
||||
},
|
||||
dependencyDot / asString := rendering.DOT.dotGraph(
|
||||
dependencyTreeModuleGraph0.value,
|
||||
|
|
@ -123,12 +123,12 @@ object DependencyTreeSettings {
|
|||
| ]""".stripMargin,
|
||||
dependencyDotNodeColors := true,
|
||||
dependencyDotNodeLabel := { (organization: String, name: String, version: String) =>
|
||||
"""%s<BR/><B>%s</B><BR/>%s""".format(organization, name, version)
|
||||
s"""${organization}<BR/><B>${name}</B><BR/>${version}"""
|
||||
},
|
||||
// GraphML support
|
||||
dependencyGraphMLFile := {
|
||||
val config = configuration.value
|
||||
target.value / "dependencies-%s.graphml".format(config.toString)
|
||||
target.value / s"dependencies-${config.toString}.graphml"
|
||||
},
|
||||
dependencyGraphML := dependencyGraphMLTask.value,
|
||||
whatDependsOn := {
|
||||
|
|
@ -188,7 +188,7 @@ object DependencyTreeSettings {
|
|||
val resultFile = dependencyGraphMLFile.value
|
||||
val graph = dependencyTreeModuleGraph0.value
|
||||
rendering.GraphML.saveAsGraphML(graph, resultFile.getAbsolutePath)
|
||||
streams.value.log.info("Wrote dependency graph to '%s'" format resultFile)
|
||||
streams.value.log.info(s"Wrote dependency graph to '${resultFile}'")
|
||||
resultFile
|
||||
}
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ object DependencyTreeSettings {
|
|||
val outFile = fileTask.value
|
||||
IO.write(outFile, dataTask.value, IO.utf8)
|
||||
|
||||
streams.value.log.info("Wrote dependency graph to '%s'" format outFile)
|
||||
streams.value.log.info(s"Wrote dependency graph to '${outFile}'")
|
||||
outFile
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue