From 5d83709306f7032c83bef21db79773a57754f513 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Fri, 24 Apr 2020 22:41:54 +0800 Subject: [PATCH] Bump Scala version 2.13.2 (#1065) * wip * bump jline * bump travis version * long lines * fixes * . --- .travis.yml | 2 +- .../ammonite/interp/MakeReporter.scala | 43 +++++++++++++++++++ .../ammonite/interp/MakeReporter.scala | 0 .../interp/script/AmmoniteBuildServer.scala | 2 +- .../scala/ammonite/repl/tools/Router.scala | 5 ++- .../main/scala/ammonite/repl/FrontEnds.scala | 21 ++++----- build.sc | 18 ++++---- mill | 2 +- readme.md | 1 + 9 files changed, 70 insertions(+), 24 deletions(-) create mode 100644 amm/interp/src/main/scala-2.13.2/ammonite/interp/MakeReporter.scala rename amm/interp/src/main/{scala-not-2.13.1 => scala-not-2.13.1+}/ammonite/interp/MakeReporter.scala (100%) diff --git a/.travis.yml b/.travis.yml index 98428acce..a51edcd67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ matrix: - stage: build env: CI_SCRIPT="./mill -i unitTest" jdk: oraclejdk8 - scala: 2.13.1 + scala: 2.13.2 - stage: build env: CI_SCRIPT="./mill -i integrationTest" diff --git a/amm/interp/src/main/scala-2.13.2/ammonite/interp/MakeReporter.scala b/amm/interp/src/main/scala-2.13.2/ammonite/interp/MakeReporter.scala new file mode 100644 index 000000000..42580afe5 --- /dev/null +++ b/amm/interp/src/main/scala-2.13.2/ammonite/interp/MakeReporter.scala @@ -0,0 +1,43 @@ +package ammonite.interp + +import ammonite.runtime.Classpath + +import scala.reflect.internal.util.Position +import scala.reflect.io.FileZipArchive +import scala.tools.nsc +import scala.tools.nsc.classpath.{AggregateClassPath, ZipAndJarClassPathFactory} +import scala.tools.nsc.{Global, Settings} +import scala.tools.nsc.interactive.{InteractiveAnalyzer, Global => InteractiveGlobal} +import scala.tools.nsc.plugins.Plugin +import scala.tools.nsc.reporters.FilteringReporter +import scala.tools.nsc.typechecker.Analyzer + +object MakeReporter { + + type Reporter = scala.tools.nsc.reporters.Reporter + + def makeReporter(errorLogger: (Position, String) => Unit, + warningLogger: (Position, String) => Unit, + infoLogger: (Position, String) => Unit, + outerSettings: Settings): Reporter = + new FilteringReporter { + + def doReport(pos: scala.reflect.internal.util.Position, + msg: String, + severity: Severity): Unit = + display(pos, msg, severity) + + def display(pos: Position, msg: String, severity: Severity) = + severity match{ + case ERROR => + Classpath.traceClasspathProblem(s"ERROR: $msg") + errorLogger(pos, msg) + case WARNING => + warningLogger(pos, msg) + case INFO => + infoLogger(pos, msg) + } + + def settings = outerSettings + } +} diff --git a/amm/interp/src/main/scala-not-2.13.1/ammonite/interp/MakeReporter.scala b/amm/interp/src/main/scala-not-2.13.1+/ammonite/interp/MakeReporter.scala similarity index 100% rename from amm/interp/src/main/scala-not-2.13.1/ammonite/interp/MakeReporter.scala rename to amm/interp/src/main/scala-not-2.13.1+/ammonite/interp/MakeReporter.scala diff --git a/amm/interp/src/main/scala/ammonite/interp/script/AmmoniteBuildServer.scala b/amm/interp/src/main/scala/ammonite/interp/script/AmmoniteBuildServer.scala index 1eb0189c2..b69cb2222 100644 --- a/amm/interp/src/main/scala/ammonite/interp/script/AmmoniteBuildServer.scala +++ b/amm/interp/src/main/scala/ammonite/interp/script/AmmoniteBuildServer.scala @@ -64,7 +64,7 @@ class AmmoniteBuildServer( Dependency.of( "org.scalameta", "semanticdb-scalac_" + scala.util.Properties.versionNumberString, - "4.3.7" + "4.3.9" ) ), root, diff --git a/amm/repl/api/src/main/scala/ammonite/repl/tools/Router.scala b/amm/repl/api/src/main/scala/ammonite/repl/tools/Router.scala index daaeadb1b..8d0cb57e1 100755 --- a/amm/repl/api/src/main/scala/ammonite/repl/tools/Router.scala +++ b/amm/repl/api/src/main/scala/ammonite/repl/tools/Router.scala @@ -300,8 +300,9 @@ class Router [C <: Context](val c: C) { if (curCls.members.exists(_.name.toString == defaultName)) Some(defaultName) else None } - val argListSymbol = q"${c.fresh[TermName]("argsList")}" - val extrasSymbol = q"${c.fresh[TermName]("extras")}" + + val argListSymbol = q"${c.fresh[TermName](TermName("argsList"))}" + val extrasSymbol = q"${c.fresh[TermName](TermName("extras"))}" val defaults = for ((arg, i) <- flattenedArgLists.zipWithIndex) yield { val arg = TermName(c.freshName()) hasDefault(i).map(defaultName => q"($arg: $curCls) => $arg.${newTermName(defaultName)}") diff --git a/amm/repl/src/main/scala/ammonite/repl/FrontEnds.scala b/amm/repl/src/main/scala/ammonite/repl/FrontEnds.scala index dcb9e0ec9..a41f5fc3f 100644 --- a/amm/repl/src/main/scala/ammonite/repl/FrontEnds.scala +++ b/amm/repl/src/main/scala/ammonite/repl/FrontEnds.scala @@ -7,12 +7,13 @@ import fastparse.Parsed import fastparse.ParserInput import org.jline.reader.{Highlighter => _, _} import org.jline.reader.impl.history.DefaultHistory -import org.jline.reader.impl.DefaultParser.ArgumentList + import org.jline.terminal._ import org.jline.utils.AttributedString import ammonite.util.{Catching, Colors, Res} import ammonite.repl.api.FrontEnd import ammonite.interp.{Parsers, Preprocessor} +import org.jline.reader.impl.DefaultParser object FrontEnds { @@ -55,7 +56,7 @@ object FrontEnds { def readCode(): Res[(String, Seq[String])] = { Option(reader.readLine(prompt)) match { case Some(code) => - val pl = reader.getParser.parse(code, 0).asInstanceOf[AmmoniteParsedLine] + val pl = reader.getParser.parse(code, 0).asInstanceOf[AmmParser#AmmoniteParsedLine] Res.Success(code -> pl.stmts) case None => Res.Exit(()) } @@ -125,10 +126,15 @@ class AmmCompleter(highlighter: org.jline.reader.Highlighter) extends Completer } class AmmParser extends Parser { + class AmmoniteParsedLine(line: String, words: java.util.List[String], + wordIndex: Int, wordCursor: Int, cursor: Int, + val stmts: Seq[String] = Seq.empty // needed for interpreter + ) + extends defaultParser.ArgumentList(line, words, wordIndex, wordCursor, cursor) var addHistory: String => Unit = x => () - private val defaultParser = new org.jline.reader.impl.DefaultParser + val defaultParser = new org.jline.reader.impl.DefaultParser override def parse(line: String, cursor: Int, context: Parser.ParseContext): ParsedLine = { // let JLine's default parser to handle JLine words and indices @@ -169,18 +175,13 @@ class AmmParser extends Parser { } } -class AmmoniteParsedLine( - line: String, words: java.util.List[String], - wordIndex: Int, wordCursor: Int, cursor: Int, - val stmts: Seq[String] = Seq.empty // needed for interpreter -) extends ArgumentList(line, words, wordIndex, wordCursor, cursor) - class SyntaxError(val msg: String) extends RuntimeException class AmmHighlighter extends org.jline.reader.Highlighter { var colors: Colors = Colors.Default - + def setErrorIndex(x$1: Int): Unit = () + def setErrorPattern(x$1: java.util.regex.Pattern): Unit = () override def highlight(reader: LineReader, buffer: String): AttributedString = { val hl = Highlighter.defaultHighlight( buffer.toVector, diff --git a/build.sc b/build.sc index 53675e5f8..080bce90d 100644 --- a/build.sc +++ b/build.sc @@ -19,11 +19,11 @@ val commitsSinceTaggedVersion = { } -val binCrossScalaVersions = Seq("2.12.11", "2.13.1") -val isScala2_12_10OrLater = Set("2.12.10") ++ binCrossScalaVersions +val binCrossScalaVersions = Seq("2.12.11", "2.13.2") +val isScala2_12_10OrLater = Set("2.12.10", "2.12.11", "2.13.1", "2.13.2") val fullCrossScalaVersions = Seq( "2.12.1", "2.12.2", "2.12.3", "2.12.4", "2.12.6", "2.12.7", "2.12.8", "2.12.9", "2.12.10", "2.12.11", - "2.13.0", "2.13.1" + "2.13.0", "2.13.1", "2.13.2" ) val latestAssemblies = binCrossScalaVersions.map(amm(_).assembly) @@ -68,8 +68,8 @@ trait AmmInternalModule extends mill.scalalib.CrossSbtModule{ else millSourcePath / "src" / "main" / "scala-not-2.12.10-2.13.1+" ) val extraDir3 = - if (sv == "2.13.1") Nil - else Seq(PathRef(millSourcePath / "src" / "main" / "scala-not-2.13.1")) + if (sv == "2.13.1" || sv == "2.13.2") Nil + else Seq(PathRef(millSourcePath / "src" / "main" / "scala-not-2.13.1+")) super.sources() ++ extraDir ++ Seq(extraDir2) ++ extraDir3 } @@ -147,7 +147,7 @@ class OpsModule(val crossScalaVersion: String) extends AmmModule{ object terminal extends Cross[TerminalModule](binCrossScalaVersions:_*) class TerminalModule(val crossScalaVersion: String) extends AmmModule{ def ivyDeps = Agg( - ivy"com.lihaoyi::sourcecode:0.2.0", + ivy"com.lihaoyi::sourcecode:0.2.1", ivy"com.lihaoyi::fansi:0.2.8" ) def compileIvyDeps = Agg( @@ -249,9 +249,9 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){ terminal() ) def ivyDeps = Agg( - ivy"org.jline:jline-terminal:3.6.2", - ivy"org.jline:jline-terminal-jna:3.6.2", - ivy"org.jline:jline-reader:3.6.2", + ivy"org.jline:jline-terminal:3.14.1", + ivy"org.jline:jline-terminal-jna:3.14.1", + ivy"org.jline:jline-reader:3.14.1", ivy"com.github.javaparser:javaparser-core:3.2.5", ivy"com.github.scopt::scopt:3.7.1" ) diff --git a/mill b/mill index 510a1378f..3c3321eed 100755 --- a/mill +++ b/mill @@ -3,7 +3,7 @@ # This is a wrapper script, that automatically download mill from GitHub release pages # You can give the required mill version with MILL_VERSION env variable # If no version is given, it falls back to the value of DEFAULT_MILL_VERSION -DEFAULT_MILL_VERSION=0.6.1-122-5be570 +DEFAULT_MILL_VERSION=0.6.2 set -e diff --git a/readme.md b/readme.md index 6c9e8b5d8..995398eb5 100644 --- a/readme.md +++ b/readme.md @@ -153,3 +153,4 @@ And possibly: - **It's entirely possible your changes won't be merged**, or will get ripped out later. This is also the case for my changes, as the Author! - **Even a rejected/reverted PR is valuable**! It helps to explore the solution space, and know what works and what doesn't. For every line in the repo, at least three lines were tried, committed, and reverted/refactored, and more than 10 were tried without committing. - **Feel free to send Proof-Of-Concept PRs** that you don't intend to get merged. +