mbeckerle commented on code in PR #1366:
URL: https://github.com/apache/daffodil/pull/1366#discussion_r1871904466


##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaSet.scala:
##########
@@ -540,8 +540,51 @@ final class SchemaSet private (
     .flatMap(_.defineVariables)
     .union(predefinedVars)
 
+  // propagated to referenced element propCache
+  private lazy val propagateReferenceeAndTypeUsedProperties = {
+    root.allComponents.collect {
+      case ref: AbstractElementRef =>
+        val referent = ref.optReferredToComponent.get
+        ref.propCache.foreach(kv =>
+          // if the referent or its simpleType carries the property then add it
+          if (
+            referent.formatAnnotation.justThisOneProperties.contains(kv._1)
+            || referent.optSimpleType.exists {
+              case std: SimpleTypeDefBase =>
+                std.formatAnnotation.justThisOneProperties.contains(kv._1)
+              case _ => false
+            }
+          ) {
+            // only add the used properties that the referent carries, not any 
local properties that aren't shared
+            referent.propCache.put(kv._1, kv._2)
+          }
+        )
+      case ele: ElementDeclMixin =>
+        val ost = ele.optSimpleType
+        if (ost.isDefined && ost.get.isInstanceOf[SimpleTypeDefBase]) {
+          val std = ost.get.asInstanceOf[SimpleTypeDefBase]
+          if (std.propCache.nonEmpty) {
+            // if it has used properties transfer it to the element that's 
using it
+            // we don't need the check for what is carries since all 
properties on the type are shared
+            // by the element using it
+            std.propCache.foreach(kv => ele.propCache.put(kv._1, kv._2))
+          }
+          // copy the used properties from the element to the type
+          ele.propCache.foreach(kv =>
+            if (std.formatAnnotation.justThisOneProperties.contains(kv._1)) {
+              // only add the used properties that the simple type carries, 
not any local element properties that aren't shared
+              std.propCache.put(kv._1, kv._2)
+            }
+          )
+        }
+      case _ => // do nothing
+    }
+  }
+
   private lazy val checkUnusedProperties = LV('hasUnusedProperties) {

Review Comment:
   This part:
   
   > Note that the lazy val name is 'checkUnusedProperties' but the LV symbol 
is 'hasUnusedProperties'. They should match.
   
   is not yet done. 
   



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to