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 942a335732c662f6b1d508ecddb48402f9eccb63
Author: Michael Hoke <[email protected]>
AuthorDate: Tue Jul 12 12:30:19 2022 -0400

    - Add file path to TDML Config
    -Add remaining hook for Generate action
---
 .vscode/launch.json                                | 11 ++++++++++-
 package.json                                       |  9 ++++++---
 .../org.apache.daffodil.debugger.dap/Parse.scala   | 22 +++++++++++++++++-----
 src/adapter/activateDaffodilDebug.ts               | 18 ++++++++++++------
 src/utils.ts                                       |  4 ++++
 5 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/.vscode/launch.json b/.vscode/launch.json
index b11cd6d..b3df683 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -29,7 +29,7 @@
                        "outFiles": [
                                "${workspaceFolder}/dist/ext/**/*.js"
                        ],
-                       "preLaunchTask": "npm: watch",
+                       "preLaunchTask": "npm: watch"
                },
                {
                        "name": "Tests",
@@ -48,6 +48,15 @@
                        ],
                        "internalConsoleOptions": "openOnSessionStart",
                        "preLaunchTask": "npm: compile"
+               },
+               {
+                       "type": "scala",
+                       "request": "launch",
+                       "name": "DAPodil",
+                       "mainClass": "org.apache.daffodil.debugger.dap.DAPodil",
+                       "args": [],
+                       "jvmOptions": [],
+                       "env": {}
                }
        ]
 }
diff --git a/package.json b/package.json
index 70db8c8..23f6552 100644
--- a/package.json
+++ b/package.json
@@ -323,7 +323,8 @@
                 "default": {
                   "action": "none",
                   "name": "Default Test Case",
-                  "description": "Generated by DFDL VSCode Extension"
+                  "description": "Generated by DFDL VSCode Extension",
+                  "path": "${workspaceFolder}/infoset.tdml"
                 }
               },
               "stopOnEntry": {
@@ -384,7 +385,8 @@
             "tdmlConfig": {
               "action": "none",
               "name": "Default Test Case",
-              "description": "Generated by DFDL VSCode Extension"
+              "description": "Generated by DFDL VSCode Extension",
+              "path": "${workspaceFolder}/infoset.tdml"
             },
             "debugServer": 4711,
             "openHexView": false,
@@ -411,7 +413,8 @@
               "tdmlConfig": {
                 "action": "none",
                 "name": "Default Test Case",
-                "description": "Generated by DFDL VSCode Extension"
+                "description": "Generated by DFDL VSCode Extension",
+                "path": "${workspaceFolder}/infoset.tdml"
               },
               "debugServer": 4711,
               "openHexView": false,
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 74f5aed..dff5e98 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
@@ -182,7 +182,7 @@ object Parse {
 
       object TDMLConfig {
         case object None extends TDMLConfig
-        case class Config(action: String, name: String, description: String) 
extends TDMLConfig
+        case class Config(action: String, name: String, description: String, 
path: String) extends TDMLConfig
       }
 
       def parse(arguments: JsonObject): EitherNel[String, LaunchArgs] =
@@ -255,7 +255,10 @@ object Parse {
                           .getOrElse("Default Test Case"),
                         Option(tdmlConfig.getAsJsonPrimitive("description"))
                           .map(_.getAsString())
-                          .getOrElse("Generated by DFDL VSCode Extension")
+                          .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
@@ -389,8 +392,15 @@ object Parse {
                   
testSuite.setSuiteName(FilenameUtils.getBaseName(args.schemaPath.toString()))
                   testSuite.setDefaultRoundTrip(RoundTripType.ONE_PASS)
                   
testSuite.getTutorialOrParserTestCaseOrDefineSchema().add(testCase)
+
+                  args.tdmlConfig match {
+                    case Debugee.LaunchArgs.TDMLConfig.Config(_, _, _, 
tdml_path) =>
+                      
IO(JAXBContext.newInstance(classOf[TestSuite]).createMarshaller().marshal(testSuite,
 new FileOutputStream(tdml_path)))
+                    case _ =>
+                      IO(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM))
+                  }
                   
-                  
IO(JAXBContext.newInstance(classOf[TestSuite]).createMarshaller().marshal(testSuite,
 new FileOutputStream(path.toFile())))
+            
                   
                   // path.toString()
                 case _ =>
@@ -682,6 +692,7 @@ object Parse {
       val action: String
       val name: String
       val description: String
+      val path: String
     }
     object InfosetOutput {
       case object None extends InfosetOutput
@@ -696,17 +707,18 @@ object Parse {
         }
     }
     object TDMLConfig {
-      case class Config(action: String, name: String, description: String) 
extends TDMLConfig
+      case class Config(action: String, name: String, description: String, 
path: String) extends TDMLConfig
       case object None extends TDMLConfig {
         val action = "none"
         val name = "Default Test Case Name"
         val description = "Generated by DFDL VSCode Extension"
+        val path = ""
       }
 
       def apply(that: Debugee.LaunchArgs.TDMLConfig): TDMLConfig =
         that match {
           case Debugee.LaunchArgs.TDMLConfig.None => None
-          case Debugee.LaunchArgs.TDMLConfig.Config(action, name, description) 
=> Config(action, name, description)
+          case Debugee.LaunchArgs.TDMLConfig.Config(action, name, description, 
path) => Config(action, name, description, path)
         }
     }
 
diff --git a/src/adapter/activateDaffodilDebug.ts 
b/src/adapter/activateDaffodilDebug.ts
index f3efa7f..3fd782b 100644
--- a/src/adapter/activateDaffodilDebug.ts
+++ b/src/adapter/activateDaffodilDebug.ts
@@ -28,7 +28,7 @@ import * as dfdlLang from '../language/dfdl'
 function createDebugRunFileConfigs(
   resource: vscode.Uri,
   runOrDebug: String,
-  tdmlConfig: TDMLConfig | undefined
+  tdmlAction: String | undefined
 ) {
   let targetResource = resource
   let noDebug = runOrDebug === 'run' ? true : false
@@ -42,6 +42,12 @@ function createDebugRunFileConfigs(
     }-infoset.xml`
     vscode.window.showInformationMessage(infosetFile)
 
+    var tdmlConfig = <TDMLConfig>{}
+
+    if (tdmlAction) {
+      tdmlConfig.action = tdmlAction
+    }
+
     vscode.debug.startDebugging(
       undefined,
       getConfig(
@@ -93,7 +99,7 @@ export function activateDaffodilDebug(
     vscode.commands.registerCommand(
       'extension.dfdl-debug.generateTDML',
       (resource: vscode.Uri) => {
-        null // TODO
+        createDebugRunFileConfigs(resource, 'run', 'generate')
       }
     ),
     vscode.commands.registerCommand(
@@ -439,8 +445,8 @@ class InlineDebugAdapterFactory
 }
 
 export interface TDMLConfig {
-  generate: boolean
-  append: boolean
-  name: string
-  description: string
+  action: String
+  name: String
+  description: String
+  path: String
 }
diff --git a/src/utils.ts b/src/utils.ts
index 8a5891a..5c5690d 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -119,6 +119,10 @@ export function getConfig(
             'tdmlDescription',
             'Generated by DFDL VSCode Extension'
           ),
+          path: defaultConf.get(
+            'tdmlConfigPath',
+            '${workspaceFolder}/infoset.tdml'
+          ),
         },
     stopOnEntry: stopOnEntry
       ? stopOnEntry

Reply via email to