stevedlawrence commented on a change in pull request #332: Refactor isHidden
URL: https://github.com/apache/incubator-daffodil/pull/332#discussion_r389894439
 
 

 ##########
 File path: 
daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ChoiceCombinator.scala
 ##########
 @@ -217,46 +217,49 @@ case class ChoiceCombinator(ch: ChoiceTermBase, 
alternatives: Seq[Gram])
   }
 
   override lazy val unparser: Unparser = {
-    if (!ch.isHidden) {
-      val eventRDMap = ch.choiceBranchMap
-      val eventUnparserMap = eventRDMap.flatMap {
-        case (cbe, rd) =>
-          // if we don't find a matching RD for a term that's probably
-          // because the term is an empty sequence or empty choice (which do 
happen
-          // and we even have tests for them). Since those can never be chosen 
by
-          // means of an element event, they don't appear in the map.
-          val altGram = alternatives.find { alt =>
-            val crd = alt.context.runtimeData
-            val found = crd =:= rd
-            found
-          }
-          altGram.map { ag => (cbe, ag.unparser) }
-      }
-      val mapValues = eventUnparserMap.map { case (k, v) => v 
}.toSeq.filterNot(_.isEmpty)
-      if (mapValues.isEmpty)
-        new NadaUnparser(null)
-      else {
-        new ChoiceCombinatorUnparser(ch.modelGroupRuntimeData, 
eventUnparserMap, choiceLengthInBits)
-      }
-    } else {
-      // Choices inside a hidden group ref are slightly different because we
-      // will never see events for any of the branches. Instead, we will just
-      // always pick the branch in which every thing is defaultble or OVC. It
-      // is a warning if more than one of those branches exist. It is an SDE if
-      // such a branch does not exist, which is detected elsewhere
-
+    val optDefaultableBranchUnparser = if (ch.isHidden) {
 
 Review comment:
   Does this logic need to be in the runtime unparsers? We can only know if a 
choice is hidden if it is directly referenced by a hidden group ref. But if a 
choice is a child of a hidden group ref then this can't know if it's hidden or 
not.
   
   Do we need to just always determine a defaultable branch and pass that into 
the choice combiantor, and then only use that if we determine we are hidden at 
runtime?

----------------------------------------------------------------
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

Reply via email to