mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Document CargoTaskDefinition and factor out converting TaskDefinition to Execution
This commit is contained in:
parent
e8d6a5ec0b
commit
a758e349bc
2 changed files with 63 additions and 49 deletions
|
@ -2,7 +2,6 @@ import * as vscode from "vscode";
|
|||
import type * as lc from "vscode-languageclient";
|
||||
import * as ra from "./lsp_ext";
|
||||
import * as tasks from "./tasks";
|
||||
import * as toolchain from "./toolchain";
|
||||
|
||||
import type { CtxInit } from "./ctx";
|
||||
import { makeDebugConfig } from "./debug";
|
||||
|
@ -112,22 +111,12 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise
|
|||
throw `Unexpected runnable kind: ${runnable.kind}`;
|
||||
}
|
||||
|
||||
let program: string;
|
||||
let args = createArgs(runnable);
|
||||
if (runnable.args.overrideCargo) {
|
||||
// Split on spaces to allow overrides like "wrapper cargo".
|
||||
const cargoParts = runnable.args.overrideCargo.split(" ");
|
||||
|
||||
program = unwrapUndefinable(cargoParts[0]);
|
||||
args = [...cargoParts.slice(1), ...args];
|
||||
} else {
|
||||
program = await toolchain.cargoPath();
|
||||
}
|
||||
const args = createArgs(runnable);
|
||||
|
||||
const definition: tasks.CargoTaskDefinition = {
|
||||
type: tasks.TASK_TYPE,
|
||||
program,
|
||||
args,
|
||||
command: unwrapUndefinable(args[0]), // run, test, etc...
|
||||
args: args.slice(1),
|
||||
cwd: runnable.args.workspaceRoot || ".",
|
||||
env: prepareEnv(runnable, config.runnablesExtraEnv),
|
||||
overrideCargo: runnable.args.overrideCargo,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue