olabusayoT commented on code in PR #1366:
URL: https://github.com/apache/daffodil/pull/1366#discussion_r1833038908
##########
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:
So I actually looked into that, but becauseit is a Seq[SchemaComponent], and
not an AnnotatedSchemaComponent, it doesn't know what checkUsedProperties is.
Attempts to move checkUsedProperties to SchemaComponent instead resulted in
issues since things like formatAnnotations that we use to grab the properties
only exist in AnnotatedSchemaComponent.
--
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]