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

 ##########
 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:
   I will incorporate this idea. I introduced HasFactory pretty late in this, 
but looking back at it, really there should be a harder separation between 
regular schema components and factory schema components. I'm disinclined to 
work too hard separating them though, since the whole objective is to eliminate 
the context pointers that force us to distinguish, entirely, thereby 
recombining the factory and instance. What really is happening is that the DSOM 
objects become pure factory, and the Grammar objects beccome the "instance" 
objects. 

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

Reply via email to