@@ -82,7 +82,7 @@ object Parse {
8282 outputData : Signal [IO , DAPodil .Data ],
8383 outputState : Stream [IO , DAPodil .Debugee .State ],
8484 stateSink : QueueSink [IO , Option [DAPodil .Debugee .State ]],
85- outputEvents : Stream [IO , Events .OutputEvent ],
85+ events : Stream [IO , Events .DebugEvent ],
8686 breakpoints : Breakpoints ,
8787 control : Control
8888 ) extends DAPodil .Debugee {
@@ -92,11 +92,12 @@ object Parse {
9292 def state (): Stream [IO , DAPodil .Debugee .State ] =
9393 outputState
9494
95- def outputs (): Stream [IO , Events .OutputEvent ] =
96- outputEvents
95+ def events (): Stream [IO , Events .DebugEvent ] =
96+ events
9797
98+ /** We return only the "static" sources of the schema and data file, and notify the debugger of additional sources via source change events, which only subsequently fetch the content directly (not via another `sources` call). */
9899 def sources (): IO [List [DAPodil .Source ]] =
99- IO .pure(List (schema, data, infosetSource, dataDumpSource ))
100+ IO .pure(List (schema, data))
100101
101102 def sourceContent (ref : DAPodil .Source .Ref ): IO [Option [DAPodil .Source .Content ]] =
102103 ref.value match {
@@ -140,6 +141,7 @@ object Parse {
140141
141142 object Debugee {
142143
144+ // TODO: feature flags for infoset and data position event strategies (loadedSource event vs. custom event)
143145 case class LaunchArgs (
144146 schemaPath : file.Path ,
145147 dataPath : file.Path ,
@@ -223,7 +225,7 @@ object Parse {
223225 for {
224226 data <- Resource .eval(Queue .bounded[IO , Option [DAPodil .Data ]](10 ))
225227 state <- Resource .eval(Queue .bounded[IO , Option [DAPodil .Debugee .State ]](10 ))
226- outputs <- Resource .eval(Queue .bounded[IO , Option [Events .OutputEvent ]](10 ))
228+ dapEvents <- Resource .eval(Queue .bounded[IO , Option [Events .DebugEvent ]](10 ))
227229 breakpoints <- Resource .eval(Breakpoints ())
228230 infoset <- Resource .eval(Queue .bounded[IO , Option [String ]](10 ))
229231 dataDump <- Resource .eval(Queue .bounded[IO , Option [String ]](10 ))
@@ -241,6 +243,7 @@ object Parse {
241243 infosetChanges = Stream
242244 .fromQueueNoneTerminated(infoset)
243245 .evalTap(latestInfoset.set)
246+ .evalTap(content => dapEvents.offer(Some (InfosetEvent (content, " text/xml" ))))
244247 .onFinalizeCase(ec => Logger [IO ].debug(s " infosetChanges (orig): $ec" ))
245248
246249 latestDataDump <- Resource .eval(SignallingRef [IO , String ](" " ))
@@ -263,7 +266,7 @@ object Parse {
263266 latestData,
264267 Stream .fromQueueNoneTerminated(state),
265268 state,
266- Stream .fromQueueNoneTerminated(outputs ),
269+ Stream .fromQueueNoneTerminated(dapEvents ),
267270 breakpoints,
268271 control
269272 )
@@ -283,7 +286,7 @@ object Parse {
283286 .foldMonoid
284287 .evalTap(_ => Logger [IO ].debug(" done collecting infoset XML output" ))
285288 .map(infosetXML => Events .OutputEvent .createConsoleOutput(infosetXML))
286- .enqueueNoneTerminated(outputs )
289+ .enqueueNoneTerminated(dapEvents )
287290 case Debugee .LaunchArgs .InfosetOutput .File (path) =>
288291 parse.run().through(Files [IO ].writeAll(path))
289292 }
@@ -293,6 +296,10 @@ object Parse {
293296
294297 deliverParseData = Stream
295298 .fromQueueNoneTerminated(events)
299+ .evalTap {
300+ case start : Event .StartElement => dapEvents.offer(Some (DataEvent (start.state.currentLocation.bytePos1b)))
301+ case _ => IO .unit
302+ }
296303 .through(fromParse(nextFrameId, nextRef))
297304 .enqueueNoneTerminated(data)
298305
@@ -542,6 +549,9 @@ object Parse {
542549 }
543550 }
544551
552+ case class DataEvent (bytePos1b : Long ) extends Events .DebugEvent (" daffodil.data" )
553+ case class InfosetEvent (content : String , mimeType : String ) extends Events .DebugEvent (" daffodil.infoset" )
554+
545555 /** Behavior of a stepping debugger that can be running or stopped. */
546556 sealed trait Control {
547557
@@ -594,7 +604,7 @@ object Parse {
594604 case Stopped (whenContinued, _) =>
595605 Stopped (nextContinue, nextAwaitStarted) -> (
596606 whenContinued.complete(()) *> // wake up await-ers
597- nextAwaitStarted.get // block until next await is invoked
607+ nextAwaitStarted.get // block until next await is invoked
598608 )
599609 }.flatten
600610 } yield ()
0 commit comments