From d472fd932b8292479547166ca83b2e2425f57ccc Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Wed, 13 Mar 2024 15:47:34 -0700 Subject: [PATCH] refactor: Rename CargoTask to RustTask in extension --- editors/code/src/run.ts | 10 +++++----- editors/code/src/tasks.ts | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts index fc3f1acce5..64a8a945f7 100644 --- a/editors/code/src/run.ts +++ b/editors/code/src/run.ts @@ -113,7 +113,7 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise const args = createArgs(runnable); - const definition: tasks.CargoTaskDefinition = { + const definition: tasks.RustTargetDefinition = { type: tasks.TASK_TYPE, command: args[0], // run, test, etc... args: args.slice(1), @@ -124,7 +124,7 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate() - const cargoTask = await tasks.buildCargoTask( + const task = await tasks.buildRustTask( target, definition, runnable.label, @@ -134,12 +134,12 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise true, ); - cargoTask.presentationOptions.clear = true; + task.presentationOptions.clear = true; // Sadly, this doesn't prevent focus stealing if the terminal is currently // hidden, and will become revealed due to task execution. - cargoTask.presentationOptions.focus = false; + task.presentationOptions.focus = false; - return cargoTask; + return task; } export function createArgs(runnable: ra.Runnable): string[] { diff --git a/editors/code/src/tasks.ts b/editors/code/src/tasks.ts index 1d5ab82aa0..7525dd0ff7 100644 --- a/editors/code/src/tasks.ts +++ b/editors/code/src/tasks.ts @@ -9,7 +9,7 @@ import { unwrapUndefinable } from "./undefinable"; export const TASK_TYPE = "cargo"; export const TASK_SOURCE = "rust"; -export interface CargoTaskDefinition extends vscode.TaskDefinition { +export interface RustTargetDefinition extends vscode.TaskDefinition { command?: string; args?: string[]; cwd?: string; @@ -17,7 +17,7 @@ export interface CargoTaskDefinition extends vscode.TaskDefinition { overrideCargo?: string; } -class CargoTaskProvider implements vscode.TaskProvider { +class RustTaskProvider implements vscode.TaskProvider { private readonly config: Config; constructor(config: Config) { @@ -42,7 +42,7 @@ class CargoTaskProvider implements vscode.TaskProvider { const tasks: vscode.Task[] = []; for (const workspaceTarget of vscode.workspace.workspaceFolders || []) { for (const def of defs) { - const vscodeTask = await buildCargoTask( + const vscodeTask = await buildRustTask( workspaceTarget, { type: TASK_TYPE, command: def.command }, `cargo ${def.command}`, @@ -63,11 +63,11 @@ class CargoTaskProvider implements vscode.TaskProvider { // we need to inform VSCode how to execute that command by creating // a ShellExecution for it. - const definition = task.definition as CargoTaskDefinition; + const definition = task.definition as RustTargetDefinition; if (definition.type === TASK_TYPE && definition.command) { const args = [definition.command].concat(definition.args ?? []); - return await buildCargoTask( + return await buildRustTask( task.scope, definition, task.name, @@ -81,9 +81,9 @@ class CargoTaskProvider implements vscode.TaskProvider { } } -export async function buildCargoTask( +export async function buildRustTask( scope: vscode.WorkspaceFolder | vscode.TaskScope | undefined, - definition: CargoTaskDefinition, + definition: RustTargetDefinition, name: string, args: string[], problemMatcher: string[], @@ -138,6 +138,6 @@ export async function buildCargoTask( } export function activateTaskProvider(config: Config): vscode.Disposable { - const provider = new CargoTaskProvider(config); + const provider = new RustTaskProvider(config); return vscode.tasks.registerTaskProvider(TASK_TYPE, provider); }