Skip to content
Permalink
Browse files
Create popup notification when infoset is written. Closes #12
  • Loading branch information
Shanedell committed Dec 21, 2021
1 parent 7b272e3 commit 3553a65e74d24de11e779e5acd9680ae1e0a3a6e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 15 deletions.
@@ -19,7 +19,7 @@ import { getDebugger, getDataFileFromFolder } from '../daffodilDebugger'
import { FileAccessor } from './daffodilRuntime'
import * as fs from 'fs'
import * as infoset from '../infoset'
import { getConfig } from '../utils'
import { getConfig, setCurrentConfig } from '../utils'
import * as launchWizard from '../launchWizard/launchWizard'

// Function for setting up the commands for Run and Debug file
@@ -318,13 +318,15 @@ class DaffodilConfigurationProvider
) {
return getDataFileFromFolder(dataFolder).then((dataFile) => {
config.data = dataFile
setCurrentConfig(config)
return getDebugger(this.context, config).then((result) => {
return config
})
})
}

return getDebugger(this.context, config).then((result) => {
setCurrentConfig(config)
return config
})
}
@@ -21,7 +21,40 @@ import * as daf from './daffodil'
import * as fs from 'fs'
import { InfosetEvent } from './daffodil'
import { Uri } from 'vscode'
import { onDebugStartDisplay } from './utils'
import { onDebugStartDisplay, getCurrentConfg } 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()))

if (config.infosetOutput.type === 'file') {
let rootPath = vscode.workspace.workspaceFolders
? vscode.workspace.workspaceFolders[0].uri.fsPath
: vscode.Uri.parse('').fsPath
let path = config.infosetOutput.path.includes('${workspaceFolder}')
? config.infosetOutput.path.replace('${workspaceFolder}', rootPath)
: config.infosetOutput.path

const action = await vscode.window.showInformationMessage(
`Wrote infoset file to ${path}`,
'Open',
'Dismiss'
)

let uri = vscode.Uri.parse(path)

switch (action) {
case 'Open':
let xml = await vscode.workspace.openTextDocument(uri)
await vscode.window.showTextDocument(xml, {
preview: false,
viewColumn: vscode.ViewColumn.One,
})
break
}
}
}

export async function activate(ctx: vscode.ExtensionContext) {
let sid: string | undefined
@@ -34,8 +67,9 @@ export async function activate(ctx: vscode.ExtensionContext) {
})
)
ctx.subscriptions.push(
vscode.debug.onDidTerminateDebugSession((s) => {
vscode.debug.onDidTerminateDebugSession(async (s) => {
sid = undefined
await openInfosetFilePrompt()
})
)
ctx.subscriptions.push(
@@ -18,6 +18,18 @@
import * as vscode from 'vscode'

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

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

// Function to set the current debug config
export function setCurrentConfig(config) {
currentConfig = config
return currentConfig
}

// Function to run vscode command and catch the error to not cause other issues
export function runCommand(command: string) {
@@ -29,18 +41,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(
vscode.workspace
.getConfiguration(
'launch',
vscode.workspace.workspaceFolders
? vscode.workspace.workspaceFolders[0].uri
: vscode.Uri.parse('')
)
.get('configurations')
)
)[0]
let config = JSON.parse(JSON.stringify(getCurrentConfg()))

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

0 comments on commit 3553a65

Please sign in to comment.