mbeckerle commented on code in PR #1366:
URL: https://github.com/apache/daffodil/pull/1366#discussion_r1833028861
##########
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:
There are lists of all schema components elsewhere. You do not need to do
your own recursive traversal to obtain them.
SchemaSet.allSchemaComponents is a Seq[SchemaComponent]
--
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]