mbeckerle commented on a change in pull request #223: Daffodil 1444 schema comp
simple types
URL: https://github.com/apache/incubator-daffodil/pull/223#discussion_r289568662
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/dsom/SimpleTypes.scala
##########
@@ -296,62 +286,40 @@ abstract class SimpleTypeDefBase(xml: Node, parent:
SchemaComponent, val factory
}
final class LocalSimpleTypeDef(
- xmlArg: Node, elementArg: ElementDeclMixin, factory: SimpleTypeDefFactory)
- extends SimpleTypeDefBase(xmlArg, elementArg, factory)
+ xmlArg: Node, lexicalParent: SchemaComponent)
+ extends SimpleTypeDefBase(xmlArg, lexicalParent)
with LocalNonElementComponentMixin
with NestingLexicalMixin {
- override lazy val elementDecl = elementArg
-
- /**
- * For anonymous simple type def, uses the base name, or primitive type name
- */
- override lazy val diagnosticDebugName: String = {
- //
- // TODO: implement a daf:name property to give an alternate name. If
present, use that.
- //
- val baseName = optRestriction.flatMap { r =>
- r.optBaseDef.map { _.namedQName }.orElse(Some(r.primType.globalQName))
- }.getOrElse(this.optUnion.map { u => u.primType.globalQName }.getOrElse(
- //Note that this.toString=diagnosticDebugName, so cannot be used here
- Assert.invariantFailed("Anonymous Simple type is neither a union nor a
restriction. Enclosing element is " + this.parent)))
- val repName = optRepTypeFactory.map(_.name)
- repName match {
- case None => baseName.diagnosticDebugName
- case Some(n) => s"${n} -> ${baseName.diagnosticDebugName}"
- }
- }
-
-}
-
-/**
- * The factory is sharable even though the objects it creates cannot
- * be shared.
- *
- * This allows us to compute common properties of GlobalSimpleTypes exactly
once
- * (and makes those properties available in the absence of an instantiating
element)
- *
- * In theory this is not useful in the case of LocalSimpleTypes, as they will
only ever be instantiated once,
- * but we do need LocalSimpleTypes to go through a factory so they have access
to the features implemented in the factory
- */
-
-trait SimpleTypeFactory {
- def forElement(elementDecl: ElementDeclMixin): SimpleTypeBase
- def forDerivedType(derivedType: SimpleTypeDefBase): SimpleTypeBase
-
- def primType: PrimType
+ // /**
+ // * For anonymous simple type def, uses the base name, or primitive type
name
+ // */
+ //
+ // Don't do this. diagnosticDebugName can't call ANYTHING that can SDE,
because it is
+ // used by the SDE system to identify the schema component.
+ //
+ // override lazy val diagnosticDebugName: String = {
+ // //
+ // // TODO: implement a daf:name property to give an alternate name. If
present, use that.
+ // //
+ // val baseName = optRestriction.flatMap { r =>
+ // r.optBaseDef.map { _.namedQName
}.orElse(Some(r.primType.globalQName))
+ // }.getOrElse(this.optUnion.map { u => u.primType.globalQName
}.getOrElse(
+ // //Note that this.toString=diagnosticDebugName, so SDE cannot be used
here
+ // Assert.invariantFailed("Anonymous Simple type is neither a union nor
a restriction. Enclosing element is " + this.lexicalParent)))
+ // // furthermore, we can't call things that throw SDEs either.
+ // val repName = optRepTypeDef.map(_.name)
+ // repName match {
+ // case None => baseName.diagnosticDebugName
+ // case Some(n) => s"${n} -> ${baseName.diagnosticDebugName}"
+ // }
+ // }
- def name: String
}
-abstract class SimpleTypeDefFactory(xmlArg: Node, schemaDocumentArg:
SchemaDocument)
- extends SchemaComponentFactory(xmlArg, schemaDocumentArg)
- with HasRepValueAttributes
- with SimpleTypeFactory
- with HasOptRepTypeMixinImpl
- with ProvidesDFDLStatementMixin {
+trait SimpleTypeDefMixin extends TypeBase { self: SimpleTypeDefBase =>
Review comment:
This mixin is used exactly one place, so probably should just be added to
SimpleTypeDefBase and get rid of the trait. I left it this way because it moved
fewer lines of code around, allowing the diff to be more of a diff, and less of
a wholesale green lines for things that haven't changed.
I will integrate this into the class that uses it post review.
----------------------------------------------------------------
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