Skip to content

Commit 16374df

Browse files
committed
cleanup
- fix some dangling ScalaDoc references - drop `()` after `toString` and a few other methods - replace unused pattern variables with `_` - remove code duplication in name-splitting
1 parent 0ccb010 commit 16374df

31 files changed

+131
-146
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
150150
retrieveDir,
151151
log
152152
)
153-
.fold(w => throw w.resolveException, identity(_))
153+
.fold(w => throw w.resolveException, identity)
154154
val jarPath = cp
155155
.find(_.toString.contains("junit-plugin"))
156156
.getOrElse(throw new Exception("Can't find Scala Native junit-plugin jar"))

jvm/src/test/scala/scala/xml/XMLTest.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class XMLTestJVM {
3333
def equality(): Unit = {
3434
val c: Node = new Node {
3535
override def label: String = "hello"
36-
override def hashCode(): Int =
36+
override def hashCode: Int =
3737
Utility.hashCode(prefix, label, this.attributes.hashCode(), scope.hashCode(), child)
3838
override def child: Seq[Node] = Elem(null, "world", e, sc)
3939
//def attributes = e
@@ -54,7 +54,6 @@ class XMLTestJVM {
5454
Elem(null, "author", e, sc, Text("Peter Buneman")),
5555
Elem(null, "author", e, sc, Text("Dan Suciu")),
5656
Elem(null, "title", e, sc, Text("Data on ze web"))), x2p)
57-
5857
}
5958

6059
@UnitTest
@@ -640,7 +639,7 @@ class XMLTestJVM {
640639
parserFactory.setNamespaceAware(namespaceAware)
641640
parserFactory.setXIncludeAware(namespaceAware)
642641

643-
assertEquals(xml, XML.withSAXParser(parserFactory.newSAXParser).loadString(xml).toString())
642+
assertEquals(xml, XML.withSAXParser(parserFactory.newSAXParser).loadString(xml).toString)
644643
}
645644

646645
@UnitTest

shared/src/main/scala/scala/xml/Attribute.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,19 @@ trait Attribute extends MetaData {
6565

6666
override def remove(key: String): MetaData =
6767
if (!isPrefixed && this.key == key) next
68-
else copy(next remove key)
68+
else copy(next.remove(key))
6969

7070
override def remove(namespace: String, scope: NamespaceBinding, key: String): MetaData =
71-
if (this.key == key && (scope getURI pre) == namespace) next
71+
if (this.key == key && scope.getURI(pre) == namespace) next
7272
else copy(next.remove(namespace, scope, key))
7373

7474
override def isPrefixed: Boolean = pre != null
7575

7676
override def getNamespace(owner: Node): String
7777

7878
override def wellformed(scope: NamespaceBinding): Boolean = {
79-
val arg: String = if (isPrefixed) scope getURI pre else null
80-
(next(arg, scope, key) == null) && (next wellformed scope)
79+
val arg: String = if (isPrefixed) scope.getURI(pre) else null
80+
(next(arg, scope, key) == null) && next.wellformed(scope)
8181
}
8282

8383
/** Returns an iterator on attributes */
@@ -98,9 +98,9 @@ trait Attribute extends MetaData {
9898
if (value == null)
9999
return
100100
if (isPrefixed)
101-
sb append pre append ':'
101+
sb.append(pre).append(':')
102102

103-
sb append key append '='
103+
sb.append(key).append('=')
104104
val sb2: StringBuilder = new StringBuilder()
105105
Utility.sequenceToXML(value, TopScope, sb2, stripComments = true)
106106
Utility.appendQuoted(sb2.toString, sb)

shared/src/main/scala/scala/xml/Equality.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ trait Equality extends scala.Equals {
8585
* which heads off a lot of inconsistency up front.
8686
*/
8787
override def canEqual(other: Any): Boolean = other match {
88-
case x: Equality => true
88+
case _: Equality => true
8989
case _ => false
9090
}
9191

@@ -96,7 +96,7 @@ trait Equality extends scala.Equals {
9696
* are final since clearly individual classes cannot be trusted
9797
* to maintain a semblance of order.
9898
*/
99-
override def hashCode(): Int = basisForHashCode.##
99+
override def hashCode: Int = basisForHashCode.##
100100
override def equals(other: Any): Boolean = doComparison(other, blithe = false)
101101
final def xml_==(other: Any): Boolean = doComparison(other, blithe = true)
102102
final def xml_!=(other: Any): Boolean = !xml_==(other)

shared/src/main/scala/scala/xml/Group.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final case class Group(nodes: Seq[Node]) extends Node {
2424
override def theSeq: Seq[Node] = nodes
2525

2626
override def canEqual(other: Any): Boolean = other match {
27-
case x: Group => true
27+
case _: Group => true
2828
case _ => false
2929
}
3030

shared/src/main/scala/scala/xml/MetaData.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ object MetaData {
7575
* attributes. Every instance of this class is either
7676
* - an instance of `UnprefixedAttribute key,value` or
7777
* - an instance of `PrefixedAttribute namespace_prefix,key,value` or
78-
* - `Null, the empty attribute list.
78+
* - `Null`, the empty attribute list.
7979
*
8080
* Namespace URIs are obtained by using the namespace scope of the element
8181
* owning this attribute (see `getNamespace`).
@@ -204,17 +204,17 @@ abstract class MetaData
204204
* @param uri namespace of key
205205
* @param scope a namespace scp (usually of the element owning this attribute list)
206206
* @param key to be looked fore
207-
* @return value as Some[Seq[Node]] if key is found, None otherwise
207+
* @return value as `Some[Seq[Node]]` if key is found, None otherwise
208208
*/
209209
final def get(uri: String, scope: NamespaceBinding, key: String): Option[Seq[Node]] =
210210
Option(apply(uri, scope, key))
211211

212-
protected def toString1(): String = sbToString(toString1)
212+
protected def toString1: String = sbToString(toString1)
213213

214214
// appends string representations of single attribute to StringBuilder
215215
protected def toString1(sb: StringBuilder): Unit
216216

217-
override def toString(): String = sbToString(buildString)
217+
override def toString: String = sbToString(buildString)
218218

219219
def buildString(sb: StringBuilder): StringBuilder = {
220220
sb append ' '

shared/src/main/scala/scala/xml/Node.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ abstract class Node extends NodeSeq {
140140
def descendant_or_self: List[Node] = this :: descendant
141141

142142
override def canEqual(other: Any): Boolean = other match {
143-
case x: Group => false
144-
case x: Node => true
143+
case _: Group => false
144+
case _: Node => true
145145
case _ => false
146146
}
147147

@@ -178,7 +178,7 @@ abstract class Node extends NodeSeq {
178178
/**
179179
* Same as `toString('''false''')`.
180180
*/
181-
override def toString(): String = buildString(stripComments = false)
181+
override def toString: String = buildString(stripComments = false)
182182

183183
/**
184184
* Appends qualified name of this node to `StringBuilder`.
@@ -194,7 +194,7 @@ abstract class Node extends NodeSeq {
194194
/**
195195
* Returns a type symbol (e.g. DTD, XSD), default `'''null'''`.
196196
*/
197-
def xmlType(): TypeSymbol = null
197+
def xmlType: TypeSymbol = null
198198

199199
/**
200200
* Returns a text representation of this node. Note that this is not equivalent to

shared/src/main/scala/scala/xml/NodeSeq.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S
102102
else if (that(1) == '{') {
103103
val i: Int = that indexOf '}'
104104
if (i == -1) fail
105-
val (uri: String, key: String) = (that.substring(2, i), that.substring(i + 1, that.length()))
105+
val (uri: String, key: String) = (that.substring(2, i), that.substring(i + 1, that.length))
106106
if (uri == "" || key == "") fail
107107
else y.attribute(uri, key)
108108
} else y.attribute(that drop 1)
@@ -128,7 +128,7 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S
128128
/**
129129
* Projection function, which returns elements of `this` sequence and of
130130
* all its subsequences, based on the string `that`. Use:
131-
* - `this \\ "foo" to get a list of all elements that are labelled with `"foo"`,
131+
* - `this \\ "foo"` to get a list of all elements that are labelled with "foo"`,
132132
* including `this`;
133133
* - `this \\ "_"` to get a list of all elements (wildcard), including `this`;
134134
* - `this \\ "@foo"` to get all unprefixed attributes `"foo"`;
@@ -159,7 +159,7 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S
159159
*/
160160
def \@(attributeName: String): String = (this \ ("@" + attributeName)).text
161161

162-
override def toString(): String = theSeq.mkString
162+
override def toString: String = theSeq.mkString
163163

164164
def text: String = (this map (_.text)).mkString
165165
}

shared/src/main/scala/scala/xml/Null.scala

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

16-
import Utility.isNameStart
1716
import scala.collection.Iterator
1817
import scala.collection.Seq
1918

@@ -50,13 +49,13 @@ case object Null extends MetaData {
5049

5150
override def apply(namespace: String, scope: NamespaceBinding, key: String) /* TODO type annotation */ = null
5251
override def apply(key: String) /* TODO type annotation */ =
53-
if (isNameStart(key.head)) null
52+
if (Utility.isNameStart(key.head)) null
5453
else throw new IllegalArgumentException("not a valid attribute name '" + key + "', so can never match !")
5554

5655
override protected def toString1(sb: StringBuilder): Unit = ()
57-
override protected def toString1(): String = ""
56+
override protected def toString1: String = ""
5857

59-
override def toString(): String = ""
58+
override def toString: String = ""
6059

6160
override def buildString(sb: StringBuilder): StringBuilder = sb
6261

shared/src/main/scala/scala/xml/PrettyPrinter.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ class PrettyPrinter(width: Int, step: Int, minimizeEmpty: Boolean) {
150150

151151
protected def traverse(node: Node, pscope: NamespaceBinding, ind: Int): Unit = node match {
152152

153-
case Text(s) if s.trim() == "" =>
153+
case Text(s) if s.trim == "" =>
154154

155155
case _: Atom[_] | _: Comment | _: EntityRef | _: ProcInstr =>
156-
makeBox(ind, node.toString().trim())
157-
case g@Group(xs) =>
156+
makeBox(ind, node.toString.trim)
157+
case Group(xs) =>
158158
traverse(xs.iterator, pscope, ind)
159159
case _ =>
160160
val test: String = {

0 commit comments

Comments
 (0)