Skip to content

Commit 8d0bd24

Browse files
committed
src/goTools.ts: add dlv-dap to the configured tools
dlv-dap needs to appear in the list of missing tools in order for the user get the prompt to install. Additionally, if they already have dlv-dap installed, we do want dlv-dap to appear as a tool to update, since we are building from master. If the user has declined to install, do not attempt to prompt, because it will do nothing. Instead, continue with the debugging session without attempting to install so the error will show up later. Updates #794 Change-Id: If5922c950fde621d4c666e06bcc149413674ed9d Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/303235 Trust: Suzy Mueller <[email protected]> Run-TryBot: Suzy Mueller <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
1 parent 8b97b4b commit 8d0bd24

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

src/goDebugConfiguration.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import path = require('path');
1111
import vscode = require('vscode');
1212
import { getGoConfig } from './config';
1313
import { toolExecutionEnvironment } from './goEnv';
14-
import { promptForMissingTool, promptForUpdatingTool, shouldUpdateTool } from './goInstallTools';
14+
import { declinedToolInstall, promptForMissingTool, promptForUpdatingTool, shouldUpdateTool } from './goInstallTools';
1515
import { packagePathToGoModPathMap } from './goModules';
16-
import { getToolAtVersion } from './goTools';
16+
import { getTool, getToolAtVersion } from './goTools';
1717
import { pickProcess, pickProcessByName } from './pickProcess';
1818
import { getFromGlobalState, updateGlobalState } from './stateUtils';
1919
import { getBinPath, resolvePath } from './util';
@@ -233,8 +233,15 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
233233
const debugAdapter = debugConfiguration['debugAdapter'] === 'dlv-dap' ? 'dlv-dap' : 'dlv';
234234
const dlvToolPath = getBinPath(debugAdapter);
235235
if (!path.isAbsolute(dlvToolPath)) {
236-
await promptForMissingTool(debugAdapter);
237-
return;
236+
const tool = getTool(debugAdapter);
237+
238+
// If user has not already declined to install this tool,
239+
// prompt for it. Otherwise continue and have the lack of
240+
// dlv binary be caught later.
241+
if (!declinedToolInstall(debugAdapter)) {
242+
await promptForMissingTool(debugAdapter);
243+
return;
244+
}
238245
}
239246
debugConfiguration['dlvToolPath'] = dlvToolPath;
240247

src/goInstallTools.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,18 @@ export async function installTool(
304304
return result;
305305
}
306306

307+
export function declinedToolInstall(toolName: string) {
308+
const tool = getTool(toolName);
309+
310+
// If user has declined to install this tool, don't prompt for it.
311+
return !!containsTool(declinedInstalls, tool)
312+
}
313+
307314
export async function promptForMissingTool(toolName: string) {
308315
const tool = getTool(toolName);
309316

310317
// If user has declined to install this tool, don't prompt for it.
311-
if (containsTool(declinedInstalls, tool)) {
318+
if (declinedToolInstall(toolName)) {
312319
return;
313320
}
314321

@@ -338,7 +345,9 @@ export async function promptForMissingTool(toolName: string) {
338345
const installOptions = ['Install'];
339346
let missing = await getMissingTools(goVersion);
340347
if (!containsTool(missing, tool)) {
341-
return;
348+
// If this function has been called, we want to display the prompt whether
349+
// it appears in missing or not.
350+
missing.push(tool);
342351
}
343352
missing = missing.filter((x) => x === tool || tool.isImportant);
344353
if (missing.length > 1) {
@@ -558,6 +567,17 @@ function getMissingTools(goVersion: GoVersion): Promise<Tool[]> {
558567
(tool) =>
559568
new Promise<Tool>((resolve, reject) => {
560569
const toolPath = getBinPath(tool.name);
570+
if (tool.name === 'dlv-dap') {
571+
// Check if user already has dlv-dap binary.
572+
// If so, it's likely the user may be interested in updating the tool,
573+
// so we should mark it as important and return as a missing tool.
574+
if (path.isAbsolute(toolPath)) {
575+
tool.isImportant = true;
576+
resolve(tool);
577+
return;
578+
}
579+
tool.isImportant = false;
580+
}
561581
resolve(path.isAbsolute(toolPath) ? null : tool);
562582
})
563583
)

src/goTools.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export function getConfiguredTools(
158158
// families are 64-bit, so just try to install it and hope for the best.
159159
if (process.arch.match(/^(arm64|mips|mipsel|ppc64|s390|s390x|x64)$/)) {
160160
maybeAddTool('dlv');
161+
maybeAddTool('dlv-dap');
161162
}
162163

163164
// gocode-gomod needed in go 1.11 & higher

0 commit comments

Comments
 (0)