From 6cade3f6d8ad7bb5a11b1910689b25f709c12502 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 24 Aug 2018 13:41:25 +0300 Subject: Runnig tests somehow --- code/src/extension.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'code/src') diff --git a/code/src/extension.ts b/code/src/extension.ts index df2109f50..c25e8cb61 100644 --- a/code/src/extension.ts +++ b/code/src/extension.ts @@ -81,6 +81,11 @@ export function activate(context: vscode.ExtensionContext) { let e = await vscode.window.showTextDocument(doc) e.revealRange(range, vscode.TextEditorRevealType.InCenter) }) + console.log("ping") + registerCommand('libsyntax-rust.run', async (cmd: ProcessSpec) => { + let task = createTask(cmd) + await vscode.tasks.executeTask(task) + }) dispose(vscode.workspace.registerTextDocumentContentProvider( 'libsyntax-rust', @@ -265,3 +270,40 @@ interface Decoration { range: lc.Range, tag: string, } + +interface ProcessSpec { + bin: string; + args: string[]; + env: { [key: string]: string }; +} + +interface CargoTaskDefinition extends vscode.TaskDefinition { + type: 'cargo'; + label: string; + command: string; + args: Array; + env?: { [key: string]: string }; +} + + +function createTask(spec: ProcessSpec): vscode.Task { + const TASK_SOURCE = 'Rust'; + let definition: CargoTaskDefinition = { + type: 'cargo', + label: 'cargo', + command: spec.bin, + args: spec.args, + env: spec.env + } + + let execCmd = `${definition.command} ${definition.args.join(' ')}`; + let execOption: vscode.ShellExecutionOptions = { + cwd: '.', + env: definition.env, + }; + let exec = new vscode.ShellExecution(execCmd, execOption); + + let f = vscode.workspace.workspaceFolders[0] + let t = new vscode.Task(definition, f, definition.label, TASK_SOURCE, exec, ['$rustc']); + return t; +} -- cgit v1.2.3