diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-02 21:44:56 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-02 21:44:56 +0100 |
commit | 2f6ab77708ae104c854712285af19516287b6906 (patch) | |
tree | 7e86855582629a88f7002f01bbc67bf41b0513bf /editors/code/src | |
parent | 0035dafbfa563921e2cfe41f5592fc37bff92294 (diff) | |
parent | bc3db7c1ded0db2d3804b5ac3e5c35dd53350228 (diff) |
Merge #4710
4710: New runnables r=matklad a=matklad
bors d=@vsrs
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/debug.ts | 12 | ||||
-rw-r--r-- | editors/code/src/lsp_ext.ts | 17 | ||||
-rw-r--r-- | editors/code/src/run.ts | 21 |
3 files changed, 29 insertions, 21 deletions
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 1e421d407..a0c9b3ab2 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts | |||
@@ -114,8 +114,8 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v | |||
114 | } | 114 | } |
115 | 115 | ||
116 | async function getDebugExecutable(runnable: ra.Runnable): Promise<string> { | 116 | async function getDebugExecutable(runnable: ra.Runnable): Promise<string> { |
117 | const cargo = new Cargo(runnable.cwd || '.', debugOutput); | 117 | const cargo = new Cargo(runnable.args.workspaceRoot || '.', debugOutput); |
118 | const executable = await cargo.executableFromArgs(runnable.args); | 118 | const executable = await cargo.executableFromArgs(runnable.args.cargoArgs); |
119 | 119 | ||
120 | // if we are here, there were no compilation errors. | 120 | // if we are here, there were no compilation errors. |
121 | return executable; | 121 | return executable; |
@@ -127,8 +127,8 @@ function getLldbDebugConfig(runnable: ra.Runnable, executable: string, sourceFil | |||
127 | request: "launch", | 127 | request: "launch", |
128 | name: runnable.label, | 128 | name: runnable.label, |
129 | program: executable, | 129 | program: executable, |
130 | args: runnable.extraArgs, | 130 | args: runnable.args.executableArgs, |
131 | cwd: runnable.cwd, | 131 | cwd: runnable.args.workspaceRoot, |
132 | sourceMap: sourceFileMap, | 132 | sourceMap: sourceFileMap, |
133 | sourceLanguages: ["rust"] | 133 | sourceLanguages: ["rust"] |
134 | }; | 134 | }; |
@@ -140,8 +140,8 @@ function getCppvsDebugConfig(runnable: ra.Runnable, executable: string, sourceFi | |||
140 | request: "launch", | 140 | request: "launch", |
141 | name: runnable.label, | 141 | name: runnable.label, |
142 | program: executable, | 142 | program: executable, |
143 | args: runnable.extraArgs, | 143 | args: runnable.args.executableArgs, |
144 | cwd: runnable.cwd, | 144 | cwd: runnable.args.workspaceRoot, |
145 | sourceFileMap: sourceFileMap, | 145 | sourceFileMap: sourceFileMap, |
146 | }; | 146 | }; |
147 | } | 147 | } |
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index 3e0b60699..c51acfccb 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts | |||
@@ -46,18 +46,17 @@ export interface RunnablesParams { | |||
46 | position: lc.Position | null; | 46 | position: lc.Position | null; |
47 | } | 47 | } |
48 | 48 | ||
49 | export type RunnableKind = "cargo" | "rustc" | "rustup"; | ||
50 | |||
51 | export interface Runnable { | 49 | export interface Runnable { |
52 | range: lc.Range; | ||
53 | label: string; | 50 | label: string; |
54 | kind: RunnableKind; | 51 | location?: lc.LocationLink; |
55 | args: string[]; | 52 | kind: "cargo"; |
56 | extraArgs: string[]; | 53 | args: { |
57 | env: { [key: string]: string }; | 54 | workspaceRoot?: string; |
58 | cwd: string | null; | 55 | cargoArgs: string[]; |
56 | executableArgs: string[]; | ||
57 | }; | ||
59 | } | 58 | } |
60 | export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>("rust-analyzer/runnables"); | 59 | export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>("experimental/runnables"); |
61 | 60 | ||
62 | export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint; | 61 | export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint; |
63 | 62 | ||
diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts index 5fc4f8e41..5c790741f 100644 --- a/editors/code/src/run.ts +++ b/editors/code/src/run.ts | |||
@@ -103,18 +103,27 @@ interface CargoTaskDefinition extends vscode.TaskDefinition { | |||
103 | env?: { [key: string]: string }; | 103 | env?: { [key: string]: string }; |
104 | } | 104 | } |
105 | 105 | ||
106 | export function createTask(spec: ra.Runnable): vscode.Task { | 106 | export function createTask(runnable: ra.Runnable): vscode.Task { |
107 | const TASK_SOURCE = 'Rust'; | 107 | const TASK_SOURCE = 'Rust'; |
108 | |||
109 | let command; | ||
110 | switch (runnable.kind) { | ||
111 | case "cargo": command = toolchain.getPathForExecutable("cargo"); | ||
112 | } | ||
113 | const args = runnable.args.cargoArgs; | ||
114 | if (runnable.args.executableArgs.length > 0) { | ||
115 | args.push('--', ...runnable.args.executableArgs); | ||
116 | } | ||
108 | const definition: CargoTaskDefinition = { | 117 | const definition: CargoTaskDefinition = { |
109 | type: 'cargo', | 118 | type: 'cargo', |
110 | label: spec.label, | 119 | label: runnable.label, |
111 | command: toolchain.getPathForExecutable(spec.kind), | 120 | command, |
112 | args: spec.extraArgs ? [...spec.args, '--', ...spec.extraArgs] : spec.args, | 121 | args, |
113 | env: Object.assign({}, process.env, spec.env), | 122 | env: Object.assign({}, process.env as { [key: string]: string }, { "RUST_BACKTRACE": "short" }), |
114 | }; | 123 | }; |
115 | 124 | ||
116 | const execOption: vscode.ShellExecutionOptions = { | 125 | const execOption: vscode.ShellExecutionOptions = { |
117 | cwd: spec.cwd || '.', | 126 | cwd: runnable.args.workspaceRoot || '.', |
118 | env: definition.env, | 127 | env: definition.env, |
119 | }; | 128 | }; |
120 | const exec = new vscode.ShellExecution( | 129 | const exec = new vscode.ShellExecution( |