JeremyYao commented on code in PR #1336:
URL: https://github.com/apache/daffodil-vscode/pull/1336#discussion_r2242317927
##########
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:
Thanks for the notes.
### First Paragraph
Can you expand upon what you mean by `I'd prefer to see us modify tdmlConfig
before startDebugging is called`?
My understanding of the block of code and rationales for my changes are as
follows: `tdmlConfig` appears to be an object used for organizing the object
we're passing into `getConfig()` (see attached code snippet below).
The if statements are a safety check and may be warranted in the event of
an edge case where `config.tdmlConfig.path` point to a non-tdml file (example:
a file w/o the .tdml extension).
```TypeScript
var tdmlConfig = <TDMLConfig>{}
if (tdmlAction) {
tdmlConfig.action = tdmlAction
if (tdmlAction === 'execute') {
tdmlConfig.path = targetResource.fsPath
}
}
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
)
}
vscode.debug.startDebugging(undefined, config, { noDebug: noDebug })
```
### Second paragraph
Could you point to where the filename checks are being handled currently? I
can cross-verify and make changes accordingly. As you mentioned, `Unless
somebody is going to manually override VSCode's file type selection, we're
already automatically detecting TDML files and setting the file type to TDML`,
the changes could be good to include in there for catching edge cases when
someone overrides file type detection.
We should definitely include checks as you mentioned at the end. Accounting
for the scenario the user attempts to execute `Execute TDML` for non-TDML
files.
--
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]