Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e044d5d

Browse files
committed
Use immutable.Seq in utilities
1 parent 0023e93 commit e044d5d

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

‎build.sbt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
8787
// Synthetic static accessors (for Java interop) have a changed return type
8888
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.xml.Null.apply"),
8989
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.xml.Null.value"),
90+
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.xml.Utility.parseAttributeValue"),
91+
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.xml.Utility.trimProper"),
9092

9193
// used to be a declared method, now a bridge without generic signature
9294
ProblemFilters.exclude[IncompatibleSignatureProblem]("scala.xml.MetaData.apply"),
@@ -99,6 +101,9 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
99101
ProblemFilters.exclude[IncompatibleSignatureProblem]("scala.xml.Document.theSeq"),
100102
ProblemFilters.exclude[IncompatibleSignatureProblem]("scala.xml.Group.theSeq"),
101103
ProblemFilters.exclude[IncompatibleSignatureProblem]("scala.xml.Node.theSeq"),
104+
ProblemFilters.exclude[IncompatibleSignatureProblem]("scala.xml.TextBuffer.toText"),
105+
ProblemFilters.exclude[IncompatibleSignatureProblem]("scala.xml.Utility.trimProper"),
106+
ProblemFilters.exclude[IncompatibleSignatureProblem]("scala.xml.Utility.parseAttributeValue"),
102107

103108
// Option[c.Seq] => Option[i.Seq] results in a changed generic signature
104109
ProblemFilters.exclude[IncompatibleSignatureProblem]("scala.xml.MetaData.get"),

‎shared/src/main/scala-2.12/scala/xml/ScalaVersionSpecific.scala‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ private[xml] object ScalaVersionSpecific {
2323
override def apply(): mutable.Builder[Node, NodeSeq] = NodeSeq.newBuilder
2424
}
2525
type SeqOfNode = scala.collection.Seq[Node]
26+
type SeqOfText = scala.collection.Seq[Text]
2627
}
2728

2829
private[xml] trait ScalaVersionSpecificNodeSeq extends SeqLike[Node, NodeSeq] { self: NodeSeq =>
@@ -37,3 +38,7 @@ private[xml] trait ScalaVersionSpecificNodeBuffer { self: NodeBuffer =>
3738
private[xml] trait ScalaVersionSpecificNode { self: Node => }
3839

3940
private[xml] trait ScalaVersionSpecificMetaData { self: MetaData => }
41+
42+
private[xml] trait ScalaVersionSpecificTextBuffer { self: TextBuffer => }
43+
44+
private[xml] trait ScalaVersionSpecificUtility { self: Utility.type => }

‎shared/src/main/scala-2.13+/scala/xml/ScalaVersionSpecific.scala‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ private[xml] object ScalaVersionSpecific {
2525
def fromSpecific(from: Coll)(it: IterableOnce[Node]): NodeSeq = (NodeSeq.newBuilder ++= from).result()
2626
}
2727
type SeqOfNode = scala.collection.immutable.Seq[Node]
28+
type SeqOfText = scala.collection.immutable.Seq[Text]
2829
}
2930

3031
private[xml] trait ScalaVersionSpecificNodeSeq
@@ -70,3 +71,12 @@ private[xml] trait ScalaVersionSpecificMetaData { self: MetaData =>
7071

7172
def value: scala.collection.Seq[Node]
7273
}
74+
75+
private[xml] trait ScalaVersionSpecificTextBuffer { self: TextBuffer =>
76+
def toText: scala.collection.Seq[Text]
77+
}
78+
79+
private[xml] trait ScalaVersionSpecificUtility { self: Utility.type =>
80+
def trimProper(x: Node): scala.collection.Seq[Node]
81+
def parseAttributeValue(value: String): scala.collection.Seq[Node]
82+
}

‎shared/src/main/scala/scala/xml/TextBuffer.scala‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ package scala
1414
package xml
1515

1616
import scala.collection.Seq
17+
import scala.collection.immutable.{Seq => ISeq}
1718
import Utility.isSpace
1819

1920
object TextBuffer {
@@ -26,7 +27,7 @@ object TextBuffer {
2627
* appended with the `append` method will be replaced by a single space
2728
* character, and leading and trailing space will be removed completely.
2829
*/
29-
class TextBuffer {
30+
class TextBuffer extendsScalaVersionSpecificTextBuffer{
3031
val sb: StringBuilder = new StringBuilder()
3132

3233
/**
@@ -45,8 +46,8 @@ class TextBuffer {
4546
*
4647
* @return the text without whitespaces.
4748
*/
48-
def toText: Seq[Text] = sb.toString.trim match {
49+
def toText: ScalaVersionSpecific.SeqOfText = sb.toString.trim match {
4950
case "" => Nil
50-
case s => Seq(Text(s))
51+
case s => ISeq(Text(s))
5152
}
5253
}

‎shared/src/main/scala/scala/xml/Utility.scala‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import scala.collection.immutable.{Seq => ISeq}
2525
*
2626
* @author Burak Emir
2727
*/
28-
object Utility extends AnyRef with parsing.TokenTests {
28+
object Utility extends AnyRef with parsing.TokenTests withScalaVersionSpecificUtility{
2929
final val SU: Char = '\u001A'
3030

3131
// [Martin] This looks dubious. We don't convert StringBuilders to
@@ -66,7 +66,7 @@ object Utility extends AnyRef with parsing.TokenTests {
6666
* trim a child of an element. `Attribute` values and `Atom` nodes that
6767
* are not `Text` nodes are unaffected.
6868
*/
69-
def trimProper(x: Node): Seq[Node] = x match {
69+
def trimProper(x: Node): ScalaVersionSpecific.SeqOfNode = x match {
7070
case Elem(pre, lab, md, scp, child@_*) =>
7171
val children = combineAdjacentTextNodes(child).flatMap(trimProper)
7272
Elem(pre, lab, md, scp, children.isEmpty, children: _*)
@@ -355,7 +355,7 @@ object Utility extends AnyRef with parsing.TokenTests {
355355
}
356356

357357
// unused, untested
358-
def parseAttributeValue(value: String): Seq[Node] = {
358+
def parseAttributeValue(value: String): ScalaVersionSpecific.SeqOfNode = {
359359
val sb: StringBuilder = new StringBuilder
360360
var rfb: StringBuilder = null
361361
val nb: NodeBuffer = new NodeBuffer()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /