Skip to content

Commit f9b6ae9

Browse files
committed
Only shows debug version warning if the debugger is actually installed
Signed-off-by: Seb Julliand <[email protected]>
1 parent 61efc8c commit f9b6ae9

File tree

1 file changed

+47
-43
lines changed

1 file changed

+47
-43
lines changed

src/debug/index.ts

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import Instance from "../Instance";
44
import path from "path";
55
import * as vscode from 'vscode';
66

7-
import { instance } from "../instantiate";
8-
import { ObjectItem } from "../typings";
97
import { ILELibrarySettings } from "../api/CompileTools";
8+
import { getDebugServiceDetails, ORIGINAL_DEBUG_CONFIG_FILE, resetDebugServiceDetails } from "../api/configuration/DebugConfiguration";
9+
import IBMi from "../api/IBMi";
10+
import { getStoredPassword } from "../config/passwords";
1011
import { Env, getEnvConfig } from "../filesystems/local/env";
12+
import { instance } from "../instantiate";
13+
import { ObjectItem } from "../typings";
14+
import { VscodeTools } from "../ui/Tools";
1115
import * as certificates from "./certificates";
12-
import { DebugConfiguration, getDebugServiceDetails, ORIGINAL_DEBUG_CONFIG_FILE, resetDebugServiceDetails } from "../api/configuration/DebugConfiguration";
1316
import * as server from "./server";
14-
import { VscodeTools } from "../ui/Tools";
15-
import { getStoredPassword } from "../config/passwords";
16-
import IBMi from "../api/IBMi";
1717

1818
const debugExtensionId = `IBM.ibmidebug`;
1919

@@ -297,51 +297,55 @@ export async function initialize(context: ExtensionContext) {
297297
activateDebugExtension();
298298
const connection = instance.getConnection();
299299
if (connection) {
300-
if (await server.isDebugSupported(connection)) {
301-
vscode.commands.executeCommand(`setContext`, ptfContext, true);
300+
const debuggerInstalled = server.debugPTFInstalled(connection);
301+
const debugDetails = await getDebugServiceDetails(connection);
302+
if (debuggerInstalled) {
303+
if (debugDetails.semanticVersion().major >= server.MIN_DEBUG_VERSION) {
304+
vscode.commands.executeCommand(`setContext`, ptfContext, true);
302305

303-
//Enable debug related commands
304-
vscode.commands.executeCommand(`setContext`, debugContext, true);
306+
//Enable debug related commands
307+
vscode.commands.executeCommand(`setContext`, debugContext, true);
305308

306-
//Enable service entry points related commands
307-
vscode.commands.executeCommand(`setContext`, debugSEPContext, true);
309+
//Enable service entry points related commands
310+
vscode.commands.executeCommand(`setContext`, debugSEPContext, true);
308311

309-
const isDebugManaged = isManaged();
310-
vscode.commands.executeCommand(`setContext`, `code-for-ibmi:debugManaged`, isDebugManaged);
311-
if (!isDebugManaged) {
312-
if (validateIPv4address(connection.currentHost)) {
313-
vscode.window.showWarningMessage(`You are using an IPv4 address to connect to this system. This may cause issues with debugging. Please use a hostname in the Login Settings instead.`);
314-
}
312+
const isDebugManaged = isManaged();
313+
vscode.commands.executeCommand(`setContext`, `code-for-ibmi:debugManaged`, isDebugManaged);
315314

316-
// Set the debug environment variables early to be safe
317-
setCertEnv(true, connection);
315+
if (!isDebugManaged) {
316+
if (validateIPv4address(connection.currentHost)) {
317+
vscode.window.showWarningMessage(`You are using an IPv4 address to connect to this system. This may cause issues with debugging. Please use a hostname in the Login Settings instead.`);
318+
}
318319

319-
// Download the client certificate if it doesn't exist.
320-
certificates.checkClientCertificate(connection).catch(() => {
321-
vscode.commands.executeCommand(`code-for-ibmi.debug.setup.local`);
322-
});
320+
// Set the debug environment variables early to be safe
321+
setCertEnv(true, connection);
323322

324-
}
325-
} else {
326-
const version = (await getDebugServiceDetails(connection)).semanticVersion();
327-
const storage = instance.getStorage();
328-
if (storage && version.major < server.MIN_DEBUG_VERSION) {
329-
const debugUpdateMessageId = `debugUpdateRequired-${server.MIN_DEBUG_VERSION}`;
330-
const showMessage = !storage.hasMessageBeenShown(debugUpdateMessageId);
331-
332-
if (showMessage) {
333-
vscode.window.showWarningMessage(`Debug service version ${version} is below the minimum required version ${server.MIN_DEBUG_VERSION}. Please update the debug service PTF.`, `Open docs`, `Dismiss`).then(selected => {
334-
switch (selected) {
335-
case `Open docs`:
336-
env.openExternal(Uri.parse(`https://codefori.github.io/docs/developing/debug/`));
337-
break;
338-
case `Dismiss`:
339-
storage.markMessageAsShown(debugUpdateMessageId);
340-
break;
341-
}
323+
// Download the client certificate if it doesn't exist.
324+
certificates.checkClientCertificate(connection).catch(() => {
325+
vscode.commands.executeCommand(`code-for-ibmi.debug.setup.local`);
342326
});
343327
}
344328
}
329+
else {
330+
const storage = instance.getStorage();
331+
if (storage && debugDetails.semanticVersion().major < server.MIN_DEBUG_VERSION) {
332+
const debugUpdateMessageId = `debugUpdateRequired-${server.MIN_DEBUG_VERSION}`;
333+
const showMessage = !storage.hasMessageBeenShown(debugUpdateMessageId);
334+
335+
if (showMessage) {
336+
vscode.window.showWarningMessage(`Debug service version ${debugDetails.version} is below the minimum required version ${server.MIN_DEBUG_VERSION}.0.0. Please update the debug service PTF.`, `Open docs`, `Dismiss`).then(selected => {
337+
switch (selected) {
338+
case `Open docs`:
339+
env.openExternal(Uri.parse(`https://codefori.github.io/docs/developing/debug/`));
340+
break;
341+
case `Dismiss`:
342+
storage.markMessageAsShown(debugUpdateMessageId);
343+
break;
344+
}
345+
});
346+
}
347+
}
348+
}
345349
}
346350
}
347351
});
@@ -395,7 +399,7 @@ export async function startDebug(instance: Instance, options: DebugOptions) {
395399
secure = setCertEnv(secure, connection);
396400

397401
if (options.sep) {
398-
if (serviceDetails.version === `1.0.0`) {
402+
if (serviceDetails.semanticVersion().major < 2) {
399403
vscode.window.showErrorMessage(`The debug service on this system, version ${serviceDetails.version}, does not support service entry points.`);
400404
return;
401405
}

0 commit comments

Comments
 (0)