Skip to content
Permalink
Browse files
Removes comment out code
-- also does some reindenting if necessary

DAFFODIL-2275
  • Loading branch information
olabusayoT committed Apr 24, 2020
1 parent 075ed01 commit 5e63af1f5e0cd268b84e9de9735baac19310aeff
Showing 54 changed files with 183 additions and 551 deletions.
@@ -690,7 +690,6 @@ object Main extends Logging {
}
}
val id = new InteractiveDebugger(runner, ExpressionCompilers)
// runner.init(id)
proc.setDebugging(true)
proc.setDebugger(id)
}
@@ -880,16 +880,10 @@ sealed abstract class StepExpression(val step: String, val pred: Option[Predicat
ci.noMatchError(stepQName)
}
}

// override def toString = text

// Combination of lazy val and a protected def is an idiom
// that enables a lazy calculation to call super.
//
final lazy val stepElements = {
val res = stepElementDefs
// log(LogLevel.Info, "DPath Compiler: path step elements for %s are %s.",
// step, res.map { _.sscd }.mkString(", "))
res
}

@@ -993,7 +987,7 @@ sealed abstract class DownStepExpression(s: String, predArg: Option[PredicateExp
extends StepExpression(s, predArg) {

/**
* Since an expresion can be in a reused group, type, or element, the downward path
* Since an expression can be in a reused group, type, or element, the downward path
* step may actually represent a step downward to distinct elements that happen to
* just have the same name/namespace, but they could be different types.
*
@@ -1008,10 +1002,6 @@ sealed abstract class DownStepExpression(s: String, predArg: Option[PredicateExp
* For now, we just insist all the types are equal, and issue a SDE if they are not.
*/
override lazy val inherentType: NodeInfo.Kind = {
// stepElements.map { _.typeNode }.reduce {
// (left, right) =>
// NodeInfoUtils.typeLeastUpperBound(left, right)
// }
val allTypes = stepElements.map { _.typeNode }.distinct
Assert.invariant(allTypes.length > 0)
if (allTypes.length > 1) {
@@ -2035,7 +2025,6 @@ case class FNExactlyOneExpr(nameAsParsed: String, fnQName: RefQName, args: List[
override lazy val compiledDPath = {
checkArgCount(1)
subsetError("fn:exactly-one is not supported.")
//new CompiledDPath((arrPath.compiledDPath.ops.toList :+ FNExactlyOne) ++ conversions)
}
}

@@ -66,9 +66,7 @@ abstract class DFDLAssertionBase(node: Node, decl: AnnotatedSchemaComponent)
val optPattern = getAttributeOption("testPattern")
optPattern.foreach { thePattern =>
try {
// val icu =
UnicodeRegex.compile(thePattern) // Check against ICU
// val java =
Pattern.compile(thePattern) // Check against Java
} catch { case e: PatternSyntaxException => SDE("The pattern contained invalid syntax: %s", e.getMessage()) }
}
@@ -289,7 +289,6 @@ abstract class DFDLFormatAnnotation(nodeArg: Node, annotatedSCArg: AnnotatedSche
"Short, long, and element form properties overlap: %s at %s",
locallyConflictingProperties.mkString(", "),
this.locationDescription)
// jto = "just this one"
val jtoSet = shortFormProperties.union(longFormProperties).union(elementFormProperties)
val jto = jtoSet.toMap
jto
@@ -99,7 +99,6 @@ final class DFDLSchemaFile(
}

def error(exception: SAXParseException) = {
// val ex = exception
val sde = new SchemaDefinitionError(this.schemaFileLocation, "Error loading schema due to %s", exception)
error(sde)
validationDiagnostics_ :+= sde
@@ -353,8 +353,6 @@ trait ElementBase

lazy val unparserInfosetElementDefaultingBehavior: UnparserInfo.InfosetEventBehavior = {
import UnparserInfo._
//if (isScalar && isDefaultable) ScalarDefaultable
//else if (isArray && isDefaultable) ArrayDefaultable
if (!isRepresented) MustExist
else if (isOutputValueCalc) Computed
else if (isOptional) Optional
@@ -816,9 +814,6 @@ trait ElementBase
private lazy val enumerationValues: Option[String] = {
Assert.invariant(hasEnumeration)
typeDef.optRestriction.flatMap { _.enumerationValues }
// .getOrElse {
// Assert.invariantFailed("must have an enumeration value")
// }
}

/**
@@ -139,7 +139,7 @@ trait Facets { self: Restriction =>
if (values.size > 0) {
val (_, value) = values(0)
Some(value)
} else None // SDE("Enumeration was not found in this context.")
} else None
}
// TODO: Tidy up. Can likely replace getFacetValue with a similar call to combinedBaseFacets
// as combinedBaseFacets should contain the 'narrowed' values.
@@ -309,7 +309,6 @@ trait Facets { self: Restriction =>
// Necessary for min/max Inclusive/Exclusive Facets

// Perform conversions once
//val theLocalFacet = new java.math.BigDecimal(localFacet)
val theLocalFacet = convertFacetToBigDecimal(localFacet)

facetType match {
@@ -432,7 +431,7 @@ trait Facets { self: Restriction =>
// been done in the base. --TRW

// Perform conversions once
val theRemoteFacet = checkValueSpaceFacetRange(remoteFacet, facetType) //new java.math.BigDecimal(remoteFacet)
val theRemoteFacet = checkValueSpaceFacetRange(remoteFacet, facetType)
val theLocalFacet = checkValueSpaceFacetRange(localFacet, facetType)

(theLocalFacet, theRemoteFacet)
@@ -103,7 +103,7 @@ final class Import(importNode: Node, xsd: XMLSchemaDocument, seenArg: IIMap)
}
}.value

private lazy val resolver = xsd.schemaSet.resolver // iiSchemaFileMaybe.map { _.resolver }
private lazy val resolver = xsd.schemaSet.resolver
private lazy val catFiles = resolver.catalogFiles.mkString(", ")

/**
@@ -119,9 +119,6 @@ final class Restriction(xmlArg: Node, val simpleTypeDef: SimpleTypeDefBase)
}

final lazy val combinedBaseFacets: Seq[FacetValue] = {
// val localF = localBaseFacets
// val remoteF = remoteBaseFacets

val combined: Queue[FacetValue] = Queue.empty

if (hasEnumeration) {
@@ -473,7 +470,6 @@ sealed trait TypeChecks { self: Restriction =>
protected def isInNegativeIntegerRange(value: JBigDecimal, context: ThrowsSDE): Boolean = {
// TODO: NegativeInteger not supported in DFDL v1.0
val min = new JBigDecimal(Int.MinValue.toString())
// val max = new JBigDecimal(Int.MaxValue.toString())
val isNegative = value.signum == -1
if (!isNegative) context.SDE("Expected a negative integer for this value.")
val checkMin = value.compareTo(min)
@@ -482,14 +478,12 @@ sealed trait TypeChecks { self: Restriction =>
}
protected def isInNonNegativeIntegerRange(value: JBigDecimal): Boolean = {
// Should be treated as unsigned Integer (unbounded)
// val min = JBigDecimal.ZERO
val isNegative = value.signum == -1
if (isNegative) return false
true
}
protected def isInUnsignedXXXRange(value: JBigDecimal, numBits: Int, typeName: String): Boolean = {
Assert.usage(numBits <= 64, "isInUnsignedXXXRange: numBits must be <= 64.")
// val min = JBigDecimal.ZERO
val max = new JBigDecimal(JBigInt.ONE.shiftLeft(numBits)).subtract(new JBigDecimal(1))
val isNegative = value.signum == -1
if (isNegative) return false
@@ -321,7 +321,6 @@ final class Schema(val namespace: NS, schemaDocs: Seq[SchemaDocument], schemaSet
* This just scans each schema document in the schema, checking each one.
*/
def getGlobalElementDecl(name: String) = {
// noneOrOne(schemaDocuments.flatMap { _.getGlobalElementDecl(name) }, name)
val sds = schemaDocuments
val res = sds.flatMap {
sd =>
@@ -284,7 +284,6 @@ final class SchemaSet(
* unambiguous, it is used as the root.
*/
private def findRootElement(name: String) = {
// log(Info("%s searching for root element with name %s", Misc.getNameFromClass(this), name))
val candidates = schemas.flatMap { _.getGlobalElementDecl(name) }
schemaDefinitionUnless(candidates.length != 0, "No root element found for %s in any available namespace", name)
schemaDefinitionUnless(candidates.length <= 1, "Root element %s is ambiguous. Candidates are %s.",
@@ -243,10 +243,6 @@ trait ElementBaseGrammarMixin
isSpecifiedLengthForUnparsing &&
couldBeVariableLengthInfoset &&
(lengthUnits ne LengthUnits.Characters))
// if (res)
// println("%s should add fill.".format(this.diagnosticDebugName))
// else
// println("%s NOT adding fill.".format(this.diagnosticDebugName))
res
}

@@ -416,10 +412,6 @@ trait ElementBaseGrammarMixin
couldBeVariableLengthInfoset &&
!isTruncatable &&
isSpecifiedLengthForUnparsing
// if (res)
// println("%s should check excess length.".format(this.diagnosticDebugName))
// else
// println("%s NOT checking excess length.".format(this.diagnosticDebugName))
res
}

@@ -993,7 +985,6 @@ trait ElementBaseGrammarMixin

nilKind match {
case NilKind.LiteralValue => {
// if (impliedRepresentation != Representation.Text) this.SDE("LiteralValue Nils require representation='text'.")
lengthKind match {
case LengthKind.Delimited => LiteralNilDelimitedEndOfData(this)
case LengthKind.Pattern => LiteralValueNilOfSpecifiedLength(this)
@@ -278,60 +278,6 @@ case class TypeValueCalc(e: ElementBase)

}

//case class OutputValueCalcStaticLength(e: ElementBase,
// property: PropertyLookupResult,
// ovcRepUnparserGram: Gram,
// knownLengthInBits: Long)
// extends ValueCalcBase(e, property) {
//
// override def baseName = "outputValueCalc"
//
// override lazy val parser = Assert.usageError("Not to be called on OutputValueCalc class.")
//
// override lazy val unparser = {
// val ovcRepUnparser = ovcRepUnparserGram.unparser
// val unp = new ElementOutputValueCalcStaticLengthUnparser(e.elementRuntimeData, ovcRepUnparser, MaybeULong(knownLengthInBits))
// unp
// }
//}
//
//case class OutputValueCalcRuntimeLength(e: ElementBase,
// property: PropertyLookupResult,
// ovcRepUnparserGram: Gram,
// lengthEv: LengthEv,
// lengthUnits: LengthUnits)
// extends ValueCalcBase(e, property) {
//
// override def baseName = "outputValueCalc"
//
// override lazy val parser = Assert.usageError("Not to be called on OutputValueCalc class.")
//
// override lazy val unparser = {
// val ovcRepUnparser = ovcRepUnparserGram.unparser
// val unp = new ElementOutputValueCalcRuntimeLengthUnparser(e.elementRuntimeData, ovcRepUnparser, lengthEv, lengthUnits)
// unp
// }
//}
//
//case class OutputValueCalcVariableLength(e: ElementBase,
// property: PropertyLookupResult,
// ovcRepUnparserGram: Gram)
// extends ValueCalcBase(e, property) {
//
// override def baseName = "outputValueCalc"
//
// override lazy val parser = Assert.usageError("Not to be called on OutputValueCalc class.")
//
// override lazy val unparser = {
// val ovcRepUnparser = ovcRepUnparserGram.unparser
// //
// // same "static length" unparser, but the length is optional, so in this case we don't provide it.
// //
// val unp = new ElementOutputValueCalcStaticLengthUnparser(e.elementRuntimeData, ovcRepUnparser, MaybeULong.Nope)
// unp
// }
//}

abstract class AssertPatternPrimBase(decl: Term, stmt: DFDLAssertionBase, discrim: Boolean)
extends ExpressionEvaluatorBase(decl) {

@@ -144,17 +144,6 @@ abstract class StringDelimited(e: ElementBase)
}
}

// /**
// * Called at compile time in static case, at runtime for dynamic case.
// */
// def errorIfDelimsHaveWSPStar(delims: List[String]): Unit = {
// if (delims.filter(x => x == "%WSP*;").length > 0) {
// // We cannot detect this error until expressions have been evaluated!
// log(LogLevel.Debug, "%s - Failed due to WSP* detected as a delimiter for lengthKind=delimited.", eName)
// context.schemaDefinitionError("WSP* cannot be used as a delimiter when lengthKind=delimited.")
// }
// }

override lazy val parser: DaffodilParser = new StringDelimitedParser(
e.elementRuntimeData,
justificationTrim,

0 comments on commit 5e63af1

Please sign in to comment.