diff --git a/qutes-vscode/extension.js b/qutes-vscode/extension.js index 7b6e65b..9733108 100644 --- a/qutes-vscode/extension.js +++ b/qutes-vscode/extension.js @@ -1,59 +1,52 @@ const vscode = require('vscode'); +function runQutes(runs, params = []){ + let activeEditor = vscode.window.activeTextEditor; + if (!activeEditor || activeEditor.document.languageId !== 'qutes') { + return; // no active editor or the active file is not a Qutes file + } + + let filePath = activeEditor.document.uri.fsPath; + + // Define a debug configuration + let debugConfiguration = { + name: "Run Qutes File", + type: "debugpy", + request: "launch", + program: "src/qutes.py", + console: "integratedTerminal", + args: [params,"-image","-circuit","-iter",runs,filePath], + justMyCode: true + }; + + // Start debugging with the defined configuration + vscode.debug.startDebugging(undefined, debugConfiguration); +} + /** * @param {vscode.ExtensionContext} context */ function activate(context) { let runQutesFileCommand = vscode.commands.registerCommand('qutes.runQutesFile', function () { - let activeEditor = vscode.window.activeTextEditor; - if (!activeEditor || activeEditor.document.languageId !== 'qutes') { - return; // no active editor or the active file is not a Qutes file - } - - let filePath = activeEditor.document.uri.fsPath; - - // Define a debug configuration - let debugConfiguration = { - name: "Run Qutes File", - type: "debugpy", - request: "launch", - program: "src/qutes.py", - console: "integratedTerminal", - args: ["-image","-circuit","-iter","1",filePath], - justMyCode: true - - }; - - // Start debugging with the defined configuration - vscode.debug.startDebugging(undefined, debugConfiguration); + runQutes("1"); }); let runQutesFile100Command = vscode.commands.registerCommand('qutes.runQutesFile100', function () { - let activeEditor = vscode.window.activeTextEditor; - if (!activeEditor || activeEditor.document.languageId !== 'qutes') { - return; // no active editor or the active file is not a Qutes file - } - - let filePath = activeEditor.document.uri.fsPath; + runQutes("100"); + }); - // Define a debug configuration - let debugConfiguration = { - name: "Run Qutes File", - type: "debugpy", - request: "launch", - program: "src/qutes.py", - console: "integratedTerminal", - args: ["-image","-circuit","-iter","100",filePath], - justMyCode: true - - }; + let runQutesFileVerboseCommand = vscode.commands.registerCommand('qutes.runQutesFileVerbose', function () { + runQutes("1", ["--verbose"]); + }); - // Start debugging with the defined configuration - vscode.debug.startDebugging(undefined, debugConfiguration); + let runQutesFile100VerboseCommand = vscode.commands.registerCommand('qutes.runQutesFileVerbose100', function () { + runQutes("100", ["--verbose"]); }); context.subscriptions.push(runQutesFileCommand); context.subscriptions.push(runQutesFile100Command); + context.subscriptions.push(runQutesFileVerboseCommand); + context.subscriptions.push(runQutesFile100VerboseCommand); } function deactivate() {} diff --git a/qutes-vscode/package.json b/qutes-vscode/package.json index 6e23dba..2d31d2c 100644 --- a/qutes-vscode/package.json +++ b/qutes-vscode/package.json @@ -5,7 +5,7 @@ "author": "Gabriele Messina", "publisher": "GabrieleMessina", "license": "MIT", - "version": "1.1.1", + "version": "1.1.2", "engines": { "vscode": "^1.52.0" }, @@ -50,6 +50,14 @@ "command": "qutes.runQutesFile100", "title": "Run Qutes File 100 times", "icon": "$(run-all)" + }, + { + "command": "qutes.runQutesFileVerbose", + "title": "Run Qutes File with Verbose output" + }, + { + "command": "qutes.runQutesFileVerbose100", + "title": "Run Qutes File 100 times with Verbose output" } ], "menus": { @@ -63,14 +71,19 @@ "command": "qutes.runQutesFile100", "group": "navigation", "when": "resourceLangId == qutes" + }, + { + "command": "qutes.runQutesFileVerbose", + "group": "navigation", + "when": "resourceLangId == qutes" + }, + { + "command": "qutes.runQutesFileVerbose100", + "group": "navigation", + "when": "resourceLangId == qutes" } ], "editor/title": [ - { - "command": "qutes.runQutesFile", - "group": "navigation", - "when": "resourceLangId == qutes" - }, { "command": "qutes.runQutesFile100", "group": "navigation", diff --git a/qutes.code-workspace b/qutes.code-workspace index 04280d7..8b5d79b 100644 --- a/qutes.code-workspace +++ b/qutes.code-workspace @@ -46,51 +46,6 @@ "args": ["-image","-circuit","-iter","1","./specification/grammar/grammar_tests.qut"], "justMyCode": true }, - { - "name": "Qutes: Run Test example", - "type": "debugpy", - "request": "launch", - "program": "src/qutes.py", - "console": "integratedTerminal", - "args": ["-image","-circuit","-iter","100","./playground/examples/test.qut"], - "justMyCode": true - }, - { - "name": "Qutes: Run Superdense Coding example", - "type": "debugpy", - "request": "launch", - "program": "src/qutes.py", - "console": "integratedTerminal", - "args": ["-image","-circuit","-iter","100","./playground/examples/superdense_coding.qut"], - "justMyCode": true - }, - { - "name": "Qutes: Run Grover Search example", - "type": "debugpy", - "request": "launch", - "program": "src/qutes.py", - "console": "integratedTerminal", - "args": ["-image","-iter","1","./playground/examples/grover_search.qut"], - "justMyCode": true - }, - { - "name": "Qutes: Run Quantum Teleportation example [WIP]", - "type": "debugpy", - "request": "launch", - "program": "src/qutes.py", - "console": "integratedTerminal", - "args": ["-image","-circuit","-iter","1","./playground/examples/quantum_teleportation.qut"], - "justMyCode": true - }, - { - "name": "Qutes: Run Quantum key Distribution BB84 example", - "type": "debugpy", - "request": "launch", - "program": "src/qutes.py", - "console": "integratedTerminal", - "args": ["-image","-circuit","-iter","1","./playground/examples/quantum_key_distribution_bb84.qut"], - "justMyCode": true - }, ] } } \ No newline at end of file