mirror of https://github.com/sbt/sbt.git
Use linesIterator for JDK 11 compat
This commit is contained in:
parent
4e00a3e9f0
commit
cd7a5c6f6b
|
|
@ -27,7 +27,7 @@ final class InputTask[T] private (val parser: State => Parser[Task[T]]) {
|
||||||
Parser.parse(in, parser(s)) match {
|
Parser.parse(in, parser(s)) match {
|
||||||
case Right(v) => Parser.success(v)
|
case Right(v) => Parser.success(v)
|
||||||
case Left(msg) =>
|
case Left(msg) =>
|
||||||
val indented = msg.lines.map(" " + _).mkString("\n")
|
val indented = msg.linesIterator.map(" " + _).mkString("\n")
|
||||||
Parser.failure(s"Invalid programmatic input:\n$indented")
|
Parser.failure(s"Invalid programmatic input:\n$indented")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -47,7 +47,7 @@ object InputTask {
|
||||||
Parser.parse(in, it.parser(s)) match {
|
Parser.parse(in, it.parser(s)) match {
|
||||||
case Right(t) => Def.value(t)
|
case Right(t) => Def.value(t)
|
||||||
case Left(msg) =>
|
case Left(msg) =>
|
||||||
val indented = msg.lines.map(" " + _).mkString("\n")
|
val indented = msg.linesIterator.map(" " + _).mkString("\n")
|
||||||
sys.error(s"Invalid programmatic input:\n$indented")
|
sys.error(s"Invalid programmatic input:\n$indented")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ private[sbt] object LibraryManagement {
|
||||||
val culprit = t.getClass.getSimpleName
|
val culprit = t.getClass.getSimpleName
|
||||||
log.warn(s"Update task caching failed due to $culprit.")
|
log.warn(s"Update task caching failed due to $culprit.")
|
||||||
log.warn("Report the following output to sbt:")
|
log.warn("Report the following output to sbt:")
|
||||||
resolvedAgain.toString.lines.foreach(log.warn(_))
|
resolvedAgain.toString.linesIterator.foreach(log.warn(_))
|
||||||
log.trace(t)
|
log.trace(t)
|
||||||
resolvedAgain
|
resolvedAgain
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ private[sbt] object SbtRefactorings {
|
||||||
val sortedRecordedCommands = recordedCommands.sortBy(_._1)(reverseOrderingInt)
|
val sortedRecordedCommands = recordedCommands.sortBy(_._1)(reverseOrderingInt)
|
||||||
|
|
||||||
val newContent = replaceFromBottomToTop(lines.mkString(END_OF_LINE), sortedRecordedCommands)
|
val newContent = replaceFromBottomToTop(lines.mkString(END_OF_LINE), sortedRecordedCommands)
|
||||||
(file, newContent.lines.toList)
|
(file, newContent.linesIterator.toList)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def replaceFromBottomToTop(
|
private def replaceFromBottomToTop(
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class EmbeddedXmlSpec extends CheckIfParsedSpec {
|
||||||
|
|
||||||
split(buildSbt) must throwA[MessageOnlyException].like {
|
split(buildSbt) must throwA[MessageOnlyException].like {
|
||||||
case exception =>
|
case exception =>
|
||||||
val index = buildSbt.lines.indexWhere(line => line.contains(errorLine)) + 1
|
val index = buildSbt.linesIterator.indexWhere(line => line.contains(errorLine)) + 1
|
||||||
val numberRegex = """(\d+)""".r
|
val numberRegex = """(\d+)""".r
|
||||||
val message = exception.getMessage
|
val message = exception.getMessage
|
||||||
val list = numberRegex.findAllIn(message).toList
|
val list = numberRegex.findAllIn(message).toList
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,7 @@ package internal
|
||||||
package parser
|
package parser
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
import sbt.internal.util.MessageOnlyException
|
import sbt.internal.util.MessageOnlyException
|
||||||
|
|
||||||
import scala.io.Source
|
import scala.io.Source
|
||||||
|
|
||||||
class ErrorSpec extends AbstractSpec {
|
class ErrorSpec extends AbstractSpec {
|
||||||
|
|
@ -26,12 +24,13 @@ class ErrorSpec extends AbstractSpec {
|
||||||
foreach(new File(rootPath).listFiles) { file =>
|
foreach(new File(rootPath).listFiles) { file =>
|
||||||
print(s"Processing ${file.getName}: ")
|
print(s"Processing ${file.getName}: ")
|
||||||
val buildSbt = Source.fromFile(file).getLines().mkString("\n")
|
val buildSbt = Source.fromFile(file).getLines().mkString("\n")
|
||||||
SbtParser(file, buildSbt.lines.toSeq) must throwA[MessageOnlyException].like {
|
SbtParser(file, buildSbt.linesIterator.toSeq) must throwA[MessageOnlyException]
|
||||||
case exp =>
|
.like {
|
||||||
val message = exp.getMessage
|
case exp =>
|
||||||
println(s"${exp.getMessage}")
|
val message = exp.getMessage
|
||||||
message must contain(file.getName)
|
println(s"${exp.getMessage}")
|
||||||
}
|
message must contain(file.getName)
|
||||||
|
}
|
||||||
containsLineNumber(buildSbt)
|
containsLineNumber(buildSbt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +59,9 @@ class ErrorSpec extends AbstractSpec {
|
||||||
|val a = <a/><b/>
|
|val a = <a/><b/>
|
||||||
|val s = '
|
|val s = '
|
||||||
""".stripMargin
|
""".stripMargin
|
||||||
SbtParser(SbtParser.FAKE_FILE, buildSbt.lines.toSeq) must throwA[MessageOnlyException].like {
|
SbtParser(SbtParser.FAKE_FILE, buildSbt.linesIterator.toSeq) must throwA[
|
||||||
|
MessageOnlyException
|
||||||
|
].like {
|
||||||
case exp =>
|
case exp =>
|
||||||
val message = exp.getMessage
|
val message = exp.getMessage
|
||||||
println(s"${exp.getMessage}")
|
println(s"${exp.getMessage}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue