You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sh...@apache.org on 2022/11/21 13:16:30 UTC

[daffodil] branch main updated: Remove leftover deprecated variables and methods.

This is an automated email from the ASF dual-hosted git repository.

shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git


The following commit(s) were added to refs/heads/main by this push:
     new c1ec8706e Remove leftover deprecated variables and methods.
c1ec8706e is described below

commit c1ec8706ee76415b7ae492d0542b775fcc0eab49
Author: Shane Dell <sh...@gmail.com>
AuthorDate: Fri Nov 18 13:19:30 2022 -0500

    Remove leftover deprecated variables and methods.
    
    - daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala: Remove deprecated variable compilerExternalVarSettings and method withExternalDFDLVariablesImpl. Update some var's to val's
    - daffodil-core/src/main/scala/org/apache/daffodil/dsom/SchemaSet.scala: Remove deprecated variable compilerExternalVarSettings.
    - daffodil-core/src/main/scala/org/apache/daffodil/runtime1/SchemaSetRuntime1Mixin.scala: Remove ExternalVariablesLoader and references to compilerExternalVarSettings.
    - daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/processor/TDMLDFDLProcessor.scala: Remove deprecated method withExternalDFDLVariables.
    - daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/DaffodilTDMLDFDLProcessor.scala: Remove deprecated method withExternalDFDLVariables.
    - daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/Runtime2TDMLDFDLProcessor.scala: Remove deprecated method withExternalDFDLVariables.
    
    [DAFFODIL-2743](https://issues.apache.org/jira/projects/DAFFODIL/issues/DAFFODIL-2743?filter=allissues)
---
 .../org/apache/daffodil/compiler/Compiler.scala    | 59 +++++-----------------
 .../scala/org/apache/daffodil/dsom/SchemaSet.scala | 15 ++----
 .../daffodil/runtime1/SchemaSetRuntime1Mixin.scala | 19 +------
 .../tdml/processor/TDMLDFDLProcessor.scala         |  2 -
 .../tdml/processor/DaffodilTDMLDFDLProcessor.scala |  3 --
 .../tdml/processor/Runtime2TDMLDFDLProcessor.scala |  3 --
 6 files changed, 17 insertions(+), 84 deletions(-)

diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala b/daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala
index 08647c776..1d71e580d 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala
@@ -26,7 +26,6 @@ import java.nio.channels.Channels
 import java.util.zip.GZIPInputStream
 import java.util.zip.ZipException
 
-import scala.collection.immutable.Queue
 import scala.collection.mutable.ArrayBuffer
 import scala.util.Try
 import scala.xml.Node
@@ -63,17 +62,7 @@ object ForUnparser extends ParserOrUnparser
 object BothParserAndUnparser extends ParserOrUnparser
 
 final class ProcessorFactory private(
-  private var optRootSpec: Option[RootSpec],
-  /*
-   * compilerExternalVarSettings supports the deprecated API
-   * where external variable settings can be supplied to the compiler
-   * instance.
-   *
-   * The non-deprecated API is to deal with external variable settings
-   * on the data processor instance. This is passed here so that
-   * the PF can propagate it to the DP.
-   */
-  var compilerExternalVarSettings: Queue[Binding],
+  private val optRootSpec: Option[RootSpec],
   schemaSource: DaffodilSchemaSource,
   val validateDFDLSchemas: Boolean,
   checkAllTopLevel: Boolean,
@@ -83,24 +72,21 @@ final class ProcessorFactory private(
 
   def this(optRootName: Option[String],
     optRootNamespace: Option[String],
-    compilerExternalVarSettings: Queue[Binding],
     schemaSource: DaffodilSchemaSource,
     validateDFDLSchemas: Boolean,
     checkAllTopLevel: Boolean,
     tunables: DaffodilTunables) =
     this(
       RootSpec.makeRootSpec(optRootName, optRootNamespace), // compute root-spec object
-      compilerExternalVarSettings, schemaSource, validateDFDLSchemas, checkAllTopLevel, tunables, None)
+      schemaSource, validateDFDLSchemas, checkAllTopLevel, tunables, None)
 
   private def copy(
-    optRootSpec: Option[RootSpec] = optRootSpec,
-    compilerExternalVarSettings: Queue[Binding] = compilerExternalVarSettings): ProcessorFactory =
-    new ProcessorFactory(optRootSpec, compilerExternalVarSettings, schemaSource, validateDFDLSchemas, checkAllTopLevel, tunables, Some(sset))
+    optRootSpec: Option[RootSpec] = optRootSpec): ProcessorFactory =
+      new ProcessorFactory(optRootSpec, schemaSource, validateDFDLSchemas, checkAllTopLevel, tunables, Some(sset))
 
   lazy val sset: SchemaSet =
     optSchemaSet.getOrElse(
-      SchemaSet(optRootSpec, schemaSource, validateDFDLSchemas, checkAllTopLevel, tunables,
-        compilerExternalVarSettings))
+      SchemaSet(optRootSpec, schemaSource, validateDFDLSchemas, checkAllTopLevel, tunables))
 
   lazy val rootView: RootView = sset.root
 
@@ -142,16 +128,8 @@ final class ProcessorFactory private(
 
 class InvalidParserException(msg: String, cause: Throwable = null) extends Exception(msg, cause)
 
-class Compiler private (var validateDFDLSchemas: Boolean,
-  var tunables : DaffodilTunables,
-  /*
-   * Supports deprecated feature of establishing external vars on the compiler object.
-   * These are just saved and passed to the processor factory which incorporates them into
-   * the variable map of the data processor.
-   *
-   * This argument can be removed once this deprecated feature is removed.
-   */
-  private var externalDFDLVariables: Queue[Binding],
+class Compiler private (val validateDFDLSchemas: Boolean,
+  val tunables : DaffodilTunables,
 
   /**
    * checkAllTopLevel should normally be true. There are some schemas where
@@ -165,26 +143,24 @@ class Compiler private (var validateDFDLSchemas: Boolean,
    * Compiling a schema with that sort of element in it and compileAllTopLevel true
    * causes an SDE about "relative path past root".
    */
-  private var checkAllTopLevel : Boolean,
-  private var optRootName: Option[String],
-  private var optRootNamespace: Option[String])
+  private val checkAllTopLevel : Boolean,
+  private val optRootName: Option[String],
+  private val optRootNamespace: Option[String])
   extends DFDL.Compiler {
 
   private def this(validateDFDLSchemas: Boolean = true) =
     this(validateDFDLSchemas,
       tunables = DaffodilTunables(),
-      externalDFDLVariables = Queue.empty,
       checkAllTopLevel = true,
       optRootName = None,
       optRootNamespace = None)
 
   private def copy(validateDFDLSchemas: Boolean = validateDFDLSchemas,
     tunables : DaffodilTunables = tunables,
-    externalDFDLVariables: Queue[Binding] = externalDFDLVariables,
     checkAllTopLevel : Boolean = checkAllTopLevel,
     optRootName: Option[String] = optRootName,
     optRootNamespace: Option[String] = optRootNamespace) =
-    new Compiler(validateDFDLSchemas, tunables, externalDFDLVariables, checkAllTopLevel, optRootName, optRootNamespace)
+    new Compiler(validateDFDLSchemas, tunables, checkAllTopLevel, optRootName, optRootNamespace)
 
   def withDistinguishedRootNode(name: String, namespace: String) : Compiler = {
     Assert.usage(name ne null)
@@ -206,17 +182,6 @@ class Compiler private (var validateDFDLSchemas: Boolean,
     b
   }
 
-  //
-  // Not deprecated so that we can implement the deprecated things
-  // and reuse code.
-  // When the deprecated methods go away, so should this.
-  //
-  def withExternalDFDLVariablesImpl(variables: Seq[Binding]): Compiler = {
-    var extVars = externalDFDLVariables
-    variables.foreach(b => extVars = extVars.enqueue(b))
-    copy(externalDFDLVariables = extVars)
-  }
-
   def withTunable(tunable: String, value: String): Compiler =
     copy(tunables = tunables.withTunable(tunable, value))
 
@@ -365,7 +330,7 @@ class Compiler private (var validateDFDLSchemas: Boolean,
       val rootName = optRootNameArg.orElse(optRootName) // arguments override things set with setters
       val rootNamespace = optRootNamespaceArg.orElse(optRootNamespace)
       new ProcessorFactory(
-        rootName, rootNamespace, externalDFDLVariables, schemaSource, validateDFDLSchemas, checkAllTopLevel, tunables)
+        rootName, rootNamespace, schemaSource, validateDFDLSchemas, checkAllTopLevel, tunables)
     }
 
     val err = pf.isError
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/SchemaSet.scala b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/SchemaSet.scala
index f3861e238..c6a9d4853 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/SchemaSet.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/SchemaSet.scala
@@ -34,28 +34,23 @@ import org.apache.daffodil.api.DaffodilSchemaSource
 import org.apache.daffodil.api.UnitTestSchemaSource
 import org.apache.daffodil.schema.annotation.props.LookupLocation
 import org.apache.daffodil.api.DaffodilTunables
-import org.apache.daffodil.externalvars.Binding
 import org.apache.daffodil.processors.TypeCalculatorCompiler.TypeCalcMap
 import org.apache.daffodil.grammar.Gram
 import org.apache.daffodil.grammar.SchemaSetGrammarMixin
 import org.apache.daffodil.util.TransitiveClosure
 
-import scala.collection.immutable.Queue
-
 object SchemaSet {
   def apply(
     optPFRootSpec: Option[RootSpec],
   schemaSource: DaffodilSchemaSource,
   shouldValidateDFDLSchemas: Boolean,
   checkAllTopLevel: Boolean,
-  tunables: DaffodilTunables,
-  compilerExternalVarSettings: Queue[Binding]) = {
+  tunables: DaffodilTunables) = {
     val ss = new SchemaSet(optPFRootSpec,
       schemaSource,
       shouldValidateDFDLSchemas,
       checkAllTopLevel,
-      tunables,
-      compilerExternalVarSettings)
+      tunables)
     ss.initialize()
     ss
   }
@@ -96,8 +91,7 @@ final class SchemaSet private (
   val schemaSource: DaffodilSchemaSource,
   val shouldValidateDFDLSchemas: Boolean,
   val checkAllTopLevel: Boolean,
-  val tunables: DaffodilTunables,
-  protected val compilerExternalVarSettings: Queue[Binding])
+  val tunables: DaffodilTunables)
   extends SchemaComponentImpl(<schemaSet/>, None)
   with SchemaSetIncludesAndImportsMixin
   with SchemaSetGrammarMixin {
@@ -159,8 +153,7 @@ final class SchemaSet private (
       UnitTestSchemaSource(sch, Option(root).getOrElse("anon"), optTmpDir),
       false,
       false,
-      tunableOpt.getOrElse(DaffodilTunables()),
-      Queue.empty)
+      tunableOpt.getOrElse(DaffodilTunables()))
 
   lazy val schemaFileList = schemas.map(s => s.uriString)
 
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/SchemaSetRuntime1Mixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/SchemaSetRuntime1Mixin.scala
index 85a9f9bfd..8fe83cf32 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/SchemaSetRuntime1Mixin.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/SchemaSetRuntime1Mixin.scala
@@ -21,7 +21,6 @@ import org.apache.daffodil.api.DFDL
 import org.apache.daffodil.api.ValidationMode
 import org.apache.daffodil.dsom.SchemaSet
 import org.apache.daffodil.exceptions.Assert
-import org.apache.daffodil.externalvars.ExternalVariablesLoader
 import org.apache.daffodil.grammar.VariableMapFactory
 import org.apache.daffodil.processors.DataProcessor
 import org.apache.daffodil.processors.Processor
@@ -54,22 +53,6 @@ trait SchemaSetRuntime1Mixin {
     }
     val alldvs = dvs.union(predefinedVars)
     val vmap = VariableMapFactory.create(alldvs)
-    //
-    // Here we verify that any external variable bindings supplied at schema compilation time
-    // are properly structured - the variables they reference exist, are external, and the
-    // supplied value string is convertible into the declared variable's type.
-    //
-    // But... then we throw it away. We don't save the external variable bindings as
-    // part of the saved data structure representing the compiled schema.
-    // Because external variables really have to be bound at runtime, and the schema has
-    // to work with and without any such bindings.
-    //
-    // This same checking must be done at runtime, so we share that same code here at schema compile time.
-    // This is yet another example of where runtime1-specific code is being used in a general
-    // schema-compilation role. So even if building a runtime 2, you would still want to keep much of
-    // the runtime 1 code around.
-    //
-    ExternalVariablesLoader.loadVariables(compilerExternalVarSettings, this, vmap)
     vmap
   }.value
 
@@ -104,7 +87,7 @@ trait SchemaSetRuntime1Mixin {
       typeCalcMap)
     if (root.numComponents > root.numUniqueComponents)
       Logger.log.debug(s"Compiler: component counts: unique ${root.numUniqueComponents}, actual ${root.numComponents}.")
-    val dataProc = new DataProcessor(ssrd, tunable, self.compilerExternalVarSettings)
+    val dataProc = new DataProcessor(ssrd, tunable)
     if (dataProc.isError) {
     } else {
       Logger.log.debug(s"Parser = ${ssrd.parser.toString}.")
diff --git a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/processor/TDMLDFDLProcessor.scala b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/processor/TDMLDFDLProcessor.scala
index 6aa0a548b..6d5a7e418 100644
--- a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/processor/TDMLDFDLProcessor.scala
+++ b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/processor/TDMLDFDLProcessor.scala
@@ -55,8 +55,6 @@ trait AbstractTDMLDFDLProcessorFactory {
 
   def withTunables(tunables: Map[String, String]): R
 
-  def withExternalDFDLVariables(externalVarBindings: Seq[Binding]): R
-
   def getProcessor(schemaSource: DaffodilSchemaSource, useSerializedProcessor: Boolean,
     optRootName: Option[String] = None, optRootNamespace: Option[String] = None,
     tunables: Map[String, String]): TDML.CompileResult
diff --git a/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/DaffodilTDMLDFDLProcessor.scala b/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/DaffodilTDMLDFDLProcessor.scala
index 231edb617..2425db61d 100644
--- a/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/DaffodilTDMLDFDLProcessor.scala
+++ b/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/DaffodilTDMLDFDLProcessor.scala
@@ -88,9 +88,6 @@ final class TDMLDFDLProcessorFactory private (
   override def withTunables(tunables: Map[String, String]): TDMLDFDLProcessorFactory =
     copy(compiler = compiler.withTunables(tunables))
 
-  override def withExternalDFDLVariables(externalVarBindings: Seq[Binding]): TDMLDFDLProcessorFactory =
-    copy(compiler = compiler.withExternalDFDLVariablesImpl(externalVarBindings))
-
   /**
    * This doesn't fetch a serialized processor, it runs whatever the processor is
    * through a serialize then unserialize path to get a processor as if
diff --git a/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/Runtime2TDMLDFDLProcessor.scala b/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/Runtime2TDMLDFDLProcessor.scala
index c7f9c4fa3..f51649642 100644
--- a/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/Runtime2TDMLDFDLProcessor.scala
+++ b/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/Runtime2TDMLDFDLProcessor.scala
@@ -61,9 +61,6 @@ final class Runtime2TDMLDFDLProcessorFactory private(
   override def withTunables(tunables: Map[String, String]): Runtime2TDMLDFDLProcessorFactory =
     copy(compiler = compiler.withTunables(tunables))
 
-  override def withExternalDFDLVariables(externalVarBindings: Seq[Binding]): Runtime2TDMLDFDLProcessorFactory =
-    copy(compiler = compiler.withExternalDFDLVariablesImpl(externalVarBindings))
-
   // Return result is a TDML.CompileResult - so it's the result
   // of compiling the schema for the test.
   override def getProcessor(