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 1639d792290da14e05a9edea3682f6a9cb6542cd Author: Michael Hoke <[email protected]> AuthorDate: Mon Aug 1 11:05:13 2022 -0400 attempt to get Typescript properly talking to Scala --- package.json | 5 +++ .../org.apache.daffodil.debugger.dap/Parse.scala | 9 ++-- src/daffodilDebugger.ts | 11 +++-- src/launchWizard/launchWizard.js | 50 +++++++++++++++++++++ src/launchWizard/launchWizard.ts | 51 ++++++++++++++++++++++ src/utils.ts | 5 +-- 6 files changed, 118 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 23f6552..cf0ada6 100644 --- a/package.json +++ b/package.json @@ -469,6 +469,11 @@ "description": "Description of the TDML Test Case", "default": "${command:AskForTDMLDescription}" }, + "tdmlPath": { + "type": "string", + "description": "Path to output for TDML file (req: tdmlAction=generate)", + "default": "${workspaceFolder}/infoset.tdml" + }, "infosetOutputType": { "type": "string", "description": "Destination for final Infoset (file | 'console' | 'none')", 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 0b60bca..4620b91 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 @@ -166,8 +166,9 @@ object Parse { lazy val (schemaPath: Path, dataPath: Path) = tdmlConfig .map { - case LaunchArgs.TDMLConfig(_, name, description, path) => - TDMLWrapper.execute(defaultSchemaPath, defaultDataPath, name, description, path) + case LaunchArgs.TDMLConfig(action, name, description, path) => + if (action == "execute") + TDMLWrapper.execute(defaultSchemaPath, defaultDataPath, name, description, path) } .getOrElse(defaultSchemaPath -> defaultDataPath) @@ -282,9 +283,7 @@ object Parse { val dataDumpSource = DAPodil.Source(Paths.get("data"), Some(DAPodil.Source.Ref(2))) def debugee(request: Request): EitherNel[String, Resource[IO, DAPodil.Debugee]] = - Debugee.LaunchArgs - .parse(request.arguments) - .map(debugee) + Debugee.LaunchArgs.parse(request.arguments).map(debugee) def debugee(args: Debugee.LaunchArgs): Resource[IO, DAPodil.Debugee] = for { diff --git a/src/daffodilDebugger.ts b/src/daffodilDebugger.ts index f0482d3..7ff0dd4 100644 --- a/src/daffodilDebugger.ts +++ b/src/daffodilDebugger.ts @@ -186,14 +186,17 @@ export async function getDebugger( } if (config.tdmlConfig.action !== 'none') { - if (config.tdmlName === '') { - config.tdmlName = await vscode.commands.executeCommand( + if ( + typeof config.tdmlConfig.name !== 'undefined' && + config.tdmlConfig.name === '' + ) { + config.tdmlConfig.name = await vscode.commands.executeCommand( 'extension.dfdl-debug.getTDMLName' ) } - if (config.tdmlDescription === '') { - config.tdmlDescription = await vscode.commands.executeCommand( + if (config.tdmlConfig.description === '') { + config.tdmlConfig.description = await vscode.commands.executeCommand( 'extension.dfdl-debug.getTDMLDescription' ) } diff --git a/src/launchWizard/launchWizard.js b/src/launchWizard/launchWizard.js index 25c9b14..4469aca 100644 --- a/src/launchWizard/launchWizard.js +++ b/src/launchWizard/launchWizard.js @@ -56,6 +56,31 @@ function updateInfosetOutputType() { } } +// Function to update select TDML action +function updateTDMLAction() { + var tdmlSelectionBox = document.getElementById('tdmlAction') + var tdmlSelectedValue = + tdmlSelectionBox.options[tdmlSelectionBox.selectedIndex].value + + if (tdmlSelectedValue !== 'none') { + document.getElementById('tdmlNameLabel').style = + 'margin-top: 10px; visibility: visible;' + document.getElementById('tdmlDescriptionLabel').style = + 'margin-top: 10px; visibility: visible;' + } else { + document.getElementById('tdmlNameLabel').style = 'visibility: hidden;' + document.getElementById('tdmlDescriptionLabel').style = + 'visibility: hidden;' + } + + if (tdmlSelectedValue === 'generate') { + document.getElementById('tdmlPath').style = + 'margin-top: 10px; visibility: visible;' + } else { + document.getElementById('tdmlPath').style = 'visibility: hidden;' + } +} + // Function to update config selected, also display name input box if 'New Config' selected function updateSelectedConfig() { var configSelectionBox = document.getElementById('configSelected') @@ -101,6 +126,10 @@ function save() { 'infosetOutputFilePath' ).value const infosetOutputType = document.getElementById('infosetOutputType').value + const tdmlAction = document.getElementById('tdmlAction').value + const tdmlName = document.getElementById('tdmlName').value + const tdmlDescription = document.getElementById('tdmlDescription').value + const tdmlPath = document.getElementById('tdmlPath').value const openHexView = document.getElementById('openHexView').checked const openInfosetDiffView = document.getElementById( 'openInfosetDiffView' @@ -125,6 +154,12 @@ function save() { type: infosetOutputType, path: infosetOutputFilePath, }, + tdmlConfig: { + action: tdmlAction, + name: tdmlName, + description: tdmlDescription, + path: tdmlPath, + }, trace: trace, stopOnEntry: stopOnEntry, useExistingServer: useExistingServer, @@ -157,6 +192,20 @@ function updateConfigValues(config) { ] ? config.infosetOutput['type'] : config.infosetOutputType + document.getElementById('tdmlAction').value = config.tdmlConfig['action'] + ? config.tdmlConfig['action'] + : config.tdmlAction + document.getElementById('tdmlName').value = config.tdmlConfig['name'] + ? config.tdmlConfig['name'] + : config.tdmlName + document.getElementById('tdmlDescription').value = config.tdmlConfig[ + 'description' + ] + ? config.tdmlConfig['description'] + : config.tdmlDescription + document.getElementById('tdmlPath').value = config.tdmlConfig['path'] + ? config.tdmlConfig['path'] + : config.tdmlPath document.getElementById('openHexView').checked = config.openHexView document.getElementById('openInfosetDiffView').checked = config.openInfosetDiffView @@ -167,6 +216,7 @@ function updateConfigValues(config) { document.getElementById('useExistingServer').checked = config.useExistingServer updateInfosetOutputType() + updateTDMLAction() } // Function for updating the classpath input box diff --git a/src/launchWizard/launchWizard.ts b/src/launchWizard/launchWizard.ts index f49eb5c..2770af6 100644 --- a/src/launchWizard/launchWizard.ts +++ b/src/launchWizard/launchWizard.ts @@ -355,6 +355,37 @@ class LaunchWizard { } }) + let tdmlActionSelect = '' + let tdmlActions = ['none', 'generate', 'append', 'execute'] + let tdmlAction = defaultValues.tdmlConfig['action'] + ? defaultValues.tdmlConfig['type'] + : defaultValues.tdmlAction + let tdmlName = defaultValues.tdmlConfig['name'] + ? defaultValues.tdmlConfig['name'] + : defaultValues.tdmlName + let tdmlDescription = defaultValues.tdmlConfig['description'] + ? defaultValues.tdmlConfig['description'] + : defaultValues.tdmlDescription + let tdmlPath = defaultValues.tdmlConfig['path'] + ? defaultValues.tdmlConfig['path'] + : defaultValues.tdmlPath + let tdmlNameDesVisOrHiddenStyle = + tdmlAction !== 'none' + ? 'margin-top: 10px; visibility: visible;' + : 'visibility: hidden' + let tdmlPathVisOrHiddenStyle = + tdmlAction === 'generate' + ? 'margin-top: 10px; visibility: visible;' + : 'visibility: hidden' + + tdmlActions.forEach((action) => { + if (action === tdmlAction) { + tdmlActionSelect += `<option selected value="${action}">${action}</option>` + } else { + tdmlActionSelect += `<option value="${action}">${action}</option>` + } + }) + return ` <!DOCTYPE html> <html lang="en"> @@ -466,6 +497,26 @@ class LaunchWizard { </label> </div> + <div id="tdmlActionDiv" class="setting-div"> + <p>TDML Action:</p> + <p class="setting-description">TDML Action (none | generate | append | execute)</p> + <select onChange="updateTDMLAction()" class="file-input" style="width: 200px;" id="tdmlAction"> + ${tdmlActionSelect} + </select> + + <p id="tdmlNameLabel" style="${tdmlNameDesVisOrHiddenStyle}" class="setting-description"> + TDML Name: <input class="setting-div" value="${tdmlName}" id="tdmlName"> + </p> + + <p id="tdmlDescriptionLabel" style="${tdmlNameDesVisOrHiddenStyle}" class="setting-description"> + TDML Description: <input class="setting-div" value="${tdmlDescription}" id="tdmlDescription"> + </p> + + <p id="tdmlPathLabel" style="${tdmlPathVisOrHiddenStyle}" class="file-input"> + TDML File Path: <input class="file-input" value="${tdmlPath}" id="tdmlPath"> + </p> + </div> + <div id="programDiv" class="setting-div"> <p>Program:</p> <p class="setting-description">Absolute path to the DFDL schema file.</p> diff --git a/src/utils.ts b/src/utils.ts index 5c5690d..dba985f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -119,10 +119,7 @@ export function getConfig( 'tdmlDescription', 'Generated by DFDL VSCode Extension' ), - path: defaultConf.get( - 'tdmlConfigPath', - '${workspaceFolder}/infoset.tdml' - ), + path: defaultConf.get('tdmlPath', '${workspaceFolder}/infoset.tdml'), }, stopOnEntry: stopOnEntry ? stopOnEntry
