Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/5#discussion_r149841226
--- Diff:
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/dsom/ModelGroup.scala
---
@@ -115,118 +170,47 @@ abstract class ModelGroup(xmlArg: Node, parentArg:
SchemaComponent, position: In
def modelGroupRuntimeData: ModelGroupRuntimeData
- final lazy val gRefNonDefault: Option[ChainPropProvider] = groupRef.map
{ _.nonDefaultFormatChain }
- final lazy val gRefDefault: Option[ChainPropProvider] = groupRef.map {
_.defaultFormatChain }
-
- final def nonDefaultPropertySources = LV('nonDefaultPropertySources) {
- val seq = (gRefNonDefault.toSeq ++
Seq(this.nonDefaultFormatChain)).distinct
- checkNonOverlap(seq)
- seq
- }.value
-
- final def defaultPropertySources = LV('defaultPropertySources) {
- val seq = (gRefDefault.toSeq ++ Seq(this.defaultFormatChain)).distinct
- seq
- }.value
+ protected final lazy val prettyBaseName = xml.label
- protected final lazy val prettyBaseName = xmlArg.label
+ def xmlChildren: Seq[Node]
- protected def xmlChildren: Seq[Node]
-
- private def goodXmlChildren = LV('goodXMLChildren) { xmlChildren.flatMap
{ removeNonInteresting(_) } }.value
- private lazy val positions = List.range(1, goodXmlChildren.length + 1)
// range is exclusive on 2nd arg. So +1.
- private lazy val pairs = goodXmlChildren zip positions
-
- final lazy val sequenceChildren = groupMembers.collect { case s:
Sequence => s }
- final lazy val choiceChildren = groupMembers.collect { case s: Choice =>
s }
+ final lazy val sequenceChildren = groupMembers.collect { case s:
SequenceBase => s }
+ final lazy val choiceChildren = groupMembers.collect { case s:
ChoiceBase => s }
final lazy val groupRefChildren = groupMembers.collect { case s:
GroupRef => s }
- final def group = this
-
- final lazy val groupMembers = {
- pairs.flatMap {
- case (n, i) =>
- termFactory(n, this, i)
- }
- }
+ def group = this
final override lazy val termChildren = groupMembers
- final lazy val groupMembersNoRefs = groupMembers.map {
- case eRef: ElementRef => eRef.referencedElement
- case gb: GroupBase => gb.group
- case x => x
- }
-
- /**
- * Factory for Terms
- *
- * Because of the context where this is used, this returns a list. Nil
for non-terms, non-Nil for
- * an actual term. There should be only one non-Nil.
- *
- * This could be static code in an object. It doesn't reference any of
the state of the ModelGroup,
- * it's here so that type-specific overrides are possible in Sequence or
Choice
- */
- private def termFactory(child: Node, parent: ModelGroup, position: Int)
= {
- val childList: List[Term] = child match {
- case <element>{ _* }</element> => {
- val refProp = child.attribute("ref").map { _.text }
- // must get an unprefixed attribute name, i.e. ref='foo:bar', and
not
- // be tripped up by dfdl:ref="fmt:fooey" which is a format
reference.
- refProp match {
- case None => List(schemaSet.LocalElementDeclFactory(child,
schemaDocument).forModelGroup(parent, position))
- case Some(_) => List(new ElementRef(child, parent, position))
- }
- }
- case <annotation>{ _* }</annotation> => Nil
- case textNode: Text => Nil
- case _ => ModelGroupFactory(child, parent, position)
- }
- childList
- }
-
- /**
- * XML is full of uninteresting text nodes. We just want the element
children, not all children.
- */
- private def removeNonInteresting(child: Node) = {
- val childList: List[Node] = child match {
- case _: Text => Nil
- case _: Comment => Nil
- case <annotation>{ _* }</annotation> => Nil
- case _ => List(child)
- }
- childList
- }
-
/**
* Combine our statements with those of the group ref that is
referencing us (if there is one)
*/
- final lazy val statements: Seq[DFDLStatement] = localStatements ++
groupRef.map { _.statements }.getOrElse(Nil)
- final lazy val newVariableInstanceStatements:
Seq[DFDLNewVariableInstance] =
- localNewVariableInstanceStatements ++ groupRef.map {
_.newVariableInstanceStatements }.getOrElse(Nil)
- final lazy val (discriminatorStatements, assertStatements) =
checkDiscriminatorsAssertsDisjoint(combinedDiscrims, combinedAsserts)
- private lazy val combinedAsserts: Seq[DFDLAssert] =
localAssertStatements ++ groupRef.map { _.assertStatements }.getOrElse(Nil)
- private lazy val combinedDiscrims: Seq[DFDLDiscriminator] =
localDiscriminatorStatements ++ groupRef.map { _.discriminatorStatements
}.getOrElse(Nil)
-
- final lazy val setVariableStatements: Seq[DFDLSetVariable] = {
- val combinedSvs = localSetVariableStatements ++ groupRef.map {
_.setVariableStatements }.getOrElse(Nil)
- checkDistinctVariableNames(combinedSvs)
- }
-
- final lazy val groupRef = parent match {
- case ggd: GlobalGroupDef => Some(ggd.groupRef)
- case _ => None
- }
+ // final lazy val statements: Seq[DFDLStatement] = localStatements ++
groupRef.map { _.statements }.getOrElse(Nil)
--- End diff --
remove commented code.
---