|
1 |
| -import { ExtensionContext, Uri } from "vscode"; |
| 1 | +import { env, ExtensionContext, Uri } from "vscode"; |
2 | 2 | import Instance from "../Instance";
|
3 | 3 |
|
4 | 4 | import path from "path";
|
5 | 5 | import * as vscode from 'vscode';
|
6 | 6 |
|
7 |
| -import { instance } from "../instantiate"; |
8 |
| -import { ObjectItem } from "../typings"; |
9 | 7 | 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"; |
10 | 11 | import { Env, getEnvConfig } from "../filesystems/local/env";
|
| 12 | +import { instance } from "../instantiate"; |
| 13 | +import { ObjectItem } from "../typings"; |
| 14 | +import { VscodeTools } from "../ui/Tools"; |
11 | 15 | import * as certificates from "./certificates";
|
12 |
| -import { DebugConfiguration, getDebugServiceDetails, ORIGINAL_DEBUG_CONFIG_FILE, resetDebugServiceDetails } from "../api/configuration/DebugConfiguration"; |
13 | 16 | import * as server from "./server";
|
14 |
| -import { VscodeTools } from "../ui/Tools"; |
15 |
| -import { getStoredPassword } from "../config/passwords"; |
16 |
| -import IBMi from "../api/IBMi"; |
17 | 17 |
|
18 | 18 | const debugExtensionId = `IBM.ibmidebug`;
|
19 | 19 |
|
@@ -296,29 +296,56 @@ export async function initialize(context: ExtensionContext) {
|
296 | 296 | async () => {
|
297 | 297 | activateDebugExtension();
|
298 | 298 | const connection = instance.getConnection();
|
299 |
| - if (connection && (await server.isDebugSupported(connection))) { |
300 |
| - vscode.commands.executeCommand(`setContext`, ptfContext, true); |
| 299 | + if (connection) { |
| 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); |
301 | 305 |
|
302 |
| - //Enable debug related commands |
303 |
| - vscode.commands.executeCommand(`setContext`, debugContext, true); |
| 306 | + //Enable debug related commands |
| 307 | + vscode.commands.executeCommand(`setContext`, debugContext, true); |
304 | 308 |
|
305 |
| - //Enable service entry points related commands |
306 |
| - vscode.commands.executeCommand(`setContext`, debugSEPContext, true); |
| 309 | + //Enable service entry points related commands |
| 310 | + vscode.commands.executeCommand(`setContext`, debugSEPContext, true); |
307 | 311 |
|
308 |
| - const isDebugManaged = isManaged(); |
309 |
| - vscode.commands.executeCommand(`setContext`, `code-for-ibmi:debugManaged`, isDebugManaged); |
310 |
| - if (!isDebugManaged) { |
311 |
| - if (validateIPv4address(connection.currentHost)) { |
312 |
| - 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.`); |
313 |
| - } |
| 312 | + const isDebugManaged = isManaged(); |
| 313 | + vscode.commands.executeCommand(`setContext`, `code-for-ibmi:debugManaged`, isDebugManaged); |
314 | 314 |
|
315 |
| - // Set the debug environment variables early to be safe |
316 |
| - 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 | + } |
317 | 319 |
|
318 |
| - // Download the client certificate if it doesn't exist. |
319 |
| - certificates.checkClientCertificate(connection).catch(() => { |
320 |
| - vscode.commands.executeCommand(`code-for-ibmi.debug.setup.local`); |
321 |
| - }); |
| 320 | + // Set the debug environment variables early to be safe |
| 321 | + setCertEnv(true, connection); |
| 322 | + |
| 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`); |
| 326 | + }); |
| 327 | + } |
| 328 | + } |
| 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 | + } |
322 | 349 | }
|
323 | 350 | }
|
324 | 351 | });
|
@@ -372,7 +399,7 @@ export async function startDebug(instance: Instance, options: DebugOptions) {
|
372 | 399 | secure = setCertEnv(secure, connection);
|
373 | 400 |
|
374 | 401 | if (options.sep) {
|
375 |
| - if (serviceDetails.version === `1.0.0`) { |
| 402 | + if (serviceDetails.semanticVersion().major < 2) { |
376 | 403 | vscode.window.showErrorMessage(`The debug service on this system, version ${serviceDetails.version}, does not support service entry points.`);
|
377 | 404 | return;
|
378 | 405 | }
|
|
0 commit comments