You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sh...@apache.org on 2023/06/27 18:16:51 UTC

[daffodil-vscode] branch main updated: Launch Wizard updates based on 1.3.0-rc3 issues:

This is an automated email from the ASF dual-hosted git repository.

shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git


The following commit(s) were added to refs/heads/main by this push:
     new 59fb90c  Launch Wizard updates based on 1.3.0-rc3 issues:
59fb90c is described below

commit 59fb90c9fb98fcd9817b722bb84e9df18733b806
Author: Shane Dell <sh...@gmail.com>
AuthorDate: Thu Jun 22 18:12:14 2023 -0400

    Launch Wizard updates based on 1.3.0-rc3 issues:
    
    - Update daffodil debug classpath items CSS to make the items height and width match the content.
    - Make launch wizard always available. Before was only available whenever not debugging.
    - Fix issue with tdml config throw errors if action was not set.
    - infosetOutput bug fixed, was defaulting to type console when it was supposed to file.
    - Update launch wizard daffodilDebugClasspath to have separate buttons for adding files and folders.
      - Fixes issues with linux users not being able to select both folder and buttons with only the browse button
    - Change default infoset path from "${workspaceFolder}/infoset.xml" to "${workspaceFolder}/target/infoset.xml"
      - Extension will check if directory structure to file exists, if it doesn't it will make it
    
    Closes #672
    Closes #674
    Closes #675
---
 package.json                     |  11 ++-
 src/daffodilDebugger.ts          | 180 +++++++++++++++++++++++----------------
 src/launchWizard/launchWizard.js |   2 +
 src/launchWizard/launchWizard.ts |  26 +++---
 src/styles/styles.css            |  11 ++-
 src/tests/suite/utils.test.ts    |   2 +-
 src/utils.ts                     |   2 +-
 7 files changed, 140 insertions(+), 94 deletions(-)

diff --git a/package.json b/package.json
index c1cd588..147ddaa 100644
--- a/package.json
+++ b/package.json
@@ -279,7 +279,6 @@
         "command": "launch.config",
         "title": "Configure launch.json",
         "category": "Daffodil Debug",
-        "enablement": "!inDebugMode",
         "icon": "$(debug-configure)"
       },
       {
@@ -345,8 +344,8 @@
                 "type": "object",
                 "description": "Destination for final Infoset ('file' | 'console' | 'none')",
                 "default": {
-                  "type": "console",
-                  "path": "${workspaceFolder}/infoset.xml"
+                  "type": "file",
+                  "path": "${workspaceFolder}/target/infoset.xml" 
                 }
               },
               "tdmlConfig": {
@@ -436,7 +435,7 @@
             "infosetFormat": "xml",
             "infosetOutput": {
               "type": "file",
-              "path": "${workspaceFolder}/infoset.xml"
+              "path": "${workspaceFolder}/target/infoset.xml" 
             },
             "debugServer": 4711,
             "openHexView": false,
@@ -466,7 +465,7 @@
               "infosetFormat": "xml",
               "infosetOutput": {
                 "type": "file",
-                "path": "${workspaceFolder}/infoset.xml"
+                "path": "${workspaceFolder}/target/infoset.xml" 
               },
               "debugServer": 4711,
               "openHexView": false,
@@ -549,7 +548,7 @@
           "infosetOutputFilePath": {
             "type": "string",
             "description": "Path to output for Infoset file (req: infosetOutput=file)",
-            "default": "${workspaceFolder}/infoset.xml"
+            "default": "${workspaceFolder}/target/infoset.xml" 
           },
           "stopOnEntry": {
             "type": "boolean",
diff --git a/src/daffodilDebugger.ts b/src/daffodilDebugger.ts
index ad6e63f..99a76a8 100644
--- a/src/daffodilDebugger.ts
+++ b/src/daffodilDebugger.ts
@@ -71,6 +71,90 @@ export async function getDataFileFromFolder(dataFolder: string) {
     })
 }
 
