Skip to content

Commit e0cbe97

Browse files
committed
Fix mima errors
Maybe just whitelist binary incompatabilities instead with mimaBinaryIssueFilters? https://github.com/typesafehub/migration-manager/wiki/sbt-plugin
1 parent a30715e commit e0cbe97

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

shared/src/main/scala/scala/xml/factory/XMLLoader.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ trait XMLLoader[T <: Node] {
3737
def loadXML(source: InputSource, parser: SAXParser): T = {
3838
val newAdapter = adapter
3939

40-
newAdapter.scopeStack = TopScope :: newAdapter.scopeStack
40+
newAdapter.scopes = TopScope :: newAdapter.scopes
4141
parser.parse(source, newAdapter)
42-
newAdapter.scopeStack = newAdapter.scopeStack.tail
42+
newAdapter.scopes = newAdapter.scopes.tail
4343

4444
newAdapter.rootElem.asInstanceOf[T]
4545
}

shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala

+28-21
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ package scala
1010
package xml
1111
package parsing
1212

13+
import scala.collection.mutable
1314
import org.xml.sax.Attributes
1415
import org.xml.sax.helpers.DefaultHandler
1516

@@ -38,10 +39,16 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
3839
var rootElem: Node = null
3940

4041
val buffer = new StringBuilder()
41-
var attribStack = List.empty[MetaData]
42-
var hStack = List.empty[Node] // [ element ] contains siblings
43-
var tagStack = List.empty[String]
44-
var scopeStack = List.empty[NamespaceBinding]
42+
var attribs = List.empty[MetaData]
43+
var nodes = List.empty[Node] // [ element ] contains siblings
44+
var tags = List.empty[String]
45+
var scopes = List.empty[NamespaceBinding]
46+
47+
// Fix compatability issues. Add MiMa exclusion rules, instead?
48+
var attribStack = mutable.Stack(attribs)
49+
var hStack = mutable.Stack(nodes)
50+
var tagStack = mutable.Stack(tags)
51+
var scopeStack = mutable.Stack(scopes)
4552

4653
var curTag: String = null
4754
var capture: Boolean = false
@@ -121,17 +128,17 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
121128
attributes: Attributes): Unit =
122129
{
123130
captureText()
124-
tagStack = curTag :: tagStack
131+
tags = curTag :: tags
125132
curTag = qname
126133

127134
val localName = splitName(qname)._2
128135
capture = nodeContainsText(localName)
129136

130-
hStack = null :: hStack
137+
nodes = null :: nodes
131138
var m: MetaData = Null
132139
var scpe: NamespaceBinding =
133-
if (scopeStack.isEmpty) TopScope
134-
else scopeStack.head
140+
if (scopes.isEmpty) TopScope
141+
else scopes.head
135142

136143
for (i <- 0 until attributes.getLength()) {
137144
val qname = attributes getQName i
@@ -146,16 +153,16 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
146153
m = Attribute(Option(pre), key, Text(value), m)
147154
}
148155

149-
scopeStack = scpe :: scopeStack
150-
attribStack = m :: attribStack
156+
scopes = scpe :: scopes
157+
attribs = m :: attribs
151158
}
152159

153160
/**
154161
* captures text, possibly normalizing whitespace
155162
*/
156163
def captureText(): Unit = {
157164
if (capture && buffer.length > 0)
158-
hStack = createText(buffer.toString) :: hStack
165+
nodes = createText(buffer.toString) :: nodes
159166

160167
buffer.clear()
161168
}
@@ -169,24 +176,24 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
169176
*/
170177
override def endElement(uri: String, _localName: String, qname: String): Unit = {
171178
captureText()
172-
val metaData = attribStack.head
173-
attribStack = attribStack.tail
179+
val metaData = attribs.head
180+
attribs = attribs.tail
174181

175182
// reverse order to get it right
176-
val v = hStack.takeWhile(_ != null).reverse
177-
hStack = hStack.dropWhile(_ != null) match {
183+
val v = nodes.takeWhile(_ != null).reverse
184+
nodes = nodes.dropWhile(_ != null) match {
178185
case null :: hs => hs
179186
case hs => hs
180187
}
181188
val (pre, localName) = splitName(qname)
182-
val scp = scopeStack.head
183-
scopeStack = scopeStack.tail
189+
val scp = scopes.head
190+
scopes = scopes.tail
184191

185192
// create element
186193
rootElem = createNode(pre, localName, metaData, scp, v)
187-
hStack = rootElem :: hStack
188-
curTag = tagStack.head
189-
tagStack = tagStack.tail
194+
nodes = rootElem :: nodes
195+
curTag = tags.head
196+
tags = tags.tail
190197
capture = curTag != null && nodeContainsText(curTag) // root level
191198
}
192199

@@ -195,6 +202,6 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
195202
*/
196203
override def processingInstruction(target: String, data: String) {
197204
captureText()
198-
hStack = hStack.reverse_:::(createProcInstr(target, data).toList)
205+
nodes = nodes.reverse_:::(createProcInstr(target, data).toList)
199206
}
200207
}

0 commit comments

Comments
 (0)