stevedlawrence commented on a change in pull request #228: Incremental progress
on Daffodil 1444 schema compiler space/speed issue.
URL: https://github.com/apache/incubator-daffodil/pull/228#discussion_r292032247
##########
File path: daffodil-core/src/main/scala/org/apache/daffodil/dsom/Nesting.scala
##########
@@ -54,24 +61,61 @@ trait NestingMixin {
* schema components.
*/
trait NestingLexicalMixin
- extends NestingMixin {
+ extends NestingMixin { self: SchemaComponent =>
+ @deprecated("2019-06-03", "Use enclosingComponentDefs method, and deal with
sharing.")
override protected def enclosingComponentDef = optLexicalParent
+ final override protected lazy val enclosingComponentDefs:
Seq[(SchemaComponent, Int)] =
+ optLexicalParent.map {
+ lp =>
+ val pos = self match {
+ case t: Term => t.position
+ case _ => 1
+ }
+ (lp, pos)
+ }.toSeq
}
/**
* Mixin for all global schema components
*/
trait NestingTraversesToReferenceMixin
- extends NestingMixin {
+ extends NestingMixin
+ with HasFactory { self: SchemaComponent =>
+
+ def factory: SchemaComponentFactory
+ @deprecated("2019-06-03", "Use referringComponents method, and deal with
sharing.")
def referringComponent: Option[SchemaComponent]
+ @deprecated("2019-06-03", "Use enclosingComponentDefs method, and deal with
sharing.")
final override protected def enclosingComponentDef: Option[SchemaComponent]
= {
Assert.invariant(optLexicalParent.isDefined &&
optLexicalParent.get.isInstanceOf[SchemaDocument]) // global things have
schema documents as their parents.
referringComponent
}
+ /**
+ * Enables compilation to know all the points of use of a global
+ * component.
+ */
+ def referringComponents: Seq[(String, Seq[RefSpec])] = {
+ this match {
+ case hf: HasFactory => {
+ schemaSet.root.refMap.get(hf.factory) match {
+ case None => Assert.invariantFailed("There are no references to this
component: " + this)
+ case Some(seq) => seq
+ }
+ }
+ case _ => Assert.invariantFailed("Should only be part of Global objects
with factories.")
+ }
+ }
Review comment:
Does it make sense/is it possible for this function live on HasFactory if
it's an invariantFailed if it's called on anything else?
----------------------------------------------------------------
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