Skip to content
Permalink
Browse files
Add debug option that uses configuration from last debug
Add debug option that uses configuration from last debug

- Rename function to remove typo

- Remove line added in merge
  • Loading branch information
michael-hoke authored and Shanedell committed Jul 18, 2022
1 parent f6713ed commit 5c38f0c7dad4429271aea896e1accaf4bb9266fa
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 21 deletions.
@@ -84,7 +84,8 @@
"onCommand:launch.config",
"onCommand:data.edit",
"onCommand:omega_edit.version",
"onCommand:toggle.experimental"
"onCommand:toggle.experimental",
"onCommand:extension.dfdl-debug.debugLastEditorContents"
],
"workspaceTrust": {
"request": "never"
@@ -139,6 +140,10 @@
{
"command": "extension.dfdl-debug.debugEditorContents",
"when": "resourceLangId == dfdl"
},
{
"command": "extension.dfdl-debug.debugLastEditorContents",
"when": "resourceLangId == dfdl"
}
],
"commandPalette": [
@@ -160,6 +165,10 @@
},
{
"command": "toggle.experimental"
},
{
"command": "extension.dfdl-debug.debugLastEditorContents",
"when": "resourceLangId == dfdl"
}
],
"debug/variables/context": [
@@ -184,6 +193,13 @@
"enablement": "!inDebugMode",
"icon": "$(play)"
},
{
"command": "extension.dfdl-debug.debugLastEditorContents",
"title": "Debug Last File",
"category": "Daffodil Debug",
"enablement": "!inDebugMode",
"icon": "$(debug-alt)"
},
{
"command": "extension.dfdl-debug.toggleFormatting",
"title": "Toggle between decimal and hex formatting",
@@ -19,13 +19,17 @@ import { getDebugger, getDataFileFromFolder } from '../daffodilDebugger'
import { FileAccessor } from './daffodilRuntime'
import * as fs from 'fs'
import * as infoset from '../infoset'
import { getConfig, setCurrentConfig } from '../utils'
import { getConfig, getCurrentConfig, setCurrentConfig } from '../utils'
import * as launchWizard from '../launchWizard/launchWizard'
import * as omegaEditClient from '../omega_edit/client'
import * as dfdlLang from '../language/dfdl'

// Function for setting up the commands for Run and Debug file
function createDebugRunFileConfigs(resource: vscode.Uri, runOrDebug: String) {
function createDebugRunFileConfigs(
resource: vscode.Uri,
runOrDebug: String,
runLast = false
) {
let targetResource = resource
let noDebug = runOrDebug === 'run' ? true : false

@@ -38,19 +42,27 @@ function createDebugRunFileConfigs(resource: vscode.Uri, runOrDebug: String) {
}-infoset.xml`
vscode.window.showInformationMessage(infosetFile)

vscode.debug.startDebugging(
undefined,
getConfig(
'Run File',
'launch',
'dfdl',
targetResource.fsPath,
false,
false,
{ type: 'file', path: '${workspaceFolder}/' + infosetFile }
),
{ noDebug: noDebug }
)
let currentConfig = getCurrentConfig()

if (runLast && currentConfig) {
vscode.debug.startDebugging(undefined, currentConfig, {
noDebug: noDebug,
})
} else {
vscode.debug.startDebugging(
undefined,
getConfig(
'Run File',
'launch',
'dfdl',
targetResource.fsPath,
false,
false,
{ type: 'file', path: '${workspaceFolder}/' + infosetFile }
),
{ noDebug: noDebug }
)
}

vscode.debug.onDidTerminateDebugSession(async () => {
if (!vscode.workspace.workspaceFolders) {
@@ -85,6 +97,12 @@ export function activateDaffodilDebug(
createDebugRunFileConfigs(resource, 'debug')
}
),
vscode.commands.registerCommand(
'extension.dfdl-debug.debugLastEditorContents',
(resource: vscode.Uri) => {
createDebugRunFileConfigs(resource, 'debug', true)
}
),
vscode.commands.registerCommand(
'extension.dfdl-debug.toggleFormatting',
(_) => {
@@ -21,12 +21,12 @@ import * as daf from './daffodil'
import * as fs from 'fs'
import { InfosetEvent } from './daffodil'
import { Uri } from 'vscode'
import { onDebugStartDisplay, getCurrentConfg } from './utils'
import { onDebugStartDisplay, getCurrentConfig } from './utils'

// Function to display an infomation message that the infoset file has been created
// If the user wishes to open the file then they may click the 'Open' button
async function openInfosetFilePrompt() {
let config = JSON.parse(JSON.stringify(getCurrentConfg()))
let config = JSON.parse(JSON.stringify(getCurrentConfig()))

if (config.infosetOutput.type === 'file') {
let rootPath = vscode.workspace.workspaceFolders
@@ -19,7 +19,7 @@ import * as vscode from 'vscode'

const defaultConf = vscode.workspace.getConfiguration()
// const
let currentConfig: vscode.ProviderResult<vscode.DebugConfiguration>
let currentConfig: vscode.DebugConfiguration

export const regexp = {
comma: new RegExp(',', 'g'),
@@ -29,7 +29,7 @@ export const regexp = {
}

// Function to retrieve to the current debug config
export function getCurrentConfg() {
export function getCurrentConfig() {
return currentConfig
}

@@ -49,7 +49,7 @@ export function runCommand(command: string) {
// Function for checking if config specifies if either the
// infoset, infoset diff or hex view needs to be opened
export async function onDebugStartDisplay(viewsToCheck: string[]) {
let config = JSON.parse(JSON.stringify(getCurrentConfg()))
let config = JSON.parse(JSON.stringify(getCurrentConfig()))

viewsToCheck.forEach(async (viewToCheck) => {
switch (viewToCheck) {

0 comments on commit 5c38f0c

Please sign in to comment.