Skip to content

Commit 17c4497

Browse files
authored
Merge pull request #4394 from dotty-staging/xml
Remove compiler dependency on scala-xml
2 parents 9fee410 + 2a266c5 commit 17c4497

File tree

7 files changed

+36
-28
lines changed

7 files changed

+36
-28
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import scala.collection.immutable.BitSet
77
import util.{ SourceFile, SourcePosition }
88
import Tokens._
99
import Scanners._
10-
import MarkupParsers._
10+
import xml.MarkupParsers.MarkupParser
1111
import core._
1212
import Flags._
1313
import Contexts._
@@ -397,7 +397,7 @@ object Parsers {
397397
/** the markup parser */
398398
lazy val xmlp = new MarkupParser(this, true)
399399

400-
object symbXMLBuilder extends SymbolicXMLBuilder(this, true) // DEBUG choices
400+
object symbXMLBuilder extends xml.SymbolicXMLBuilder(this, true) // DEBUG choices
401401

402402
def xmlLiteral() : Tree = xmlp.xLiteral
403403
def xmlLiteralPattern() : Tree = xmlp.xLiteralPattern

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import scala.annotation.{ switch, tailrec }
1313
import scala.collection.mutable
1414
import scala.collection.immutable.SortedMap
1515
import mutable.ListBuffer
16-
import Utility.isNameStart
1716
import rewrite.Rewrites.patch
1817

1918
object Scanners {
@@ -424,7 +423,7 @@ object Scanners {
424423
val last = if (charOffset >= 2) buf(charOffset - 2) else ' '
425424
nextChar()
426425
last match {
427-
case ' ' | '\t' | '\n' | '{' | '(' | '>' if isNameStart(ch) || ch == '!' || ch == '?' =>
426+
case ' ' | '\t' | '\n' | '{' | '(' | '>' if xml.Utility.isNameStart(ch) || ch == '!' || ch == '?' =>
428427
token = XMLSTART
429428
case _ =>
430429
// Console.println("found '<', but last is '" + in.last +"'"); // DEBUG

compiler/src/dotty/tools/dotc/parsing/MarkupParserCommon.scala renamed to compiler/src/dotty/tools/dotc/parsing/xml/MarkupParserCommon.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
\* */
88
package dotty.tools.dotc
99
package parsing
10+
package xml
1011

1112
import Utility._
1213
import util.Chars.SU

compiler/src/dotty/tools/dotc/parsing/MarkupParsers.scala renamed to compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dotty.tools
22
package dotc
33
package parsing
4+
package xml
45

56
import scala.collection.mutable
67
import mutable.{ Buffer, ArrayBuffer, ListBuffer }

compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala renamed to compiler/src/dotty/tools/dotc/parsing/xml/SymbolicXMLBuilder.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package dotty.tools
22
package dotc
33
package parsing
4+
package xml
45

56
import scala.collection.mutable
6-
import scala.xml.{ EntityRef, Text }
77
import core._
88
import Decorators._
99
import Flags.Mutable
@@ -146,14 +146,11 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(implicit ctx: Cont
146146
(buf map convertToTextPat).toList
147147

148148
def parseAttribute(pos: Position, s: String): Tree = {
149-
val ts = scala.xml.Utility.parseAttributeValue(s) map {
150-
case Text(s) => text(pos, s)
151-
case EntityRef(s) => entityRef(pos, s)
152-
}
153-
ts.length match {
154-
case 0 => TypedSplice(tpd.ref(defn.NilModule) withPos pos)
155-
case 1 => ts.head
156-
case _ => makeXMLseq(pos, ts.toList)
149+
val ts = Utility.parseAttributeValue(s, text(pos, _), entityRef(pos, _))
150+
ts match {
151+
case Nil => TypedSplice(tpd.ref(defn.NilModule) withPos pos)
152+
case t :: Nil => t
153+
case _ => makeXMLseq(pos, ts)
157154
}
158155
}
159156

compiler/src/dotty/tools/dotc/parsing/Utility.scala renamed to compiler/src/dotty/tools/dotc/parsing/xml/Utility.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.dotc
22
package parsing
3+
package xml
34

45
import scala.collection.mutable
56

project/Build.scala

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,11 @@ object Build {
339339
// - publishes its own empty artifact "dotty" that depends on "dotty-library" and "dotty-compiler",
340340
// this is only necessary for compatibility with sbt which currently hardcodes the "dotty" artifact name
341341
lazy val dotty = project.in(file(".")).asDottyRoot(NonBootstrapped)
342-
lazy val `dotty-bootstrapped` = project.asDottyRoot(Bootstrapped).disablePlugins(ScriptedPlugin)
343-
lazy val `dotty-optimised` = project.asDottyRoot(BootstrappedOptimised).disablePlugins(ScriptedPlugin)
342+
lazy val `dotty-bootstrapped` = project.asDottyRoot(Bootstrapped)
343+
lazy val `dotty-optimised` = project.asDottyRoot(BootstrappedOptimised)
344344

345345
lazy val `dotty-interfaces` = project.in(file("interfaces")).
346+
disablePlugins(ScriptedPlugin).
346347
settings(commonScala2Settings). // Java-only project, so this is fine
347348
settings(
348349
// Do not append Scala versions to the generated artifacts
@@ -420,8 +421,8 @@ object Build {
420421
)
421422

422423
lazy val `dotty-doc` = project.in(file("doc-tool")).asDottyDoc(NonBootstrapped)
423-
lazy val `dotty-doc-bootstrapped` = project.in(file("doc-tool")).asDottyDoc(Bootstrapped).disablePlugins(ScriptedPlugin)
424-
lazy val `dotty-doc-optimised` = project.in(file("doc-tool")).asDottyDoc(BootstrappedOptimised).disablePlugins(ScriptedPlugin)
424+
lazy val `dotty-doc-bootstrapped` = project.in(file("doc-tool")).asDottyDoc(Bootstrapped)
425+
lazy val `dotty-doc-optimised` = project.in(file("doc-tool")).asDottyDoc(BootstrappedOptimised)
425426

426427
def dottyDoc(implicit mode: Mode): Project = mode match {
427428
case NonBootstrapped => `dotty-doc`
@@ -501,7 +502,8 @@ object Build {
501502
// get libraries onboard
502503
libraryDependencies ++= Seq(
503504
"org.scala-lang.modules" % "scala-asm" % "6.0.0-scala-1", // used by the backend
504-
("org.scala-lang.modules" %% "scala-xml" % "1.0.6").withDottyCompat(scalaVersion.value),
505+
// FIXME: Not needed, but should be on the compiler CP
506+
("org.scala-lang.modules" %% "scala-xml" % "1.1.0").withDottyCompat(scalaVersion.value),
505507
"org.scala-lang" % "scala-library" % scalacVersion % "test",
506508
Dependencies.compilerInterface(sbtVersion.value),
507509
),
@@ -542,7 +544,7 @@ object Build {
542544
if path.contains("scala-library") ||
543545
// FIXME: currently needed for tests referencing scalac internals
544546
path.contains("scala-reflect") ||
545-
// FIXME: should go away when xml literal parsing is removed
547+
// used for tests that compile xml
546548
path.contains("scala-xml") ||
547549
// used for tests that compile dotty
548550
path.contains("scala-asm") ||
@@ -706,8 +708,8 @@ object Build {
706708
if (mode == NonBootstrapped) nonBootstrapedDottyCompilerSettings else bootstrapedDottyCompilerSettings
707709

708710
lazy val `dotty-compiler` = project.in(file("compiler")).asDottyCompiler(NonBootstrapped)
709-
lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).asDottyCompiler(Bootstrapped).disablePlugins(ScriptedPlugin)
710-
lazy val `dotty-compiler-optimised` = project.in(file("compiler")).asDottyCompiler(BootstrappedOptimised).disablePlugins(ScriptedPlugin)
711+
lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).asDottyCompiler(Bootstrapped)
712+
lazy val `dotty-compiler-optimised` = project.in(file("compiler")).asDottyCompiler(BootstrappedOptimised)
711713

712714
def dottyCompiler(implicit mode: Mode): Project = mode match {
713715
case NonBootstrapped => `dotty-compiler`
@@ -721,8 +723,8 @@ object Build {
721723
)
722724

723725
lazy val `dotty-library` = project.in(file("library")).asDottyLibrary(NonBootstrapped)
724-
lazy val `dotty-library-bootstrapped`: Project = project.in(file("library")).asDottyLibrary(Bootstrapped).disablePlugins(ScriptedPlugin)
725-
lazy val `dotty-library-optimised`: Project = project.in(file("library")).asDottyLibrary(BootstrappedOptimised).disablePlugins(ScriptedPlugin)
726+
lazy val `dotty-library-bootstrapped`: Project = project.in(file("library")).asDottyLibrary(Bootstrapped)
727+
lazy val `dotty-library-optimised`: Project = project.in(file("library")).asDottyLibrary(BootstrappedOptimised)
726728

727729
def dottyLibrary(implicit mode: Mode): Project = mode match {
728730
case NonBootstrapped => `dotty-library`
@@ -763,7 +765,7 @@ object Build {
763765
)
764766

765767
lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge")).asDottySbtBridge(NonBootstrapped)
766-
lazy val `dotty-sbt-bridge-bootstrapped` = project.in(file("sbt-bridge")).asDottySbtBridge(Bootstrapped).disablePlugins(ScriptedPlugin)
768+
lazy val `dotty-sbt-bridge-bootstrapped` = project.in(file("sbt-bridge")).asDottySbtBridge(Bootstrapped)
767769

768770
lazy val `dotty-language-server` = project.in(file("language-server")).
769771
dependsOn(dottyCompiler(Bootstrapped)).
@@ -828,8 +830,8 @@ object Build {
828830
).disablePlugins(ScriptedPlugin)
829831

830832
lazy val `dotty-bench` = project.in(file("bench")).asDottyBench(NonBootstrapped)
831-
lazy val `dotty-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped).disablePlugins(ScriptedPlugin)
832-
lazy val `dotty-bench-optimised` = project.in(file("bench")).asDottyBench(BootstrappedOptimised).disablePlugins(ScriptedPlugin)
833+
lazy val `dotty-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped)
834+
lazy val `dotty-bench-optimised` = project.in(file("bench")).asDottyBench(BootstrappedOptimised)
833835

834836
// Depend on dotty-library so that sbt projects using dotty automatically
835837
// depend on the dotty-library
@@ -1132,8 +1134,8 @@ object Build {
11321134
)
11331135

11341136
lazy val dist = project.asDist(NonBootstrapped)
1135-
lazy val `dist-bootstrapped` = project.asDist(Bootstrapped).disablePlugins(ScriptedPlugin)
1136-
lazy val `dist-optimised` = project.asDist(BootstrappedOptimised).disablePlugins(ScriptedPlugin)
1137+
lazy val `dist-bootstrapped` = project.asDist(Bootstrapped)
1138+
lazy val `dist-optimised` = project.asDist(BootstrappedOptimised)
11371139

11381140
// /** A sandbox to play with the Scala.js back-end of dotty.
11391141
// *
@@ -1181,6 +1183,7 @@ object Build {
11811183

11821184
// FIXME: we do not aggregate `bin` because its tests delete jars, thus breaking other tests
11831185
def asDottyRoot(implicit mode: Mode): Project = project.withCommonSettings.
1186+
disablePlugins(ScriptedPlugin).
11841187
aggregate(`dotty-interfaces`, dottyLibrary, dottyCompiler, dottyDoc, dottySbtBridgeReference).
11851188
bootstrappedAggregate(`scala-library`, `scala-compiler`, `scala-reflect`, scalap, `dotty-language-server`).
11861189
dependsOn(dottyCompiler).
@@ -1190,31 +1193,37 @@ object Build {
11901193
)
11911194

11921195
def asDottyCompiler(implicit mode: Mode): Project = project.withCommonSettings.
1196+
disablePlugins(ScriptedPlugin).
11931197
dependsOn(`dotty-interfaces`).
11941198
dependsOn(dottyLibrary).
11951199
settings(dottyCompilerSettings)
11961200

11971201
def asDottyLibrary(implicit mode: Mode): Project = project.withCommonSettings.
1202+
disablePlugins(ScriptedPlugin).
11981203
settings(dottyLibrarySettings).
11991204
bootstrappedSettings(
12001205
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called.
12011206
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath)
12021207
)
12031208

12041209
def asDottyDoc(implicit mode: Mode): Project = project.withCommonSettings.
1210+
disablePlugins(ScriptedPlugin).
12051211
dependsOn(dottyCompiler, dottyCompiler % "test->test").
12061212
settings(dottyDocSettings)
12071213

12081214
def asDottySbtBridge(implicit mode: Mode): Project = project.withCommonSettings.
1215+
disablePlugins(ScriptedPlugin).
12091216
dependsOn(dottyCompiler % Provided).
12101217
settings(dottySbtBridgeSettings)
12111218

12121219
def asDottyBench(implicit mode: Mode): Project = project.withCommonSettings.
1220+
disablePlugins(ScriptedPlugin).
12131221
dependsOn(dottyCompiler).
12141222
settings(commonBenchmarkSettings).
12151223
enablePlugins(JmhPlugin)
12161224

12171225
def asDist(implicit mode: Mode): Project = project.
1226+
disablePlugins(ScriptedPlugin).
12181227
enablePlugins(PackPlugin).
12191228
withCommonSettings.
12201229
dependsOn(`dotty-interfaces`, dottyCompiler, dottyLibrary, dottyDoc).

0 commit comments

Comments
 (0)