mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Move run_single into runnables
This commit is contained in:
parent
72d48b08fb
commit
5bf739c824
@ -4,7 +4,6 @@ import * as joinLines from './join_lines';
|
|||||||
import * as matchingBrace from './matching_brace';
|
import * as matchingBrace from './matching_brace';
|
||||||
import * as onEnter from './on_enter';
|
import * as onEnter from './on_enter';
|
||||||
import * as parentModule from './parent_module';
|
import * as parentModule from './parent_module';
|
||||||
import * as runSingle from './run_single';
|
|
||||||
import * as runnables from './runnables';
|
import * as runnables from './runnables';
|
||||||
import * as syntaxTree from './syntaxTree';
|
import * as syntaxTree from './syntaxTree';
|
||||||
|
|
||||||
@ -14,7 +13,6 @@ export {
|
|||||||
joinLines,
|
joinLines,
|
||||||
matchingBrace,
|
matchingBrace,
|
||||||
parentModule,
|
parentModule,
|
||||||
runSingle,
|
|
||||||
runnables,
|
runnables,
|
||||||
syntaxTree,
|
syntaxTree,
|
||||||
onEnter
|
onEnter
|
||||||
|
@ -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);
|
|
||||||
}
|
|
@ -103,3 +103,19 @@ export async function handle() {
|
|||||||
return await vscode.tasks.executeTask(task);
|
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);
|
||||||
|
}
|
@ -56,7 +56,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
overrideCommand('type', commands.onEnter.handle);
|
overrideCommand('type', commands.onEnter.handle);
|
||||||
|
|
||||||
// Unlike the above this does not send requests to the language server
|
// 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
|
// Notifications are events triggered by the language server
|
||||||
const allNotifications: Iterable<
|
const allNotifications: Iterable<
|
||||||
|
Loading…
Reference in New Issue
Block a user