diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 9f86e7bde967..cb7be315c537 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -7,7 +7,7 @@ import scala.collection.immutable.BitSet import util.{ SourceFile, SourcePosition } import Tokens._ import Scanners._ -import MarkupParsers._ +import xml.MarkupParsers.MarkupParser import core._ import Flags._ import Contexts._ @@ -397,7 +397,7 @@ object Parsers { /** the markup parser */ lazy val xmlp = new MarkupParser(this, true) - object symbXMLBuilder extends SymbolicXMLBuilder(this, true) // DEBUG choices + object symbXMLBuilder extends xml.SymbolicXMLBuilder(this, true) // DEBUG choices def xmlLiteral() : Tree = xmlp.xLiteral def xmlLiteralPattern() : Tree = xmlp.xLiteralPattern diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index a46bcab6e1ae..877410ddf2ef 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -13,7 +13,6 @@ import scala.annotation.{ switch, tailrec } import scala.collection.mutable import scala.collection.immutable.SortedMap import mutable.ListBuffer -import Utility.isNameStart import rewrite.Rewrites.patch object Scanners { @@ -424,7 +423,7 @@ object Scanners { val last = if (charOffset >= 2) buf(charOffset - 2) else ' ' nextChar() last match { - case ' ' | '\t' | '\n' | '{' | '(' | '>' if isNameStart(ch) || ch == '!' || ch == '?' => + case ' ' | '\t' | '\n' | '{' | '(' | '>' if xml.Utility.isNameStart(ch) || ch == '!' || ch == '?' => token = XMLSTART case _ => // Console.println("found '<', but last is '" + in.last +"'"); // DEBUG diff --git a/compiler/src/dotty/tools/dotc/parsing/MarkupParserCommon.scala b/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParserCommon.scala similarity index 99% rename from compiler/src/dotty/tools/dotc/parsing/MarkupParserCommon.scala rename to compiler/src/dotty/tools/dotc/parsing/xml/MarkupParserCommon.scala index a3781343e92c..a2ef15336ed2 100644 --- a/compiler/src/dotty/tools/dotc/parsing/MarkupParserCommon.scala +++ b/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParserCommon.scala @@ -7,6 +7,7 @@ \* */ package dotty.tools.dotc package parsing +package xml import Utility._ import util.Chars.SU diff --git a/compiler/src/dotty/tools/dotc/parsing/MarkupParsers.scala b/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala similarity index 99% rename from compiler/src/dotty/tools/dotc/parsing/MarkupParsers.scala rename to compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala index 600d7d45164a..4792f3e3baa7 100644 --- a/compiler/src/dotty/tools/dotc/parsing/MarkupParsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala @@ -1,6 +1,7 @@ package dotty.tools package dotc package parsing +package xml import scala.collection.mutable import mutable.{ Buffer, ArrayBuffer, ListBuffer } diff --git a/compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala b/compiler/src/dotty/tools/dotc/parsing/xml/SymbolicXMLBuilder.scala similarity index 96% rename from compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala rename to compiler/src/dotty/tools/dotc/parsing/xml/SymbolicXMLBuilder.scala index ceef07d4ca36..663cd48203c2 100644 --- a/compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala +++ b/compiler/src/dotty/tools/dotc/parsing/xml/SymbolicXMLBuilder.scala @@ -1,9 +1,9 @@ package dotty.tools package dotc package parsing +package xml import scala.collection.mutable -import scala.xml.{ EntityRef, Text } import core._ import Decorators._ import Flags.Mutable @@ -146,14 +146,11 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(implicit ctx: Cont (buf map convertToTextPat).toList def parseAttribute(pos: Position, s: String): Tree = { - val ts = scala.xml.Utility.parseAttributeValue(s) map { - case Text(s) => text(pos, s) - case EntityRef(s) => entityRef(pos, s) - } - ts.length match { - case 0 => TypedSplice(tpd.ref(defn.NilModule) withPos pos) - case 1 => ts.head - case _ => makeXMLseq(pos, ts.toList) + val ts = Utility.parseAttributeValue(s, text(pos, _), entityRef(pos, _)) + ts match { + case Nil => TypedSplice(tpd.ref(defn.NilModule) withPos pos) + case t :: Nil => t + case _ => makeXMLseq(pos, ts) } } diff --git a/compiler/src/dotty/tools/dotc/parsing/Utility.scala b/compiler/src/dotty/tools/dotc/parsing/xml/Utility.scala similarity index 99% rename from compiler/src/dotty/tools/dotc/parsing/Utility.scala rename to compiler/src/dotty/tools/dotc/parsing/xml/Utility.scala index 8af594d68cce..74f102054dcf 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Utility.scala +++ b/compiler/src/dotty/tools/dotc/parsing/xml/Utility.scala @@ -1,5 +1,6 @@ package dotty.tools.dotc package parsing +package xml import scala.collection.mutable diff --git a/project/Build.scala b/project/Build.scala index df3c32e455cc..bb502d545ff7 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -339,10 +339,11 @@ object Build { // - publishes its own empty artifact "dotty" that depends on "dotty-library" and "dotty-compiler", // this is only necessary for compatibility with sbt which currently hardcodes the "dotty" artifact name lazy val dotty = project.in(file(".")).asDottyRoot(NonBootstrapped) - lazy val `dotty-bootstrapped` = project.asDottyRoot(Bootstrapped).disablePlugins(ScriptedPlugin) - lazy val `dotty-optimised` = project.asDottyRoot(BootstrappedOptimised).disablePlugins(ScriptedPlugin) + lazy val `dotty-bootstrapped` = project.asDottyRoot(Bootstrapped) + lazy val `dotty-optimised` = project.asDottyRoot(BootstrappedOptimised) lazy val `dotty-interfaces` = project.in(file("interfaces")). + disablePlugins(ScriptedPlugin). settings(commonScala2Settings). // Java-only project, so this is fine settings( // Do not append Scala versions to the generated artifacts @@ -420,8 +421,8 @@ object Build { ) lazy val `dotty-doc` = project.in(file("doc-tool")).asDottyDoc(NonBootstrapped) - lazy val `dotty-doc-bootstrapped` = project.in(file("doc-tool")).asDottyDoc(Bootstrapped).disablePlugins(ScriptedPlugin) - lazy val `dotty-doc-optimised` = project.in(file("doc-tool")).asDottyDoc(BootstrappedOptimised).disablePlugins(ScriptedPlugin) + lazy val `dotty-doc-bootstrapped` = project.in(file("doc-tool")).asDottyDoc(Bootstrapped) + lazy val `dotty-doc-optimised` = project.in(file("doc-tool")).asDottyDoc(BootstrappedOptimised) def dottyDoc(implicit mode: Mode): Project = mode match { case NonBootstrapped => `dotty-doc` @@ -501,7 +502,8 @@ object Build { // get libraries onboard libraryDependencies ++= Seq( "org.scala-lang.modules" % "scala-asm" % "6.0.0-scala-1", // used by the backend - ("org.scala-lang.modules" %% "scala-xml" % "1.0.6").withDottyCompat(scalaVersion.value), + // FIXME: Not needed, but should be on the compiler CP + ("org.scala-lang.modules" %% "scala-xml" % "1.1.0").withDottyCompat(scalaVersion.value), "org.scala-lang" % "scala-library" % scalacVersion % "test", Dependencies.compilerInterface(sbtVersion.value), ), @@ -542,7 +544,7 @@ object Build { if path.contains("scala-library") || // FIXME: currently needed for tests referencing scalac internals path.contains("scala-reflect") || - // FIXME: should go away when xml literal parsing is removed + // used for tests that compile xml path.contains("scala-xml") || // used for tests that compile dotty path.contains("scala-asm") || @@ -706,8 +708,8 @@ object Build { if (mode == NonBootstrapped) nonBootstrapedDottyCompilerSettings else bootstrapedDottyCompilerSettings lazy val `dotty-compiler` = project.in(file("compiler")).asDottyCompiler(NonBootstrapped) - lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).asDottyCompiler(Bootstrapped).disablePlugins(ScriptedPlugin) - lazy val `dotty-compiler-optimised` = project.in(file("compiler")).asDottyCompiler(BootstrappedOptimised).disablePlugins(ScriptedPlugin) + lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).asDottyCompiler(Bootstrapped) + lazy val `dotty-compiler-optimised` = project.in(file("compiler")).asDottyCompiler(BootstrappedOptimised) def dottyCompiler(implicit mode: Mode): Project = mode match { case NonBootstrapped => `dotty-compiler` @@ -721,8 +723,8 @@ object Build { ) lazy val `dotty-library` = project.in(file("library")).asDottyLibrary(NonBootstrapped) - lazy val `dotty-library-bootstrapped`: Project = project.in(file("library")).asDottyLibrary(Bootstrapped).disablePlugins(ScriptedPlugin) - lazy val `dotty-library-optimised`: Project = project.in(file("library")).asDottyLibrary(BootstrappedOptimised).disablePlugins(ScriptedPlugin) + lazy val `dotty-library-bootstrapped`: Project = project.in(file("library")).asDottyLibrary(Bootstrapped) + lazy val `dotty-library-optimised`: Project = project.in(file("library")).asDottyLibrary(BootstrappedOptimised) def dottyLibrary(implicit mode: Mode): Project = mode match { case NonBootstrapped => `dotty-library` @@ -763,7 +765,7 @@ object Build { ) lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge")).asDottySbtBridge(NonBootstrapped) - lazy val `dotty-sbt-bridge-bootstrapped` = project.in(file("sbt-bridge")).asDottySbtBridge(Bootstrapped).disablePlugins(ScriptedPlugin) + lazy val `dotty-sbt-bridge-bootstrapped` = project.in(file("sbt-bridge")).asDottySbtBridge(Bootstrapped) lazy val `dotty-language-server` = project.in(file("language-server")). dependsOn(dottyCompiler(Bootstrapped)). @@ -828,8 +830,8 @@ object Build { ).disablePlugins(ScriptedPlugin) lazy val `dotty-bench` = project.in(file("bench")).asDottyBench(NonBootstrapped) - lazy val `dotty-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped).disablePlugins(ScriptedPlugin) - lazy val `dotty-bench-optimised` = project.in(file("bench")).asDottyBench(BootstrappedOptimised).disablePlugins(ScriptedPlugin) + lazy val `dotty-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped) + lazy val `dotty-bench-optimised` = project.in(file("bench")).asDottyBench(BootstrappedOptimised) // Depend on dotty-library so that sbt projects using dotty automatically // depend on the dotty-library @@ -1132,8 +1134,8 @@ object Build { ) lazy val dist = project.asDist(NonBootstrapped) - lazy val `dist-bootstrapped` = project.asDist(Bootstrapped).disablePlugins(ScriptedPlugin) - lazy val `dist-optimised` = project.asDist(BootstrappedOptimised).disablePlugins(ScriptedPlugin) + lazy val `dist-bootstrapped` = project.asDist(Bootstrapped) + lazy val `dist-optimised` = project.asDist(BootstrappedOptimised) // /** A sandbox to play with the Scala.js back-end of dotty. // * @@ -1181,6 +1183,7 @@ object Build { // FIXME: we do not aggregate `bin` because its tests delete jars, thus breaking other tests def asDottyRoot(implicit mode: Mode): Project = project.withCommonSettings. + disablePlugins(ScriptedPlugin). aggregate(`dotty-interfaces`, dottyLibrary, dottyCompiler, dottyDoc, dottySbtBridgeReference). bootstrappedAggregate(`scala-library`, `scala-compiler`, `scala-reflect`, scalap, `dotty-language-server`). dependsOn(dottyCompiler). @@ -1190,11 +1193,13 @@ object Build { ) def asDottyCompiler(implicit mode: Mode): Project = project.withCommonSettings. + disablePlugins(ScriptedPlugin). dependsOn(`dotty-interfaces`). dependsOn(dottyLibrary). settings(dottyCompilerSettings) def asDottyLibrary(implicit mode: Mode): Project = project.withCommonSettings. + disablePlugins(ScriptedPlugin). settings(dottyLibrarySettings). bootstrappedSettings( // Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called. @@ -1202,19 +1207,23 @@ object Build { ) def asDottyDoc(implicit mode: Mode): Project = project.withCommonSettings. + disablePlugins(ScriptedPlugin). dependsOn(dottyCompiler, dottyCompiler % "test->test"). settings(dottyDocSettings) def asDottySbtBridge(implicit mode: Mode): Project = project.withCommonSettings. + disablePlugins(ScriptedPlugin). dependsOn(dottyCompiler % Provided). settings(dottySbtBridgeSettings) def asDottyBench(implicit mode: Mode): Project = project.withCommonSettings. + disablePlugins(ScriptedPlugin). dependsOn(dottyCompiler). settings(commonBenchmarkSettings). enablePlugins(JmhPlugin) def asDist(implicit mode: Mode): Project = project. + disablePlugins(ScriptedPlugin). enablePlugins(PackPlugin). withCommonSettings. dependsOn(`dotty-interfaces`, dottyCompiler, dottyLibrary, dottyDoc).