stevedlawrence commented on a change in pull request #326: Daffodil 2280
cleanup - removes backpointers and factory patterns no longer needed
URL: https://github.com/apache/incubator-daffodil/pull/326#discussion_r393673919
##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dsom/Term.scala
##########
@@ -566,50 +481,44 @@ trait Term
}
}
}
+
/**
- * Returns a tuple, where the first item in the tuple is the list of sibling
- * terms that could appear before this. The second item in the tuple is a
- * One(enclosingParent) if all prior siblings are optional or this element
has no prior siblings
+ * Returns a list of sibling terms that could appear before this.
+ *
+ * Uses only lexically enclosing group/groupDef
+ *
+ * Nil if enclosed by a choice or this is root.
*/
- lazy val potentialPriorTerms: (Seq[Term], Option[Term]) =
LV('potentialPriorTerms) {
- val et = enclosingTerm
- val (potentialPrior, optEnclosingParent) = et match {
- case None => (Seq(), None)
- case Some(eb: ElementBase) => (Seq(), Some(eb))
- case Some(ch: ChoiceTermBase) => (Seq(), Some(ch))
- case Some(sq: SequenceTermBase) if !sq.isOrdered => {
- (sq.groupMembers, Some(sq))
- }
- case Some(sq: SequenceTermBase) if sq.isOrdered => {
- val previousTerms = sq.groupMembers.takeWhile { _ != this }
- if (previousTerms.isEmpty) {
- // first child of seq, the seq is the only previous term
- (Seq(), Some(sq))
- } else {
- val firstNonOptional = previousTerms.reverse.find {
- _ match {
- case eb: ElementBase if !eb.isRequiredStreamingUnparserEvent ||
!eb.isRepresented => false
- case _ => true
+ lazy val potentialPriorTerms: Seq[Term] = LV('potentialPriorTerms) {
+ potentialPriorTermsDef
+ }.value
+
+ private def potentialPriorTermsDef = {
+ optLexicalParent.toSeq.flatMap { lp =>
+ lp match {
+ case sq: SequenceTermBase if !sq.isOrdered =>
+ sq.groupMembers.filter { _.isRepresented }
+ case sq: SequenceDefMixin => {
+ // ??? Didin' check for ordered/unordered here.
Review comment:
I don't undertand this comment. This is the ordered sequence case, right?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services