mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
prettier run
This commit is contained in:
parent
8e9f54f238
commit
f247090558
24 changed files with 1169 additions and 808 deletions
|
@ -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"]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue