michael-hoke commented on code in PR #1336:
URL: https://github.com/apache/daffodil-vscode/pull/1336#discussion_r2242799791


##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -168,35 +168,50 @@ function createDebugRunFileConfigs(
         tdmlConfig.action = tdmlAction
 
         if (tdmlAction === 'execute') {
-          tdmlConfig.name = '${command:AskForTDMLName}'
-          tdmlConfig.description = '${command:AskForTDMLDescription}'
           tdmlConfig.path = targetResource.fsPath
         }
       }
 
-      vscode.debug.startDebugging(
-        undefined,
-        getConfig({
-          name: 'Run File',
-          request: 'launch',
-          type: 'dfdl',
-          schema: {
-            path: tdmlConfig.action === 'execute' ? '' : targetResource.fsPath,
-            rootName: null,
-            rootNamespace: null,
-          },
-          data:
-            tdmlConfig.action === 'execute' ? '' : '${command:AskForDataName}',
-          debugServer: false,
-          infosetFormat: 'xml',
-          infosetOutput: {
-            type: 'file',
-            path: '${workspaceFolder}/' + infosetFile,
-          },
-          tdmlConfig: tdmlConfig,
-        }),
-        { noDebug: noDebug }
-      )
+      const config = getConfig({
+        name: 'Run File',
+        request: 'launch',
+        type: 'dfdl',
+        schema: {
+          path: tdmlConfig.action === 'execute' ? '' : targetResource.fsPath,
+          rootName: null,
+          rootNamespace: null,
+        },
+        data:
+          tdmlConfig.action === 'execute' ? '' : '${command:AskForDataName}',
+        debugServer: false,
+        infosetFormat: 'xml',
+        infosetOutput: {
+          type: 'file',
+          path: '${workspaceFolder}/' + infosetFile,
+        },
+        tdmlConfig: tdmlConfig,
+      })
+
+      // If we're calling execute TDML from a .tdml file
+      // set the name and the description of the TDML test case we want
+      // before running the debugger
+      if (
+        typeof config.tdmlConfig?.path === 'string' &&
+        path.extname(config.tdmlConfig?.path).toLowerCase() == '.tdml' &&
+        typeof config.tdmlConfig?.action === 'string' &&
+        config.tdmlConfig?.action.toLowerCase() == 'execute'
+      ) {
+        config.tdmlConfig.name = await vscode.commands.executeCommand(
+          'extension.dfdl-debug.getTDMLName',
+          config
+        )
+
+        config.tdmlConfig.description = await vscode.commands.executeCommand(
+          'extension.dfdl-debug.getTDMLDescription',
+          config
+        )
+      }

Review Comment:
   It's a bad code smell - we're creating a tdmlConfig object, passing it to 
the "real" config object, then further modifying it after we've set it. It's 
better to do the modifications in one place instead of two.
   
   It'd be a good idea to go down this small rabbit hole - look in 
package.json. We are using VSCode's built-in language detection for tdml (and 
also for dfdl). In package.json, you'll find the information on how VSCode is 
identifying these file types, and if you look at the language files for each 
one, you'll see how we're telling VSCode to handle things like syntax 
highlighting.
   
   I don't believe we have any file checks in code (or need them) - pretty sure 
it's all here. We should have all of these checks already in place. If someone 
gives us a "bad" TDML file, the parsing is going to fail when we try to get 
them to select a test case. Even if they create their own launch config with a 
bad test case name/file, the scala side should also have checks to handle that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to