src/goDebugConfiguration.ts: show warning for dlv-dap with dlvLoadConfig

The debug adapter dlv-dap does not support setting loadConfig.
This shows the user a warning if dlvLoadConfig is set when
running with dlv-dap.

Updates golang/vscode-go#1462

Change-Id: Ica5682b2f2b34cf069b28ec710490d25a84cfa14
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/315149
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Polina Sokolova <polina@google.com>
diff --git a/docs/settings.md b/docs/settings.md
index cd432d2..e5f254a 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -144,7 +144,7 @@
 | --- | --- |
 | `apiVersion` | Delve Api Version to use. Default value is 2. <br/> Allowed Options: `1`, `2` <br/> Default: `2` |
 | `debugAdapter` | Select which debug adapter to use by default. This is also used for choosing which debug adapter to use when no launch.json is present and with codelenses. <br/> Allowed Options: `legacy`, `dlv-dap` <br/> Default: `"legacy"` |
-| `dlvLoadConfig` | LoadConfig describes to delve, how to load values from target's memory <br/> Default: ``` { <pre>"followPointers" :	true,<br/>"maxArrayValues" :	64,<br/>"maxStringLen" :	64,<br/>"maxStructFields" :	-1,<br/>"maxVariableRecurse" :	1,</pre>} ``` |
+| `dlvLoadConfig` | LoadConfig describes to delve, how to load values from target's memory. Ignored by 'dlv-dap'. <br/> Default: ``` { <pre>"followPointers" :	true,<br/>"maxArrayValues" :	64,<br/>"maxStringLen" :	64,<br/>"maxStructFields" :	-1,<br/>"maxVariableRecurse" :	1,</pre>} ``` |
 | `showGlobalVariables` | Boolean value to indicate whether global package variables should be shown in the variables pane or not. <br/> Default: `false` |
 
 Default:
diff --git a/package.json b/package.json
index 8f77d60..43bbed1 100644
--- a/package.json
+++ b/package.json
@@ -699,7 +699,7 @@
                     "default": -1
                   }
                 },
-                "description": "LoadConfig describes to delve, how to load values from target's memory",
+                "description": "LoadConfig describes to delve, how to load values from target's memory. Ignored by 'dlv-dap'",
                 "default": {
                   "followPointers": true,
                   "maxVariableRecurse": 1,
@@ -883,7 +883,7 @@
                     "default": -1
                   }
                 },
-                "description": "LoadConfig describes to delve, how to load values from target's memory",
+                "description": "LoadConfig describes to delve, how to load values from target's memory. Ignored by 'dlv-dap'.",
                 "default": {
                   "followPointers": true,
                   "maxVariableRecurse": 1,
@@ -1693,7 +1693,7 @@
                   "default": -1
                 }
               },
-              "description": "LoadConfig describes to delve, how to load values from target's memory",
+              "description": "LoadConfig describes to delve, how to load values from target's memory. Ignored by 'dlv-dap'.",
               "default": {
                 "followPointers": true,
                 "maxVariableRecurse": 1,
diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts
index 5d2cbaf..de7c0b1 100644
--- a/src/goDebugConfiguration.ts
+++ b/src/goDebugConfiguration.ts
@@ -143,6 +143,14 @@
 
 		const goConfig = getGoConfig(folder && folder.uri);
 		const dlvConfig = goConfig['delveConfig'];
+
+		// Figure out which debugAdapter is being used first, so we can use this to send warnings
+		// for properties that don't apply.
+		if (!debugConfiguration.hasOwnProperty('debugAdapter') && dlvConfig.hasOwnProperty('debugAdapter')) {
+			debugConfiguration['debugAdapter'] = dlvConfig['debugAdapter'];
+		}
+		const debugAdapter = debugConfiguration['debugAdapter'] === 'dlv-dap' ? 'dlv-dap' : 'dlv';
+
 		let useApiV1 = false;
 		if (debugConfiguration.hasOwnProperty('useApiV1')) {
 			useApiV1 = debugConfiguration['useApiV1'] === true;
@@ -155,6 +163,17 @@
 		if (!debugConfiguration.hasOwnProperty('apiVersion') && dlvConfig.hasOwnProperty('apiVersion')) {
 			debugConfiguration['apiVersion'] = dlvConfig['apiVersion'];
 		}
+		if (
+			debugAdapter === 'dlv-dap' &&
+			(debugConfiguration.hasOwnProperty('dlvLoadConfig') ||
+				goConfig.inspect('delveConfig.dlvLoadConfig').globalValue !== undefined ||
+				goConfig.inspect('delveConfig.dlvLoadConfig').workspaceValue !== undefined)
+		) {
+			this.showWarning(
+				'ignoreDebugDlvConfigWithDlvDapWarning',
+				"User specified 'dlvLoadConfig' setting will be ignored by debug adapter 'dlv-dap'."
+			);
+		}
 		if (!debugConfiguration.hasOwnProperty('dlvLoadConfig') && dlvConfig.hasOwnProperty('dlvLoadConfig')) {
 			debugConfiguration['dlvLoadConfig'] = dlvConfig['dlvLoadConfig'];
 		}
@@ -171,9 +190,6 @@
 			// expand 'cwd' folder path containing '~', which would cause dlv to fail
 			debugConfiguration['cwd'] = resolveHomeDir(debugConfiguration['cwd']);
 		}
-		if (!debugConfiguration.hasOwnProperty('debugAdapter') && dlvConfig.hasOwnProperty('debugAdapter')) {
-			debugConfiguration['debugAdapter'] = dlvConfig['debugAdapter'];
-		}
 
 		// Remove any '--gcflags' entries and show a warning
 		if (debugConfiguration['buildFlags']) {
@@ -197,7 +213,6 @@
 			}
 		}
 
-		const debugAdapter = debugConfiguration['debugAdapter'] === 'dlv-dap' ? 'dlv-dap' : 'dlv';
 		const dlvToolPath = getBinPath(debugAdapter);
 		if (!path.isAbsolute(dlvToolPath)) {
 			const tool = getTool(debugAdapter);