diff --git a/package.json b/package.json index 018b3d0..92f3a1a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ }, "main": "./out/src/frontend/extension", "activationEvents": [ - "onCommand:code-debug.examineMemoryLocation" + "onCommand:code-debug.examineMemoryLocation", + "onCommand:code-debug.getFileNameNoExt", + "onCommand:code-debug.getFileBasenameNoExt" ], "categories": [ "Debuggers" @@ -50,6 +52,10 @@ "asm" ] }, + "variables": { + "FileBasenameNoExt": "code-debug.getFileBasenameNoExt", + "FileNameNoExt": "code-debug.getFileNameNoExt" + }, "configurationAttributes": { "launch": { "required": [ @@ -216,6 +222,10 @@ "program": "./out/src/lldb.js", "runtime": "node", "label": "LLDB", + "variables": { + "FileBasenameNoExt": "code-debug.getFileBasenameNoExt", + "FileNameNoExt": "code-debug.getFileNameNoExt" + }, "enableBreakpointsFor": { "languageIds": [ "c", @@ -399,6 +409,10 @@ "program": "./out/src/mago.js", "runtime": "node", "label": "Mago-MI", + "variables": { + "FileBasenameNoExt": "code-debug.getFileBasenameNoExt", + "FileNameNoExt": "code-debug.getFileNameNoExt" + }, "enableBreakpointsFor": { "languageIds": [ "d" diff --git a/src/frontend/extension.ts b/src/frontend/extension.ts index c72696b..ca211a6 100644 --- a/src/frontend/extension.ts +++ b/src/frontend/extension.ts @@ -7,6 +7,26 @@ import * as os from "os"; export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider("debugmemory", new MemoryContentProvider())); context.subscriptions.push(vscode.commands.registerCommand("code-debug.examineMemoryLocation", examineMemory)); + context.subscriptions.push(vscode.commands.registerCommand("code-debug.getFileNameNoExt", () => { + if (!vscode.window.activeTextEditor || !vscode.window.activeTextEditor.document || !vscode.window.activeTextEditor.document.fileName) + { + vscode.window.showErrorMessage("No editor with valid file name active"); + return; + } + var fileName = vscode.window.activeTextEditor.document.fileName; + var ext = path.extname(fileName); + return fileName.substr(0, fileName.length - ext.length); + })); + context.subscriptions.push(vscode.commands.registerCommand("code-debug.getFileBasenameNoExt", () => { + if (!vscode.window.activeTextEditor || !vscode.window.activeTextEditor.document || !vscode.window.activeTextEditor.document.fileName) + { + vscode.window.showErrorMessage("No editor with valid file name active"); + return; + } + var fileName = path.basename(vscode.window.activeTextEditor.document.fileName); + var ext = path.extname(fileName); + return fileName.substr(0, fileName.length - ext.length); + })); } var memoryLocationRegex = /^0x[0-9a-f]+$/;