diff options
author | Aleksey Kladov <[email protected]> | 2018-08-24 11:41:25 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-24 11:41:25 +0100 |
commit | 6cade3f6d8ad7bb5a11b1910689b25f709c12502 (patch) | |
tree | 96aea3209cc310462c37708d5623fe1f1d667634 /code/src/extension.ts | |
parent | 89e56c364f3d0a9d5a12ae488185abc1ea69df4a (diff) |
Runnig tests somehow
Diffstat (limited to 'code/src/extension.ts')
-rw-r--r-- | code/src/extension.ts | 42 |
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 | |||
274 | interface ProcessSpec { | ||
275 | bin: string; | ||
276 | args: string[]; | ||
277 | env: { [key: string]: string }; | ||
278 | } | ||
279 | |||
280 | interface 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 | |||
289 | function 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 | } | ||