def parseScope()

in debugger/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala [973:1049]


    def parseScope(
        ref: DAPodil.VariablesReference,
        event: Event.StartElement
    ): IO[DAPodil.Frame.Scope] =
      (variableRefs.next, variableRefs.next, variableRefs.next, variableRefs.next, variableRefs.next).mapN {
        (pouRef, delimiterStackRef, diagnosticsRef, diagnosticsValidationsRef, diagnosticsErrorsRef) =>
          val hidden = event.state.withinHiddenNest
          val childIndex = if (event.state.childPos != -1) Some(event.state.childPos) else None
          val groupIndex = if (event.state.groupPos != -1) Some(event.state.groupPos) else None
          val occursIndex = if (event.state.arrayIterationPos != -1) Some(event.state.arrayIterationPos) else None
          val foundDelimiter = for {
            dpr <- event.state.delimitedParseResult.toScalaOption
            dv <- dpr.matchedDelimiterValue.toScalaOption
          } yield Misc.remapStringToVisibleGlyphs(dv)
          val foundField = for {
            dpr <- event.state.delimitedParseResult.toScalaOption
            f <- dpr.field.toScalaOption
          } yield Misc.remapStringToVisibleGlyphs(f)

          val pouRootVariable =
            new Types.Variable("Points of uncertainty", "", null, pouRef.value, null)
          val pouVariables =
            event.pointsOfUncertainty.map(pou => new Types.Variable(s"${pou.name.value}", s"${pou.context}"))

          val delimiterStackRootVariable =
            new Types.Variable("Delimiters", "", null, delimiterStackRef.value, null)
          val delimiterStackVariables =
            event.delimiterStack.map(delimiter =>
              new Types.Variable(s"${delimiter.kind}:${delimiter.value.delimType}", s"${delimiter.value.lookingFor}")
            )

          val diagnosticsRootVariable =
            new Types.Variable("Diagnostics", "", null, diagnosticsRef.value, null)
          val diagnosticsValidationsVariable =
            new Types.Variable("Validations", "", null, diagnosticsValidationsRef.value, null)
          val diagnosticsErrorsVariable =
            new Types.Variable("Errors", "", null, diagnosticsErrorsRef.value, null)
          // TODO: Get better values than toString() when https://issues.apache.org/jira/browse/DAFFODIL-1200 is completed.
          val diagnosticsValidations: List[Types.Variable] =
            event.diagnostics.filter(_.isValidation).zipWithIndex.map { case (diag, i) =>
              new Types.Variable(i.toString, diag.toString().replace("Validation Error: ", ""))
            }
          val diagnosticsErrors: List[Types.Variable] =
            event.diagnostics.filterNot(_.isValidation).zipWithIndex.map { case (diag, i) =>
              new Types.Variable(i.toString, diag.toString())
            }

          val parseVariables: List[Types.Variable] =
            (List(
              new Types.Variable("hidden", hidden.toString, "bool", 0, null),
              pouRootVariable,
              delimiterStackRootVariable,
              diagnosticsRootVariable
            ) ++ childIndex.map(ci => new Types.Variable("childIndex", ci.toString)).toList
              ++ groupIndex
                .map(gi => new Types.Variable("groupIndex", gi.toString))
                .toList
              ++ occursIndex
                .map(oi => new Types.Variable("occursIndex", oi.toString))
                .toList
              ++ foundDelimiter.map(fd => new Types.Variable("foundDelimiter", fd)).toList
              ++ foundField.map(ff => new Types.Variable("foundField", ff)).toList)
              .sortBy(_.name)

          DAPodil.Frame.Scope(
            "Parse",
            ref,
            Map(
              ref -> parseVariables,
              pouRef -> pouVariables,
              delimiterStackRef -> delimiterStackVariables,
              diagnosticsRef -> List(diagnosticsValidationsVariable, diagnosticsErrorsVariable),
              diagnosticsValidationsRef -> diagnosticsValidations,
              diagnosticsErrorsRef -> diagnosticsErrors
            )
          )
      }