mbeckerle commented on a change in pull request #226: Sick of NPE.
lexicalParent is now optLexicalParent and is Option type
URL: https://github.com/apache/incubator-daffodil/pull/226#discussion_r291167815
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/dsom/SchemaComponentFactory.scala
##########
@@ -79,14 +81,14 @@ trait SchemaFileLocatableImpl
trait CommonContextMixin
extends NestingMixin { self: OOLAGHost with ThrowsSDE =>
- def lexicalParent: SchemaComponent
+ def optLexicalParent: Option[SchemaComponent]
- lazy val schemaFile: Option[DFDLSchemaFile] = lexicalParent.schemaFile
- lazy val schemaSet: SchemaSet = lexicalParent.schemaSet
- def schemaDocument: SchemaDocument = lexicalParent.schemaDocument
- lazy val xmlSchemaDocument: XMLSchemaDocument =
lexicalParent.xmlSchemaDocument
- lazy val schema: Schema = lexicalParent.schema
- def uriString: String = lexicalParent.uriString
+ lazy val schemaFile: Option[DFDLSchemaFile] = optLexicalParent.flatMap {
_.schemaFile }
Review comment:
Well this one really should be named optSchemaFile. The code is not very
consistent about this naming convention though.
It uses flatMap because it wants an option type back. The ones below are
non-option, so they fault if used on an object without lexical parent (which is
only the root).
----------------------------------------------------------------
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