aboutsummaryrefslogtreecommitdiff
path: root/code/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-24 11:41:25 +0100
committerAleksey Kladov <[email protected]>2018-08-24 11:41:25 +0100
commit6cade3f6d8ad7bb5a11b1910689b25f709c12502 (patch)
tree96aea3209cc310462c37708d5623fe1f1d667634 /code/src
parent89e56c364f3d0a9d5a12ae488185abc1ea69df4a (diff)
Runnig tests somehow
Diffstat (limited to 'code/src')
-rw-r--r--code/src/extension.ts42
1 files changed, 42 insertions, 0 deletions
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) {
81 let e = await vscode.window.showTextDocument(doc) 81 let e = await vscode.window.showTextDocument(doc)
82 e.revealRange(range, vscode.TextEditorRevealType.InCenter) 82 e.revealRange(range, vscode.TextEditorRevealType.InCenter)
83 }) 83 })
84 console.log("ping")
85 registerCommand('libsyntax-rust.run', async (cmd: ProcessSpec) => {
86 let task = createTask(cmd)
87 await vscode.tasks.executeTask(task)
88 })
84 89
85 dispose(vscode.workspace.registerTextDocumentContentProvider( 90 dispose(vscode.workspace.registerTextDocumentContentProvider(
86 'libsyntax-rust', 91 'libsyntax-rust',
@@ -265,3 +270,40 @@ interface Decoration {
265 range: lc.Range, 270 range: lc.Range,
266 tag: string, 271 tag: string,
267} 272}
273
274interface ProcessSpec {
275 bin: string;
276 args: string[];
277 env: { [key: string]: string };
278}
279
280interface CargoTaskDefinition extends vscode.TaskDefinition {
281 type: 'cargo';
282 label: string;
283 command: string;
284 args: Array<string>;
285 env?: { [key: string]: string };
286}
287
288
289function createTask(spec: ProcessSpec): vscode.Task {
290 const TASK_SOURCE = 'Rust';
291 let definition: CargoTaskDefinition = {
292 type: 'cargo',
293 label: 'cargo',
294 command: spec.bin,
295 args: spec.args,
296 env: spec.env
297 }
298
299 let execCmd = `${definition.command} ${definition.args.join(' ')}`;
300 let execOption: vscode.ShellExecutionOptions = {
301 cwd: '.',
302 env: definition.env,
303 };
304 let exec = new vscode.ShellExecution(execCmd, execOption);
305
306 let f = vscode.workspace.workspaceFolders[0]
307 let t = new vscode.Task(definition, f, definition.label, TASK_SOURCE, exec, ['$rustc']);
308 return t;
309}