Merge remote-tracking branch 'upstream/master' into compute-lazy-assits

# Conflicts:
#	crates/rust-analyzer/src/to_proto.rs
This commit is contained in:
Mikhail Rakhmanov 2020-06-02 23:22:45 +02:00
commit cb482e6351
15 changed files with 546 additions and 343 deletions

View file

@ -114,8 +114,8 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
}
async function getDebugExecutable(runnable: ra.Runnable): Promise<string> {
const cargo = new Cargo(runnable.cwd || '.', debugOutput);
const executable = await cargo.executableFromArgs(runnable.args);
const cargo = new Cargo(runnable.args.workspaceRoot || '.', debugOutput);
const executable = await cargo.executableFromArgs(runnable.args.cargoArgs);
// if we are here, there were no compilation errors.
return executable;
@ -127,8 +127,8 @@ function getLldbDebugConfig(runnable: ra.Runnable, executable: string, sourceFil
request: "launch",
name: runnable.label,
program: executable,
args: runnable.extraArgs,
cwd: runnable.cwd,
args: runnable.args.executableArgs,
cwd: runnable.args.workspaceRoot,
sourceMap: sourceFileMap,
sourceLanguages: ["rust"]
};
@ -140,8 +140,8 @@ function getCppvsDebugConfig(runnable: ra.Runnable, executable: string, sourceFi
request: "launch",
name: runnable.label,
program: executable,
args: runnable.extraArgs,
cwd: runnable.cwd,
args: runnable.args.executableArgs,
cwd: runnable.args.workspaceRoot,
sourceFileMap: sourceFileMap,
};
}

View file

@ -53,18 +53,17 @@ export interface RunnablesParams {
position: lc.Position | null;
}
export type RunnableKind = "cargo" | "rustc" | "rustup";
export interface Runnable {
range: lc.Range;
label: string;
kind: RunnableKind;
args: string[];
extraArgs: string[];
env: { [key: string]: string };
cwd: string | null;
location?: lc.LocationLink;
kind: "cargo";
args: {
workspaceRoot?: string;
cargoArgs: string[];
executableArgs: string[];
};
}
export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>("rust-analyzer/runnables");
export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>("experimental/runnables");
export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint;

View file

@ -103,18 +103,27 @@ interface CargoTaskDefinition extends vscode.TaskDefinition {
env?: { [key: string]: string };
}
export function createTask(spec: ra.Runnable): vscode.Task {
export function createTask(runnable: ra.Runnable): vscode.Task {
const TASK_SOURCE = 'Rust';
let command;
switch (runnable.kind) {
case "cargo": command = toolchain.getPathForExecutable("cargo");
}
const args = runnable.args.cargoArgs;
if (runnable.args.executableArgs.length > 0) {
args.push('--', ...runnable.args.executableArgs);
}
const definition: CargoTaskDefinition = {
type: 'cargo',
label: spec.label,
command: toolchain.getPathForExecutable(spec.kind),
args: spec.extraArgs ? [...spec.args, '--', ...spec.extraArgs] : spec.args,
env: Object.assign({}, process.env, spec.env),
label: runnable.label,
command,
args,
env: Object.assign({}, process.env as { [key: string]: string }, { "RUST_BACKTRACE": "short" }),
};
const execOption: vscode.ShellExecutionOptions = {
cwd: spec.cwd || '.',
cwd: runnable.args.workspaceRoot || '.',
env: definition.env,
};
const exec = new vscode.ShellExecution(