From 5bf739c824c25867811163e05f706ff3d20bd2e6 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Sat, 12 Jan 2019 13:54:08 -0500 Subject: Move run_single into runnables --- editors/code/src/commands/index.ts | 2 -- editors/code/src/commands/run_single.ts | 63 --------------------------------- editors/code/src/commands/runnables.ts | 16 +++++++++ editors/code/src/extension.ts | 2 +- 4 files changed, 17 insertions(+), 66 deletions(-) delete mode 100644 editors/code/src/commands/run_single.ts (limited to 'editors') diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index c8bb55591..33e2b34a2 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -4,7 +4,6 @@ import * as joinLines from './join_lines'; import * as matchingBrace from './matching_brace'; import * as onEnter from './on_enter'; import * as parentModule from './parent_module'; -import * as runSingle from './run_single'; import * as runnables from './runnables'; import * as syntaxTree from './syntaxTree'; @@ -14,7 +13,6 @@ export { joinLines, matchingBrace, parentModule, - runSingle, runnables, syntaxTree, onEnter diff --git a/editors/code/src/commands/run_single.ts b/editors/code/src/commands/run_single.ts deleted file mode 100644 index 855bcdb06..000000000 --- a/editors/code/src/commands/run_single.ts +++ /dev/null @@ -1,63 +0,0 @@ -import * as vscode from 'vscode'; -import * as lc from 'vscode-languageclient'; - -interface Runnable { - range: lc.Range; - label: string; - bin: string; - args: string[]; - env: { [index: string]: string }; -} - -interface CargoTaskDefinition extends vscode.TaskDefinition { - type: 'cargo'; - label: string; - command: string; - args: string[]; - env?: { [key: string]: string }; -} - -function createTask(spec: Runnable): vscode.Task { - const TASK_SOURCE = 'Rust'; - const definition: CargoTaskDefinition = { - type: 'cargo', - label: 'cargo', - command: spec.bin, - args: spec.args, - env: spec.env - }; - - const execOption: vscode.ShellExecutionOptions = { - cwd: '.', - env: definition.env - }; - const exec = new vscode.ShellExecution(definition.command, definition.args, execOption); - - const f = vscode.workspace.workspaceFolders![0]; - const t = new vscode.Task( - definition, - f, - definition.label, - TASK_SOURCE, - exec, - ['$rustc'] - ); - t.presentationOptions.clear = true - return t; -} - -export async function handle(runnable: Runnable) { - const editor = vscode.window.activeTextEditor; - if (editor == null || editor.document.languageId !== 'rust') { - return; - } - - const task = createTask(runnable); - task.group = vscode.TaskGroup.Build; - task.presentationOptions = { - reveal: vscode.TaskRevealKind.Always, - panel: vscode.TaskPanelKind.Dedicated, - }; - - return vscode.tasks.executeTask(task); -} \ No newline at end of file diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index be17c8944..f9a4e2fc9 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -103,3 +103,19 @@ export async function handle() { return await vscode.tasks.executeTask(task); } } + +export async function handleSingle(runnable: Runnable) { + const editor = vscode.window.activeTextEditor; + if (editor == null || editor.document.languageId !== 'rust') { + return; + } + + const task = createTask(runnable); + task.group = vscode.TaskGroup.Build; + task.presentationOptions = { + reveal: vscode.TaskRevealKind.Always, + panel: vscode.TaskPanelKind.Dedicated, + }; + + return vscode.tasks.executeTask(task); +} \ No newline at end of file diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index acbb1f734..9edfb13b5 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -56,7 +56,7 @@ export function activate(context: vscode.ExtensionContext) { overrideCommand('type', commands.onEnter.handle); // Unlike the above this does not send requests to the language server - registerCommand('ra-lsp.run-single', commands.runSingle.handle); + registerCommand('ra-lsp.run-single', commands.runnables.handleSingle); // Notifications are events triggered by the language server const allNotifications: Iterable< -- cgit v1.2.3