stevedlawrence commented on a change in pull request #332: Refactor isHidden
URL: https://github.com/apache/incubator-daffodil/pull/332#discussion_r392961023
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ChoiceCombinator.scala
##########
@@ -217,46 +217,58 @@ 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
+ /*
+ * Since it's impossible to know the hiddenness for terms at this level
(unless
+ * they're a hiddenGroupRef), we always attempt to find a defaultable
unparser.
+ * If we find one, and at runtime, we're in a hidden state, we can use
that. If we
+ * are not in a hidden state, it doesn't get used. If we don't find one,
and we encounter
+ * a hidden group ref here, we know we'll run into that issue at runtime,
so we SDE.
Review comment:
I think the last sentence of this comment isn't correct. Looks like the code
below is correct in that we can always determine staticaly if we are a hidden
group that doesn't contains a defaultable branch.
----------------------------------------------------------------
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