Skip to content

Commit a1cd5f4

Browse files
committed
Remove compiler dependency on scala-xml
1 parent 4ed97e3 commit a1cd5f4

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@ object Build {
501501
// get libraries onboard
502502
libraryDependencies ++= Seq(
503503
"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),
504+
// FIXME: Not needed, but should be on the compiler CP
505+
("org.scala-lang.modules" %% "scala-xml" % "1.1.0").withDottyCompat(scalaVersion.value),
505506
"org.scala-lang" % "scala-library" % scalacVersion % "test",
506507
Dependencies.compilerInterface(sbtVersion.value),
507508
),

0 commit comments

Comments
 (0)