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


##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/AnnotatedSchemaComponent.scala:
##########
@@ -377,6 +378,66 @@ trait AnnotatedSchemaComponent
     val res = schemaDocument.formatAnnotation.formatChain
     res
   }
+
+  /**
+   * Used to recursively go through Schema Components and look for DFDL 
properties that
+   * have not been accessed and record it as a warning. This function uses the
+   * property cache state to determine which properties have been access, so
+   * this function must only be called after all property accesses are complete
+   * (e.g. schema compilation has finished) to ensure there are no false
+   * positives.
+   */
+  final lazy val checkUnusedProperties: Unit = {
+    // Get the properties defined on this component and what it refers to
+    val localProps = formatAnnotation.justThisOneProperties
+    val refProps = optReferredToComponent
+      .map { _.formatAnnotation.justThisOneProperties }
+      .getOrElse(Map.empty)
+
+    val usedProperties = propCache
+
+    localProps.foreach { case (prop, (value, _)) =>
+      if (!usedProperties.contains(prop)) {
+        SDW(WarnID.IgnoreDFDLProperty, "DFDL property was ignored: %s=\"%s\"", 
prop, value)
+      }
+    }
+
+    refProps.foreach { case (prop, (value, _)) =>
+      if (!usedProperties.contains(prop)) {
+        optReferredToComponent.get.SDW(
+          WarnID.IgnoreDFDLProperty,
+          "DFDL property was ignored: %s=\"%s\"",
+          prop,
+          value
+        )
+      }
+    }
+
+    val descendantsForCheck = this match {

Review Comment:
   And from simple type to element (if it has any used properties) and from 
element to simple type (but only for the properties the simple type carries)



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