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/.vscode/launch.json | 3 +++ code/.vscode/tasks.json | 2 +- code/package.json | 26 ++++++++++++++++++++++++++ code/src/extension.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ code/tsconfig.json | 3 +-- 5 files changed, 73 insertions(+), 3 deletions(-) (limited to 'code') diff --git a/code/.vscode/launch.json b/code/.vscode/launch.json index 5e615ad4c..a5dd523df 100644 --- a/code/.vscode/launch.json +++ b/code/.vscode/launch.json @@ -10,6 +10,9 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": ["--extensionDevelopmentPath='./'"], + "env": { + "RUST_LOG": "m=trace" + }, "stopOnEntry": false, "sourceMaps": true, "outFiles": [ "./out/src/**/*.js" ], diff --git a/code/.vscode/tasks.json b/code/.vscode/tasks.json index 8e5a8b9ef..e1cfa4deb 100644 --- a/code/.vscode/tasks.json +++ b/code/.vscode/tasks.json @@ -21,7 +21,7 @@ "showOutput": "silent", // we run the custom script "compile" as defined in package.json - "args": ["run", "compile", "--loglevel", "silent"], + "args": ["run", "compile",], // The tsc compiler is started in watching mode "isBackground": true, diff --git a/code/package.json b/code/package.json index 20a6ceee7..1ed9dfabe 100644 --- a/code/package.json +++ b/code/package.json @@ -28,6 +28,28 @@ "onLanguage:rust" ], "contributes": { + "taskDefinitions": [ + { + "type": "cargo", + "required": [ + "command" + ], + "properties": { + "label": { + "type": "string" + }, + "command": { + "type": "string" + }, + "args": { + "type": "array" + }, + "env": { + "type": "object" + } + } + } + ], "commands": [ { "command": "libsyntax-rust.syntaxTree", @@ -48,6 +70,10 @@ { "command": "libsyntax-rust.joinLines", "title": "Rust Join Lines" + }, + { + "command": "libsyntax-rust.run", + "title": "Rust Run" } ], "keybindings": [ 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; +} diff --git a/code/tsconfig.json b/code/tsconfig.json index 11c3126e0..32a166d0f 100644 --- a/code/tsconfig.json +++ b/code/tsconfig.json @@ -7,6 +7,5 @@ "sourceMap": true, "rootDir": "." }, - "include": [ "src" ], - "exclude": [ "node_modules" ] + "include": [ "src/*.ts" ], } -- cgit v1.2.3