prettier run

This commit is contained in:
Andrei Listochkin 2022-05-17 18:15:06 +01:00
parent 8e9f54f238
commit f247090558
24 changed files with 1169 additions and 808 deletions

View file

@ -1,12 +1,12 @@
import * as vscode from 'vscode';
import * as vscode from "vscode";
import * as toolchain from "./toolchain";
import { Config } from './config';
import { log } from './util';
import { Config } from "./config";
import { log } from "./util";
// This ends up as the `type` key in tasks.json. RLS also uses `cargo` and
// our configuration should be compatible with it so use the same key.
export const TASK_TYPE = 'cargo';
export const TASK_SOURCE = 'rust';
export const TASK_TYPE = "cargo";
export const TASK_SOURCE = "rust";
export interface CargoTaskDefinition extends vscode.TaskDefinition {
command?: string;
@ -30,17 +30,23 @@ class CargoTaskProvider implements vscode.TaskProvider {
// tasks.json - only tweaked.
const defs = [
{ command: 'build', group: vscode.TaskGroup.Build },
{ command: 'check', group: vscode.TaskGroup.Build },
{ command: 'test', group: vscode.TaskGroup.Test },
{ command: 'clean', group: vscode.TaskGroup.Clean },
{ command: 'run', group: undefined },
{ command: "build", group: vscode.TaskGroup.Build },
{ command: "check", group: vscode.TaskGroup.Build },
{ command: "test", group: vscode.TaskGroup.Test },
{ command: "clean", group: vscode.TaskGroup.Clean },
{ command: "run", group: undefined },
];
const tasks: vscode.Task[] = [];
for (const workspaceTarget of vscode.workspace.workspaceFolders || []) {
for (const def of defs) {
const vscodeTask = await buildCargoTask(workspaceTarget, { type: TASK_TYPE, command: def.command }, `cargo ${def.command}`, [def.command], this.config.cargoRunner);
const vscodeTask = await buildCargoTask(
workspaceTarget,
{ type: TASK_TYPE, command: def.command },
`cargo ${def.command}`,
[def.command],
this.config.cargoRunner
);
vscodeTask.group = def.group;
tasks.push(vscodeTask);
}
@ -58,7 +64,13 @@ class CargoTaskProvider implements vscode.TaskProvider {
if (definition.type === TASK_TYPE && definition.command) {
const args = [definition.command].concat(definition.args ?? []);
return await buildCargoTask(task.scope, definition, task.name, args, this.config.cargoRunner);
return await buildCargoTask(
task.scope,
definition,
task.name,
args,
this.config.cargoRunner
);
}
return undefined;
@ -73,7 +85,6 @@ export async function buildCargoTask(
customRunner?: string,
throwOnError: boolean = false
): Promise<vscode.Task> {
let exec: vscode.ProcessExecution | vscode.ShellExecution | undefined = undefined;
if (customRunner) {
@ -90,7 +101,6 @@ export async function buildCargoTask(
}
}
// fallback to default processing
} catch (e) {
if (throwOnError) throw `Cargo runner '${customRunner}' failed! ${e}`;
// fallback to default processing
@ -117,7 +127,7 @@ export async function buildCargoTask(
name,
TASK_SOURCE,
exec,
['$rustc']
["$rustc"]
);
}