+async function getTDMLConfig(
+  config: vscode.DebugConfiguration
+): Promise<boolean> {
+  // If not supported TDML action entered, delete tdml config so no errors are thrown
+  if (!['execute', 'generate', 'append'].includes(config?.tdmlConfig?.action)) {
+    delete config.tdmlConfig
+  }
+
+  // If we are doing a TDML execute, these fields will be replaced,
+  //   so we don't need to prompt for them now.
+  if (config?.tdmlConfig?.action === 'execute') {
+    // Erase the value of `data` so that we aren't prompted for it later
+    // Might need to add `program` here if we move the `Execute TDML` command
+    //   away from the detected dfdl language in VSCode.
+    config.data = ''
+  } else {
+    // Get program file before debugger starts to avoid timeout
+    if (config.program.includes('${command:AskForProgramName}')) {
+      config.program = await vscode.commands.executeCommand(
+        'extension.dfdl-debug.getProgramName'
+      )
+    }
+
+    if (config.program === '') {
+      // need to invalidate a variable data file so the DebugConfigurationProvider doesn't try to resolve it after we return
+      if (config.data.includes('${command:AskForDataName}')) {
+        config.data = ''
+      }
+
+      return false
+    }
+
+    // Get data file before debugger starts to avoid timeout
+    if (config.data.includes('${command:AskForDataName}')) {
+      config.data = await vscode.commands.executeCommand(
+        'extension.dfdl-debug.getDataName'
+      )
+    }
+  }
+
+  if (
+    config?.tdmlConfig?.action === 'generate' ||
+    config?.tdmlConfig?.action === 'append' ||
+    config?.tdmlConfig?.action === 'execute'
+  ) {
+    if (
+      config?.tdmlConfig?.name === undefined ||
+      config?.tdmlConfig?.name.includes('${command:AskForTDMLName}')
+    )
+      config.tdmlConfig.name = await vscode.commands.executeCommand(
+        'extension.dfdl-debug.getTDMLName'
+      )
+
+    if (
+      config?.tdmlConfig?.description === undefined ||
+      config?.tdmlConfig?.description.includes(
+        '${command:AskForTDMLDescription}'
+      )
+    )
+      config.tdmlConfig.description = await vscode.commands.executeCommand(
+        'extension.dfdl-debug.getTDMLDescription'
+      )
+
+    if (
+      config?.tdmlConfig?.path === undefined ||
+      config?.tdmlConfig?.path.includes('${command:AskForTDMLPath}')
+    )
+      if (config?.tdmlConfig?.action === 'generate')
+        config.tdmlConfig.path = await vscode.commands.executeCommand(
+          'extension.dfdl-debug.getTDMLPath'
+        )
+      else
+        config.tdmlConfig.path = await vscode.commands.executeCommand(
+          'extension.dfdl-debug.getValidatedTDMLPath'
+        )
+  }
+
+  if (config?.tdmlConfig?.action !== 'execute' && config.data === '') {
+    return false
+  }
+
+  return true
+}
+
 // Function for getting the daffodil-debugger
 export async function getDebugger(
   context: vscode.ExtensionContext,
@@ -109,76 +193,7 @@ export async function getDebugger(
 
       await stopDebugger()
 
-      // If we are doing a TDML execute, these fields will be replaced,
-      //   so we don't need to prompt for them now.
-      if (config?.tdmlConfig?.action === 'execute') {
-        // Erase the value of `data` so that we aren't prompted for it later
-        // Might need to add `program` here if we move the `Execute TDML` command
-        //   away from the detected dfdl language in VSCode.
-        config.data = ''
-      } else {
-        // Get program file before debugger starts to avoid timeout
-        if (config.program.includes('${command:AskForProgramName}')) {
-          config.program = await vscode.commands.executeCommand(
-            'extension.dfdl-debug.getProgramName'
-          )
-        }
-
-        if (config.program === '') {
-          // need to invalidate a variable data file so the DebugConfigurationProvider doesn't try to resolve it after we return
-          if (config.data.includes('${command:AskForDataName}')) {
-            config.data = ''
-          }
-
-          return await stopDebugging()
-        }
-
-        // Get data file before debugger starts to avoid timeout
-        if (config.data.includes('${command:AskForDataName}')) {
-          config.data = await vscode.commands.executeCommand(
-            'extension.dfdl-debug.getDataName'
-          )
-        }
-      }
-
-      if (
-        config?.tdmlConfig?.action === 'generate' ||
-        config?.tdmlConfig?.action === 'append' ||
-        config?.tdmlConfig?.action === 'execute'
-      ) {
-        if (
-          config?.tdmlConfig?.name === undefined ||
-          config?.tdmlConfig?.name.includes('${command:AskForTDMLName}')
-        )
-          config.tdmlConfig.name = await vscode.commands.executeCommand(
-            'extension.dfdl-debug.getTDMLName'
-          )
-
-        if (
-          config?.tdmlConfig?.description === undefined ||
-          config?.tdmlConfig?.description.includes(
-            '${command:AskForTDMLDescription}'
-          )
-        )
-          config.tdmlConfig.description = await vscode.commands.executeCommand(
-            'extension.dfdl-debug.getTDMLDescription'
-          )
-
-        if (
-          config?.tdmlConfig?.path === undefined ||
-          config?.tdmlConfig?.path.includes('${command:AskForTDMLPath}')
-        )
-          if (config?.tdmlConfig?.action === 'generate')
-            config.tdmlConfig.path = await vscode.commands.executeCommand(
-              'extension.dfdl-debug.getTDMLPath'
-            )
-          else
-            config.tdmlConfig.path = await vscode.commands.executeCommand(
-              'extension.dfdl-debug.getValidatedTDMLPath'
-            )
-      }
-
-      if (config?.tdmlConfig?.action !== 'execute' && config.data === '') {
+      if (!(await getTDMLConfig(config))) {
         return await stopDebugging()
       }
 
@@ -191,9 +206,14 @@ export async function getDebugger(
 
       //check if each classpath still exists
       if (config.daffodilDebugClasspath) {
-        config.daffodilDebugClasspath.split(':').forEach((entry) => {
-          if (!fs.existsSync(entry)) {
-            throw new Error(`File or directory: ${entry} doesn't exist`)
+        config.daffodilDebugClasspath.split(':').forEach((entry: string) => {
+          let fullpathEntry = entry.replaceAll(
+            '${workspaceFolder}',
+            workspaceFolder
+          )
+
+          if (!fs.existsSync(fullpathEntry)) {
+            throw new Error(`File or directory: ${fullpathEntry} doesn't exist`)
           }
         })
 
@@ -207,6 +227,20 @@ export async function getDebugger(
           : config.daffodilDebugClasspath
       }
 
+      // make sure infoset output directory is present
+      if (config.infosetOutput.type == 'file') {
+        let dir = path.dirname(
+          config.infosetOutput.path.includes('${workspaceFolder}')
+            ? config.infosetOutput.path.replace(
+                '${workspaceFolder}',
+                vscode.workspace.workspaceFolders[0].uri.fsPath
+              )
+            : config.infosetOutput.path
+        )
+
+        if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
+      }
+
       // Start debugger in terminal based on scriptName
 
       /*
diff --git a/src/launchWizard/launchWizard.js b/src/launchWizard/launchWizard.js
index 0d1e8d5..b77e94d 100644
--- a/src/launchWizard/launchWizard.js
+++ b/src/launchWizard/launchWizard.js
@@ -65,6 +65,8 @@ function filePicker(id, description) {
     id: id,
     description: description,
     configIndex: getConfigIndex(),
+    selectFiles: description.includes('file(s)') ? true : false,
+    selectFolders: description.includes('folder(s)') ? true : false,
     extraData: extraData,
   })
 }
diff --git a/src/launchWizard/launchWizard.ts b/src/launchWizard/launchWizard.ts
index 7fd8bfc..73b896a 100644
--- a/src/launchWizard/launchWizard.ts
+++ b/src/launchWizard/launchWizard.ts
@@ -146,20 +146,21 @@ async function updateWebViewConfigValues(configIndex) {
 }
 
 // Function to create file picker for wizard
-async function openFilePicker(description) {
+async function openFilePicker(
+  description: string,
+  selectFiles: boolean = true,
+  selectFolders: boolean = true
+) {
   let rootPath = vscode.workspace.workspaceFolders
     ? vscode.workspace.workspaceFolders[0].uri.fsPath
-    : vscode.Uri.parse('').fsPath
-
-  let canSelectMany = !!description.includes('jar files/folder')
-  let canSelectFolders = !!description.includes('jar files/folder')
+    : vscode.Uri.file('').fsPath
 
   let chosenFile = await vscode.window
     .showOpenDialog({
-      canSelectMany: canSelectMany,
+      canSelectMany: true,
       openLabel: description,
-      canSelectFiles: true,
-      canSelectFolders: canSelectFolders,
+      canSelectFiles: selectFiles,
+      canSelectFolders: selectFolders,
       title: description,
     })
     .then(async (fileUri) => {
@@ -197,7 +198,11 @@ async function createWizard(ctx: vscode.ExtensionContext) {
           })
           return
         case 'openFilePicker':
-          let result = await openFilePicker(message.description)
+          let result = await openFilePicker(
+            message.description,
+            message.selectFiles,
+            message.selectFolders
+          )
 
           // don't add empty string to table
           if (result !== '') {
@@ -458,7 +463,8 @@ class LaunchWizard {
         ${daffodilDebugClasspathList}
 
         <p style="margin-left: 5px">
-          <button id="daffodilDebugClasspathBrowse" class="browse-button" type="button" onclick="filePicker('daffodilDebugClasspath', 'Select jar files/folder with desired jars')">Browse</button>
+          <button id="daffodilDebugClasspathAddFolders" class="browse-button" type="button" onclick="filePicker('daffodilDebugClasspath', 'Select folder(s) with desired jars')">Add Folder(s)</button>
+          <button id="daffodilDebugClasspathAddFiles" class="browse-button" type="button" onclick="filePicker('daffodilDebugClasspath', 'Select jar file(s)')">Add JAR File(s)</button>
         </p>
       </div>
 
diff --git a/src/styles/styles.css b/src/styles/styles.css
index 59da008..05455ac 100644
--- a/src/styles/styles.css
+++ b/src/styles/styles.css
@@ -34,14 +34,19 @@
   color: white;
   cursor: pointer;
   background-color: rgb(80, 78, 78);
-  width: 375px;
-  height: 25px;
+  width: fit-content;
+  height: fit-content;
   font-size: 12px;
   border: none;
   border-radius: 12px;
   padding-left: 7px;
+  padding-right: 10px;
+  padding-bottom: 5px;
   margin: 0px;
   margin-top: 5px;
+
+  word-wrap: break-word;
+  word-break: break-all;
 }
 
 /* Hide the browser's default checkbox */
@@ -130,7 +135,7 @@
   font-size: 12px;
   cursor: pointer;
   width: 75px;
-  height: 25px;
+  height: fit-content;
 }
 
 .minus-button {
diff --git a/src/tests/suite/utils.test.ts b/src/tests/suite/utils.test.ts
index 4e15543..c51aafb 100644
--- a/src/tests/suite/utils.test.ts
+++ b/src/tests/suite/utils.test.ts
@@ -33,7 +33,7 @@ suite('Utils Test Suite', () => {
     infosetFormat: 'xml',
     infosetOutput: {
       type: 'none',
-      path: '${workspaceFolder}/infoset.xml',
+      path: '${workspaceFolder}/target/infoset.xml',
     },
     stopOnEntry: true,
     useExistingServer: false,
diff --git a/src/utils.ts b/src/utils.ts
index d2d2e27..c300ca8 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -129,7 +129,7 @@ export function getConfig(
           type: defaultConf.get('infosetOutputType', 'none'),
           path: defaultConf.get(
             'infosetOutputFilePath',
-            '${workspaceFolder}/infoset.xml'
+            '${workspaceFolder}/target/infoset.xml'
           ),
         },
     stopOnEntry: stopOnEntry