This is an automated email from the ASF dual-hosted git repository. arosien pushed a commit to branch daffodil-vscode-tdml in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git
commit 2e8f0c1bb12547b4e520b4fbd3845897db406c96 Author: Adam Rosien <[email protected]> AuthorDate: Tue Jul 26 09:49:49 2022 -0700 Push Debugee.LaunchArgs path updating out of debugee launcher. Also formatting. --- .../org.apache.daffodil.debugger.dap/Parse.scala | 76 ++++++++++++---------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala b/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala index 1a390ed..56ce09d 100644 --- a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala +++ b/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala @@ -244,22 +244,26 @@ object Parse { action.getAsString() match { case "none" => Right(LaunchArgs.TDMLConfig.None).toEitherNel case "generate" | "append" | "execute" => - Right(LaunchArgs.TDMLConfig.Config( - Option(tdmlConfig.getAsJsonPrimitive("action")) - .map(_.getAsString()) - .getOrElse("None"), - Option(tdmlConfig.getAsJsonPrimitive("name")) - .map(_.getAsString()) - .getOrElse("Default Test Case"), - Option(tdmlConfig.getAsJsonPrimitive("description")) - .map(_.getAsString()) - .getOrElse("Generated by DFDL VSCode Extension"), - Option(tdmlConfig.getAsJsonPrimitive("path")) - .map(_.getAsString()) - .getOrElse("") - )).toEitherNel + Right( + LaunchArgs.TDMLConfig.Config( + Option(tdmlConfig.getAsJsonPrimitive("action")) + .map(_.getAsString()) + .getOrElse("None"), + Option(tdmlConfig.getAsJsonPrimitive("name")) + .map(_.getAsString()) + .getOrElse("Default Test Case"), + Option(tdmlConfig.getAsJsonPrimitive("description")) + .map(_.getAsString()) + .getOrElse("Generated by DFDL VSCode Extension"), + Option(tdmlConfig.getAsJsonPrimitive("path")) + .map(_.getAsString()) + .getOrElse("") + ) + ).toEitherNel case invalidType => - Left(s"invalid 'tdmlConfig.action': '$invalidType', must be 'none', 'generate', 'append', or 'execute'").toEitherNel + Left( + s"invalid 'tdmlConfig.action': '$invalidType', must be 'none', 'generate', 'append', or 'execute'" + ).toEitherNel } } } @@ -271,7 +275,18 @@ object Parse { val dataDumpSource = DAPodil.Source(Paths.get("data"), Some(DAPodil.Source.Ref(2))) def debugee(request: Request): EitherNel[String, Resource[IO, DAPodil.Debugee]] = - Debugee.LaunchArgs.parse(request.arguments).map(debugee) + Debugee.LaunchArgs + .parse(request.arguments) + .map { args => + // TODO: move this into Debugee.LaunchArgs + args.tdmlConfig match { + case Debugee.LaunchArgs.TDMLConfig.Config("execute", name, description, tdmlPath) => + val (schemaPath, dataPath) = TDMLWrapper.execute(args.schemaPath, args.dataPath, name, description, tdmlPath) + args.copy(schemaPath = schemaPath, dataPath = dataPath) + case _ => args + } + } + .map(debugee) def debugee(args: Debugee.LaunchArgs): Resource[IO, DAPodil.Debugee] = for { @@ -282,22 +297,6 @@ object Parse { infoset <- Resource.eval(Queue.bounded[IO, Option[String]](10)) // TODO: it's a bit incongruous to have a separate channel for infoset changes, vs. streaming Parse.Event values control <- Resource.eval(Control.stopped()) - pathTuple = args.tdmlConfig match { - case Debugee.LaunchArgs.TDMLConfig.Config(action, name, description, tdmlPath) => - if (action == "execute") { - TDMLWrapper.execute(args.schemaPath, args.dataPath, name, description, tdmlPath) - } - else - (args.schemaPath, args.dataPath) - case _ => - (args.schemaPath, args.dataPath) - } - - // pathTuple will start with the original values of these paths and will only get updated if - // these paths need to be changed. - args.schemaPath = pathTuple._1 - args.dataPath = pathTuple._2 - latestData <- Stream.fromQueueNoneTerminated(data).holdResource(DAPodil.Data.empty) latestInfoset <- Resource.eval(SignallingRef[IO, String]("")) @@ -388,7 +387,7 @@ object Parse { IO(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM)) } else - IO(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM)) + IO(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM)) case _ => IO(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM)) } @@ -658,7 +657,13 @@ object Parse { case class ConfigEvent(launchArgs: ConfigEvent.LaunchArgs, buildInfo: ConfigEvent.BuildInfo) extends Events.DebugEvent("daffodil.config") object ConfigEvent { - case class LaunchArgs(schemaPath: String, dataPath: String, stopOnEntry: Boolean, infosetOutput: InfosetOutput, tdmlConfig: TDMLConfig) + case class LaunchArgs( + schemaPath: String, + dataPath: String, + stopOnEntry: Boolean, + infosetOutput: InfosetOutput, + tdmlConfig: TDMLConfig + ) sealed trait InfosetOutput { val `type`: String = @@ -698,7 +703,8 @@ object Parse { def apply(that: Debugee.LaunchArgs.TDMLConfig): TDMLConfig = that match { case Debugee.LaunchArgs.TDMLConfig.None => None - case Debugee.LaunchArgs.TDMLConfig.Config(action, name, description, path) => Config(action, name, description, path) + case Debugee.LaunchArgs.TDMLConfig.Config(action, name, description, path) => + Config(action, name, description, path) } }
