Skip to content

Changes in preparation for the 2.13 collections #202

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 3 commits 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
14 changes: 7 additions & 7 deletions jvm/src/test/scala/scala/xml/ReuseNodesTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ import org.junit.runner.RunWith
object ReuseNodesTest {

class OriginalTranformr(rules: RewriteRule*) extends RuleTransformer(rules:_*) {
override def transform(ns: Seq[Node]): Seq[Node] = {
override def transform(ns: collection.Seq[Node]): collection.Seq[Node] = {
val xs = ns.toStream map transform
val (xs1, xs2) = xs zip ns span { case (x, n) => unchanged(n, x) }

if (xs2.isEmpty) ns
else (xs1 map (_._2)) ++ xs2.head._1 ++ transform(ns drop (xs1.length + 1))
}
override def transform(n:Node): Seq[Node] = super.transform(n)
override def transform(n:Node): collection.Seq[Node] = super.transform(n)
}

class ModifiedTranformr(rules: RewriteRule*) extends RuleTransformer(rules:_*) {
override def transform(ns: Seq[Node]): Seq[Node] = {
override def transform(ns: collection.Seq[Node]): collection.Seq[Node] = {
val changed = ns flatMap transform

if (changed.length != ns.length || (changed, ns).zipped.exists(_ != _)) changed
else ns
}
override def transform(n:Node): Seq[Node] = super.transform(n)
override def transform(n:Node): collection.Seq[Node] = super.transform(n)
}

class AlternateTranformr(rules: RewriteRule*) extends RuleTransformer(rules:_*) {
override def transform(ns: Seq[Node]): Seq[Node] = {
override def transform(ns: collection.Seq[Node]): collection.Seq[Node] = {
val xs = ns.toStream map transform
val (xs1, xs2) = xs zip ns span { case (x, n) => unchanged(n, x) }

if (xs2.isEmpty) ns
else (xs1 map (_._2)) ++ xs2.head._1 ++ transform(ns drop (xs1.length + 1))
}
override def transform(n:Node): Seq[Node] = super.transform(n)
override def transform(n:Node): collection.Seq[Node] = super.transform(n)
}

def rewriteRule = new RewriteRule {
Expand Down Expand Up @@ -80,7 +80,7 @@ class ReuseNodesTest {
recursiveAssert(original,transformed)
}

def recursiveAssert(original:Seq[Node], transformed:Seq[Node]):Unit = {
def recursiveAssert(original: collection.Seq[Node], transformed: collection.Seq[Node]):Unit = {
original zip transformed foreach {
case (x, y) => recursiveAssert(x, y)
}
Expand Down
2 changes: 1 addition & 1 deletion jvm/src/test/scala/scala/xml/SerializationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SerializationTest {
@Test
def implicitConversion: Unit = {
val parent = <parent><child></child><child/></parent>
val children: Seq[Node] = parent.child
val children: collection.Seq[Node] = parent.child
val asNodeSeq: NodeSeq = children
assertEquals(asNodeSeq, JavaByteSerialization.roundTrip(asNodeSeq))
}
Expand Down
4 changes: 2 additions & 2 deletions jvm/src/test/scala/scala/xml/XMLTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,9 @@ class XMLTestJVM {
def attributes = {
val noAttr = <t/>
val attrNull = <t a={ null: String }/>
val attrNone = <t a={ None: Option[Seq[Node]] }/>
val attrNone = <t a={ None: Option[collection.Seq[Node]] }/>
val preAttrNull = <t p:a={ null: String }/>
val preAttrNone = <t p:a={ None: Option[Seq[Node]] }/>
val preAttrNone = <t p:a={ None: Option[collection.Seq[Node]] }/>
assertEquals(noAttr, attrNull)
assertEquals(noAttr, attrNone)
assertEquals(noAttr, preAttrNull)
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.12")
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.14")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22")
2 changes: 1 addition & 1 deletion shared/src/main/scala/scala/xml/Atom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Atom[+A](val data: A) extends SpecialNode with Serializable {
if (data == null)
throw new IllegalArgumentException("cannot construct " + getClass.getSimpleName + " with null")

override protected def basisForHashCode: Seq[Any] = Seq(data)
override protected def basisForHashCode: collection.Seq[Any] = Seq(data)

override def strict_==(other: Equality) = other match {
case x: Atom[_] => data == x.data
Expand Down
12 changes: 6 additions & 6 deletions shared/src/main/scala/scala/xml/Attribute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ object Attribute {
}

/** Convenience functions which choose Un/Prefixedness appropriately */
def apply(key: String, value: Seq[Node], next: MetaData): Attribute =
def apply(key: String, value: collection.Seq[Node], next: MetaData): Attribute =
new UnprefixedAttribute(key, value, next)

def apply(pre: String, key: String, value: String, next: MetaData): Attribute =
if (pre == null || pre == "") new UnprefixedAttribute(key, value, next)
else new PrefixedAttribute(pre, key, value, next)

def apply(pre: String, key: String, value: Seq[Node], next: MetaData): Attribute =
def apply(pre: String, key: String, value: collection.Seq[Node], next: MetaData): Attribute =
if (pre == null || pre == "") new UnprefixedAttribute(key, value, next)
else new PrefixedAttribute(pre, key, value, next)

def apply(pre: Option[String], key: String, value: Seq[Node], next: MetaData): Attribute =
def apply(pre: Option[String], key: String, value: collection.Seq[Node], next: MetaData): Attribute =
pre match {
case None => new UnprefixedAttribute(key, value, next)
case Some(p) => new PrefixedAttribute(p, key, value, next)
Expand All @@ -50,11 +50,11 @@ object Attribute {
abstract trait Attribute extends MetaData {
def pre: String // will be null if unprefixed
val key: String
val value: Seq[Node]
val value: collection.Seq[Node]
val next: MetaData

def apply(key: String): Seq[Node]
def apply(namespace: String, scope: NamespaceBinding, key: String): Seq[Node]
def apply(key: String): collection.Seq[Node]
def apply(namespace: String, scope: NamespaceBinding, key: String): collection.Seq[Node]
def copy(next: MetaData): Attribute

def remove(key: String) =
Expand Down
8 changes: 4 additions & 4 deletions shared/src/main/scala/scala/xml/Document.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Document extends NodeSeq with pull.XMLEvent with Serializable {
* excluded. If there is a document type declaration, the list also
* contains a document type declaration information item.
*/
var children: Seq[Node] = _
var children: collection.Seq[Node] = _

/** The element information item corresponding to the document element. */
var docElem: Node = _
Expand All @@ -43,14 +43,14 @@ class Document extends NodeSeq with pull.XMLEvent with Serializable {
* declared in the DTD. If any notation is multiply declared, this property
* has no value.
*/
def notations: Seq[scala.xml.dtd.NotationDecl] =
def notations: collection.Seq[scala.xml.dtd.NotationDecl] =
dtd.notations

/**
* An unordered set of unparsed entity information items, one for each
* unparsed entity declared in the DTD.
*/
def unparsedEntities: Seq[scala.xml.dtd.EntityDecl] =
def unparsedEntities: collection.Seq[scala.xml.dtd.EntityDecl] =
dtd.unparsedEntities

/** The base URI of the document entity. */
Expand Down Expand Up @@ -90,7 +90,7 @@ class Document extends NodeSeq with pull.XMLEvent with Serializable {

// methods for NodeSeq

def theSeq: Seq[Node] = this.docElem
def theSeq: collection.Seq[Node] = this.docElem

override def canEqual(other: Any) = other match {
case _: Document => true
Expand Down
4 changes: 2 additions & 2 deletions shared/src/main/scala/scala/xml/Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Elem(
// setting namespace scope if necessary
// cleaning adjacent text nodes if necessary

override protected def basisForHashCode: Seq[Any] =
override protected def basisForHashCode: collection.Seq[Any] =
prefix :: label :: attributes :: child.toList

/**
Expand All @@ -136,7 +136,7 @@ class Elem(
attributes: MetaData = this.attributes,
scope: NamespaceBinding = this.scope,
minimizeEmpty: Boolean = this.minimizeEmpty,
child: Seq[Node] = this.child.toSeq): Elem = Elem(prefix, label, attributes, scope, minimizeEmpty, child: _*)
child: collection.Seq[Node] = this.child.toSeq): Elem = Elem(prefix, label, attributes, scope, minimizeEmpty, child: _*)

/**
* Returns concatenation of `text(n)` for each child `n`.
Expand Down
4 changes: 2 additions & 2 deletions shared/src/main/scala/scala/xml/Equality.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ package xml
*
* Among the obstacles to sanity are/were:
*
* Node extends NodeSeq extends Seq[Node]
* Node extends NodeSeq extends collection.Seq[Node]
* MetaData extends Iterable[MetaData]
* The hacky "Group" xml node which throws exceptions
* with wild abandon, so don't get too close
Expand Down Expand Up @@ -69,7 +69,7 @@ object Equality {
import Equality._

trait Equality extends scala.Equals {
protected def basisForHashCode: Seq[Any]
protected def basisForHashCode: collection.Seq[Any]

def strict_==(other: Equality): Boolean
def strict_!=(other: Equality) = !strict_==(other)
Expand Down
2 changes: 1 addition & 1 deletion shared/src/main/scala/scala/xml/Group.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package xml
*
* @author Burak Emir
*/
final case class Group(nodes: Seq[Node]) extends Node {
final case class Group(nodes: collection.Seq[Node]) extends Node {
override def theSeq = nodes

override def canEqual(other: Any) = other match {
Expand Down
24 changes: 12 additions & 12 deletions shared/src/main/scala/scala/xml/MetaData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ abstract class MetaData
* Gets value of unqualified (unprefixed) attribute with given key, null if not found
*
* @param key
* @return value as Seq[Node] if key is found, null otherwise
* @return value as collection.Seq[Node] if key is found, null otherwise
*/
def apply(key: String): Seq[Node]
def apply(key: String): collection.Seq[Node]

/**
* convenience method, same as `apply(namespace, owner.scope, key)`.
Expand All @@ -110,7 +110,7 @@ abstract class MetaData
* @param owner the element owning this attribute list
* @param key the attribute key
*/
final def apply(namespace_uri: String, owner: Node, key: String): Seq[Node] =
final def apply(namespace_uri: String, owner: Node, key: String): collection.Seq[Node] =
apply(namespace_uri, owner.scope, key)

/**
Expand All @@ -119,9 +119,9 @@ abstract class MetaData
* @param namespace_uri namespace uri of key
* @param scp a namespace scp (usually of the element owning this attribute list)
* @param k to be looked for
* @return value as Seq[Node] if key is found, null otherwise
* @return value as collection.Seq[Node] if key is found, null otherwise
*/
def apply(namespace_uri: String, scp: NamespaceBinding, k: String): Seq[Node]
def apply(namespace_uri: String, scp: NamespaceBinding, k: String): collection.Seq[Node]

/**
* returns a copy of this MetaData item with next field set to argument.
Expand All @@ -147,7 +147,7 @@ abstract class MetaData
case m: MetaData => this.asAttrMap == m.asAttrMap
case _ => false
}
protected def basisForHashCode: Seq[Any] = List(this.asAttrMap)
protected def basisForHashCode: collection.Seq[Any] = List(this.asAttrMap)

/** filters this sequence of meta data */
override def filter(f: MetaData => Boolean): MetaData =
Expand All @@ -158,7 +158,7 @@ abstract class MetaData
def key: String

/** returns value of this MetaData item */
def value: Seq[Node]
def value: collection.Seq[Node]

/**
* Returns a String containing "prefix:key" if the first key is
Expand All @@ -182,12 +182,12 @@ abstract class MetaData
* Gets value of unqualified (unprefixed) attribute with given key, None if not found
*
* @param key
* @return value in Some(Seq[Node]) if key is found, None otherwise
* @return value in Some(collection.Seq[Node]) if key is found, None otherwise
*/
final def get(key: String): Option[Seq[Node]] = Option(apply(key))
final def get(key: String): Option[collection.Seq[Node]] = Option(apply(key))

/** same as get(uri, owner.scope, key) */
final def get(uri: String, owner: Node, key: String): Option[Seq[Node]] =
final def get(uri: String, owner: Node, key: String): Option[collection.Seq[Node]] =
get(uri, owner.scope, key)

/**
Expand All @@ -196,9 +196,9 @@ abstract class MetaData
* @param uri namespace of key
* @param scope a namespace scp (usually of the element owning this attribute list)
* @param key to be looked fore
* @return value as Some[Seq[Node]] if key is found, None otherwise
* @return value as Some[collection.Seq[Node]] if key is found, None otherwise
*/
final def get(uri: String, scope: NamespaceBinding, key: String): Option[Seq[Node]] =
final def get(uri: String, scope: NamespaceBinding, key: String): Option[collection.Seq[Node]] =
Option(apply(uri, scope, key))

protected def toString1(): String = sbToString(toString1)
Expand Down
2 changes: 1 addition & 1 deletion shared/src/main/scala/scala/xml/NamespaceBinding.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ case class NamespaceBinding(prefix: String, uri: String, parent: NamespaceBindin
case _ => false
}

def basisForHashCode: Seq[Any] = List(prefix, uri, parent)
def basisForHashCode: collection.Seq[Any] = List(prefix, uri, parent)

def buildString(stop: NamespaceBinding): String = sbToString(buildString(_, stop))

Expand Down
12 changes: 6 additions & 6 deletions shared/src/main/scala/scala/xml/Node.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ abstract class Node extends NodeSeq {
* @return value of `UnprefixedAttribute` with given key
* in attributes, if it exists, otherwise `null`.
*/
final def attribute(key: String): Option[Seq[Node]] = attributes.get(key)
final def attribute(key: String): Option[collection.Seq[Node]] = attributes.get(key)

/**
* Convenience method, looks up a prefixed attribute in attributes of this node.
Expand All @@ -96,7 +96,7 @@ abstract class Node extends NodeSeq {
* @return value of `PrefixedAttribute` with given namespace
* and given key, otherwise `'''null'''`.
*/
final def attribute(uri: String, key: String): Option[Seq[Node]] =
final def attribute(uri: String, key: String): Option[collection.Seq[Node]] =
attributes.get(uri, this, key)

/**
Expand All @@ -113,12 +113,12 @@ abstract class Node extends NodeSeq {
*
* @return all children of this node
*/
def child: Seq[Node]
def child: collection.Seq[Node]

/**
* Children which do not stringify to "" (needed for equality)
*/
def nonEmptyChildren: Seq[Node] = child filterNot (_.toString == "")
def nonEmptyChildren: collection.Seq[Node] = child filterNot (_.toString == "")

/**
* Descendant axis (all descendants of this node, not including node itself)
Expand All @@ -139,7 +139,7 @@ abstract class Node extends NodeSeq {
case _ => false
}

override protected def basisForHashCode: Seq[Any] =
override protected def basisForHashCode: collection.Seq[Any] =
prefix :: label :: attributes :: nonEmptyChildren.toList

override def strict_==(other: Equality) = other match {
Expand All @@ -159,7 +159,7 @@ abstract class Node extends NodeSeq {
/**
* returns a sequence consisting of only this node
*/
def theSeq: Seq[Node] = this :: Nil
def theSeq: collection.Seq[Node] = this :: Nil

/**
* String representation of this node
Expand Down
2 changes: 1 addition & 1 deletion shared/src/main/scala/scala/xml/NodeBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package xml

/**
* This class acts as a Buffer for nodes. If it is used as a sequence of
* nodes `Seq[Node]`, it must be ensured that no updates occur after that
* nodes `collection.Seq[Node]`, it must be ensured that no updates occur after that
* point, because `scala.xml.Node` is assumed to be immutable.
*
* Despite this being a sequence, don't use it as key in a hashtable.
Expand Down
10 changes: 5 additions & 5 deletions shared/src/main/scala/scala/xml/NodeSeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import scala.language.implicitConversions
*/
object NodeSeq {
final val Empty = fromSeq(Nil)
def fromSeq(s: Seq[Node]): NodeSeq = new NodeSeq {
def fromSeq(s: collection.Seq[Node]): NodeSeq = new NodeSeq {
def theSeq = s
}
type Coll = NodeSeq
Expand All @@ -31,11 +31,11 @@ object NodeSeq {
def apply() = newBuilder
}
def newBuilder: Builder[Node, NodeSeq] = new ListBuffer[Node] mapResult fromSeq
implicit def seqToNodeSeq(s: Seq[Node]): NodeSeq = fromSeq(s)
implicit def seqToNodeSeq(s: collection.Seq[Node]): NodeSeq = fromSeq(s)
}

/**
* This class implements a wrapper around `Seq[Node]` that adds XPath
* This class implements a wrapper around `collection.Seq[Node]` that adds XPath
* and comprehension methods.
*
* @author Burak Emir
Expand All @@ -45,7 +45,7 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S
/** Creates a list buffer as builder for this class */
override protected[this] def newBuilder = NodeSeq.newBuilder

def theSeq: Seq[Node]
def theSeq: collection.Seq[Node]
def length = theSeq.length
override def iterator = theSeq.iterator

Expand All @@ -62,7 +62,7 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S
!these.hasNext && !those.hasNext
}

protected def basisForHashCode: Seq[Any] = theSeq
protected def basisForHashCode: collection.Seq[Any] = theSeq

override def canEqual(other: Any) = other match {
case _: NodeSeq => true
Expand Down
Loading