about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
authorVeetaha <gerzoh1@gmail.com>2020-02-25 00:56:38 +0200
committerVeetaha <gerzoh1@gmail.com>2020-02-25 00:56:38 +0200
commit8a8a4d08ef6c695cce04f5e306fad83cc9abddcd (patch)
tree7f6c79aaf8afbaa48f7048351d4b3dc82ab05fdb /editors/code/src
parentd6a96a90f417d48e6391d2233abf752988c04f1a (diff)
downloadrust-8a8a4d08ef6c695cce04f5e306fad83cc9abddcd.tar.gz
rust-8a8a4d08ef6c695cce04f5e306fad83cc9abddcd.zip
vscode: migrate runnables to rust-analyzer-api.ts
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/commands/runnables.ts29
1 files changed, 7 insertions, 22 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 7919997ce33..06b51346686 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -1,5 +1,6 @@
 import * as vscode from 'vscode';
 import * as lc from 'vscode-languageclient';
+import * as ra from '../rust-analyzer-api';
 
 import { Ctx, Cmd } from '../ctx';
 
@@ -14,16 +15,13 @@ export function run(ctx: Ctx): Cmd {
         const textDocument: lc.TextDocumentIdentifier = {
             uri: editor.document.uri.toString(),
         };
-        const params: RunnablesParams = {
+
+        const runnables = await client.sendRequest(ra.runnables, {
             textDocument,
             position: client.code2ProtocolConverter.asPosition(
                 editor.selection.active,
             ),
-        };
-        const runnables = await client.sendRequest<Runnable[]>(
-            'rust-analyzer/runnables',
-            params,
-        );
+        });
         const items: RunnableQuickPick[] = [];
         if (prevRunnable) {
             items.push(prevRunnable);
@@ -48,7 +46,7 @@ export function run(ctx: Ctx): Cmd {
 }
 
 export function runSingle(ctx: Ctx): Cmd {
-    return async (runnable: Runnable) => {
+    return async (runnable: ra.Runnable) => {
         const editor = ctx.activeRustEditor;
         if (!editor) return;
 
@@ -64,26 +62,13 @@ export function runSingle(ctx: Ctx): Cmd {
     };
 }
 
-interface RunnablesParams {
-    textDocument: lc.TextDocumentIdentifier;
-    position?: lc.Position;
-}
-
-interface Runnable {
-    label: string;
-    bin: string;
-    args: string[];
-    env: { [index: string]: string };
-    cwd?: string;
-}
-
 class RunnableQuickPick implements vscode.QuickPickItem {
     public label: string;
     public description?: string | undefined;
     public detail?: string | undefined;
     public picked?: boolean | undefined;
 
-    constructor(public runnable: Runnable) {
+    constructor(public runnable: ra.Runnable) {
         this.label = runnable.label;
     }
 }
@@ -96,7 +81,7 @@ interface CargoTaskDefinition extends vscode.TaskDefinition {
     env?: { [key: string]: string };
 }
 
-function createTask(spec: Runnable): vscode.Task {
+function createTask(spec: ra.Runnable): vscode.Task {
     const TASK_SOURCE = 'Rust';
     const definition: CargoTaskDefinition = {
         type: 'cargo',