Skip to content

Fix #51 Test compat for -Xxml:coalescing #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ version := "1.0.5-SNAPSHOT"

scalaVersion := crossScalaVersions.value.head

crossScalaVersions := Seq("2.11.6", "2.12.0-M1")
crossScalaVersions := Seq("2.11.7", "2.12.0-M1")

//scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_ -Xfatal-warnings -Xxml:coalescing".split("\\s+").to[Seq]
scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_ -Xxml:coalescing".split("\\s+").to[Seq]

// important!! must come here (why?)
scalaModuleOsgiSettings
Expand Down
23 changes: 17 additions & 6 deletions src/main/scala/scala/xml/dtd/ContentModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ import scala.xml.dtd.impl._
import scala.xml.Utility.sbToString
import PartialFunction._

/*
@deprecated("Avoidance", since="2.10")
trait ContentModelLaundry extends WordExp
object ContentModelLaundry extends ContentModelLaundry {
}
*/

object ContentModel extends WordExp {

type _labelT = ElemName
type _regexpT = RegExp

object Translator extends WordBerrySethi {
@deprecated("Avoidance", since="2.10")
trait Translator extends WordBerrySethi
object Translator extends Translator {
override val lang: ContentModel.this.type = ContentModel.this
}

Expand Down Expand Up @@ -72,14 +82,15 @@ object ContentModel extends WordExp {
case Letter(ElemName(name)) =>
sb.append(name)
}

}

sealed abstract class ContentModel {
override def toString(): String = sbToString(buildString)
def buildString(sb: StringBuilder): StringBuilder
}

import ContentModel.RegExp

case object PCDATA extends ContentModel {
override def buildString(sb: StringBuilder): StringBuilder = sb.append("(#PCDATA)")
}
Expand All @@ -91,16 +102,16 @@ case object ANY extends ContentModel {
}
sealed abstract class DFAContentModel extends ContentModel {
import ContentModel.{ ElemName, Translator }
def r: ContentModel.RegExp
def r: RegExp

lazy val dfa: DetWordAutom[ElemName] = {
val nfa = Translator.automatonFrom(r, 1)
new SubsetConstruction(nfa).determinize
}
}

case class MIXED(r: ContentModel.RegExp) extends DFAContentModel {
import ContentModel.{ Alt, RegExp }
case class MIXED(r: RegExp) extends DFAContentModel {
import ContentModel.Alt

override def buildString(sb: StringBuilder): StringBuilder = {
val newAlt = r match { case Alt(rs@_*) => Alt(rs drop 1: _*) }
Expand All @@ -111,7 +122,7 @@ case class MIXED(r: ContentModel.RegExp) extends DFAContentModel {
}
}

case class ELEMENTS(r: ContentModel.RegExp) extends DFAContentModel {
case class ELEMENTS(r: RegExp) extends DFAContentModel {
override def buildString(sb: StringBuilder): StringBuilder =
ContentModel.buildString(r, sb)
}
1 change: 1 addition & 0 deletions src/main/scala/scala/xml/dtd/impl/WordBerrySethi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import scala.collection.{ immutable, mutable }
* @version 1.0
*/
// TODO: still used in ContentModel -- @deprecated("This class will be removed", "2.10.0")
@deprecated("This class will be removed", "2.10.0")
private[dtd] abstract class WordBerrySethi extends BaseBerrySethi {
override val lang: WordExp

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/scala/xml/pull/XMLEventReader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ trait ProducerConsumerIterator[T >: Null] extends Iterator[T] {
// defaults to unbounded - override to positive Int if desired
val MaxQueueSize = -1

def interruptibly[T](body: => T): Option[T] = try Some(body) catch {
def interruptibly[A](body: => A): Option[A] = try Some(body) catch {
case _: InterruptedException =>
Thread.currentThread.interrupt(); None
case _: ClosedChannelException => None
Expand Down
6 changes: 3 additions & 3 deletions src/test/scala/scala/xml/ShouldCompile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class Foo {
}

// t2281
class A {
class t2281A {
def f(x: Boolean) = if (x) <br/><br/> else <br/>
}

class B {
class t2281B {
def splitSentences(text: String): ArrayBuffer[String] = {
val outarr = new ArrayBuffer[String]
var outstr = new StringBuffer
Expand Down Expand Up @@ -92,4 +92,4 @@ object shouldCompile {
case 1 => <xml:group></xml:group>
case 2 => <p></p>
}
}
}
2 changes: 2 additions & 0 deletions src/test/scala/scala/xml/XMLTest.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.xml

import language.postfixOps

import org.junit.{Test => UnitTest}
import org.junit.Ignore
import org.junit.runner.RunWith
Expand Down