aboutsummaryrefslogtreecommitdiff
path: root/code
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
parent89e56c364f3d0a9d5a12ae488185abc1ea69df4a (diff)
Runnig tests somehow
Diffstat (limited to 'code')
-rw-r--r--code/.vscode/launch.json3
-rw-r--r--code/.vscode/tasks.json2
-rw-r--r--code/package.json26
-rw-r--r--code/src/extension.ts42
-rw-r--r--code/tsconfig.json3
5 files changed, 73 insertions, 3 deletions
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 @@
10 "request": "launch", 10 "request": "launch",
11 "runtimeExecutable": "${execPath}", 11 "runtimeExecutable": "${execPath}",
12 "args": ["--extensionDevelopmentPath='./'"], 12 "args": ["--extensionDevelopmentPath='./'"],
13 "env": {
14 "RUST_LOG": "m=trace"
15 },
13 "stopOnEntry": false, 16 "stopOnEntry": false,
14 "sourceMaps": true, 17 "sourceMaps": true,
15 "outFiles": [ "./out/src/**/*.js" ], 18 "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 @@
21 "showOutput": "silent", 21 "showOutput": "silent",
22 22
23 // we run the custom script "compile" as defined in package.json 23 // we run the custom script "compile" as defined in package.json
24 "args": ["run", "compile", "--loglevel", "silent"], 24 "args": ["run", "compile",],
25 25
26 // The tsc compiler is started in watching mode 26 // The tsc compiler is started in watching mode
27 "isBackground": true, 27 "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 @@
28 "onLanguage:rust" 28 "onLanguage:rust"
29 ], 29 ],
30 "contributes": { 30 "contributes": {
31 "taskDefinitions": [
32 {
33 "type": "cargo",
34 "required": [
35 "command"
36 ],
37 "properties": {
38 "label": {
39 "type": "string"
40 },
41 "command": {
42 "type": "string"
43 },
44 "args": {
45 "type": "array"
46 },
47 "env": {
48 "type": "object"
49 }
50 }
51 }
52 ],
31 "commands": [ 53 "commands": [
32 { 54 {
33 "command": "libsyntax-rust.syntaxTree", 55 "command": "libsyntax-rust.syntaxTree",
@@ -48,6 +70,10 @@
48 { 70 {
49 "command": "libsyntax-rust.joinLines", 71 "command": "libsyntax-rust.joinLines",
50 "title": "Rust Join Lines" 72 "title": "Rust Join Lines"
73 },
74 {
75 "command": "libsyntax-rust.run",
76 "title": "Rust Run"
51 } 77 }
52 ], 78 ],
53 "keybindings": [ 79 "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) {
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}
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 @@
7 "sourceMap": true, 7 "sourceMap": true,
8 "rootDir": "." 8 "rootDir": "."
9 }, 9 },
10 "include": [ "src" ], 10 "include": [ "src/*.ts" ],
11 "exclude": [ "node_modules" ]
12} 11}