You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by ar...@apache.org on 2022/08/05 17:38:16 UTC

[daffodil-vscode] 12/28: - Reconfigure TDMLConfig object to be one valid case class instead of 3

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 049fede03684e7656ddbc53fb76798e4415a381d
Author: Michael Hoke <mi...@nteligen.com>
AuthorDate: Wed Jun 29 18:59:41 2022 -0400

    - Reconfigure TDMLConfig object to be one valid
    case class instead of 3
---
 .../org.apache.daffodil.debugger.dap/Parse.scala   | 43 +++++++++-------------
 1 file changed, 17 insertions(+), 26 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 b2aebff..e77cc07 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
@@ -181,10 +181,8 @@ object Parse {
       }
 
       object TDMLConfig {
-        case class Generate(name: String, description: String) extends TDMLConfig
-        case class Append(name: String, description: String) extends TDMLConfig
-        case class Execute(name: String, description: String) extends TDMLConfig
         case object None extends TDMLConfig
+        case class Config(action: String, name: String, description: String) extends TDMLConfig
       }
 
       def parse(arguments: JsonObject): EitherNel[String, LaunchArgs] =
@@ -248,16 +246,17 @@ object Parse {
                   action.getAsString() match {
                     case "none" => Right(LaunchArgs.TDMLConfig.None).toEitherNel
                     case "generate" | "append" | "execute" =>
-                      Option(tdmlConfig.getAsJsonPrimitive("name"))
-                        .map(_.getAsString())
-                        .getOrElse("Default Test Case")
-                        .asRight[String]
-                        .toEitherNel
-                      Option(tdmlConfig.getAsJsonPrimitive("description"))
-                        .map(_.getAsString())
-                        .getOrElse("Generated by DFDL VSCode Extension")
-                        .asRight[String]
-                        .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")
+                      )).toEitherNel
                     case invalidType =>
                       Left(s"invalid 'tdmlConfig.action': '$invalidType', must be 'none', 'generate', 'append', or 'execute'").toEitherNel
                   }
@@ -680,15 +679,11 @@ object Parse {
         }
     }
     sealed trait TDMLConfig {
-      val `action`: String = 
+      val action, name, description = 
         this match {
-          case TDMLConfig.None => "none"
-          case TDMLConfig.Generate(_, _) => "generate"
-          case TDMLConfig.Append(_, _) => "append"
-          case TDMLConfig.Execute(_, _) => "execute"
+          case TDMLConfig.Config(action, name, description) => (action, name, description)
+          case TDMLConfig.None => ("none", "Default Test Case Name", "Generated by DFDL VSCode Extension")
         }
-      val `name`: String = "Default Test Case Name"
-      val `description`: String = "Generated by DFDL VSCode Extension"
     }
     object InfosetOutput {
       case object None extends InfosetOutput
@@ -703,17 +698,13 @@ object Parse {
         }
     }
     object TDMLConfig {
-      case class Generate(name: String, description: String) extends TDMLConfig
-      case class Append(name: String, description: String) extends TDMLConfig
-      case class Execute(name: String, description: String) extends TDMLConfig
+      case class Config(action: String, name: String, description: String) extends TDMLConfig
       case object None extends TDMLConfig
 
       def apply(that: Debugee.LaunchArgs.TDMLConfig): TDMLConfig =
         that match {
           case Debugee.LaunchArgs.TDMLConfig.None => None
-          case Debugee.LaunchArgs.TDMLConfig.Generate(name, description) => Generate(name, description)
-          case Debugee.LaunchArgs.TDMLConfig.Append(name, description) => Append(name, description)
-          case Debugee.LaunchArgs.TDMLConfig.Execute(name, description) => Execute(name, description)
+          case Debugee.LaunchArgs.TDMLConfig.Config(action, name, description) => Config(action, name, description)
         }
     }