Skip to content

Commit

Permalink
same input. same output.
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Nov 21, 2010
1 parent 57294eb commit 7f5472a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions src/main/scala/scalaxb/compiler/xsd/Decl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ import scala.collection.immutable

abstract class Decl

object Incrementor {
var i: Int = 1000
def nextInt: Int = {
i = i + 1
i
}
}

case class XsdContext(
schemas: mutable.ListBuffer[SchemaDecl] =
mutable.ListBuffer.empty[SchemaDecl],
Expand Down Expand Up @@ -67,7 +75,7 @@ class ParserConfig {
val attrList = mutable.ListBuffer.empty[AttributeDecl]
val topGroups = mutable.ListMap.empty[String, GroupDecl]
val topAttrGroups = mutable.ListMap.empty[String, AttributeGroupDecl]
val choices = mutable.Set.empty[ChoiceDecl]
val choices = mutable.ListBuffer.empty[ChoiceDecl]
var schemas: List[SchemaDecl] = Nil
val typeToAnnotatable = mutable.ListMap.empty[TypeDecl, Annotatable]

Expand Down Expand Up @@ -146,7 +154,7 @@ case class SchemaDecl(targetNamespace: Option[String],
elemList: List[ElemDecl],
topTypes: Map[String, TypeDecl],
typeList: List[TypeDecl],
choices: Set[ChoiceDecl],
choices: List[ChoiceDecl],
topAttrs: Map[String, AttributeDecl],
attrList: List[AttributeDecl],
topGroups: Map[String, GroupDecl],
Expand Down Expand Up @@ -240,7 +248,7 @@ object SchemaDecl {
config.elemList.toList,
immutable.ListMap.empty[String, TypeDecl] ++ config.topTypes,
config.typeList.toList,
config.choices,
config.choices.toList,
immutable.ListMap.empty[String, AttributeDecl] ++ config.topAttrs,
config.attrList.toList,
immutable.ListMap.empty[String, GroupDecl] ++ config.topGroups,
Expand Down Expand Up @@ -559,7 +567,7 @@ case class SimpleTypeDecl(namespace: Option[String],

object SimpleTypeDecl {
def fromXML(node: scala.xml.Node, family: String, config: ParserConfig): SimpleTypeDecl =
fromXML(node, "simpleType@" + family + ":" + scala.util.Random.nextInt, family, config)
fromXML(node, "simpleType@" + family + ":" + Incrementor.nextInt, family, config)

def fromXML(node: scala.xml.Node, name: String, family: String, config: ParserConfig): SimpleTypeDecl = {
var content: ContentTypeDecl = null
Expand Down Expand Up @@ -739,7 +747,7 @@ object CompositorDecl {
case class SequenceDecl(particles: List[Particle],
minOccurs: Int,
maxOccurs: Int,
rand: Double = math.random) extends CompositorDecl with HasParticle
uniqueId: Int = Incrementor.nextInt) extends CompositorDecl with HasParticle

object SequenceDecl {
def fromXML(node: scala.xml.Node, config: ParserConfig) = {
Expand All @@ -752,7 +760,7 @@ object SequenceDecl {
case class ChoiceDecl(particles: List[Particle],
minOccurs: Int,
maxOccurs: Int,
rand: Double = math.random) extends CompositorDecl with HasParticle
uniqueId: Int = Incrementor.nextInt) extends CompositorDecl with HasParticle

object ChoiceDecl {
def fromXML(node: scala.xml.Node, config: ParserConfig) = {
Expand All @@ -767,7 +775,7 @@ object ChoiceDecl {
case class AllDecl(particles: List[Particle],
minOccurs: Int,
maxOccurs: Int,
rand: Double = math.random) extends CompositorDecl with HasParticle
uniqueId: Int = Incrementor.nextInt) extends CompositorDecl with HasParticle

object AllDecl {
def fromXML(node: scala.xml.Node, config: ParserConfig) = {
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/scalaxb/compiler/xsd/GenSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ object {name} {{
}

def buildOptions(decl: ComplexTypeDecl): List[String] = {
val set = mutable.Set.empty[String]
val set = mutable.ListBuffer.empty[String]
def addIfMatch(typeSymbol: XsTypeSymbol, choice: ChoiceDecl) = {
typeSymbol match {
case symbol: ReferenceTypeSymbol =>
Expand All @@ -659,7 +659,7 @@ object {name} {{
case _ => // do nothing
}

set.toList
set.toList.distinct
}

// reverse lookup all choices that contains that.
Expand Down

0 comments on commit 7f5472a

Please sign in to comment.