diff --git a/src/api/debug/server.ts b/src/api/debug/server.ts index 073e40789..1a4fe871d 100644 --- a/src/api/debug/server.ts +++ b/src/api/debug/server.ts @@ -21,6 +21,12 @@ interface DebugServiceDetails { java: string; } + +export type DebugJob = { + name: string + ports: number[] +} + let debugServiceDetails: DebugServiceDetails | undefined; export function resetDebugServiceDetails() { debugServiceDetails = undefined; @@ -39,7 +45,7 @@ export async function getDebugServiceDetails(): Promise { const detailFilePath = path.posix.join(directory, detailFile); const detailExists = await content.testStreamFile(detailFile, "r"); - if (detailExists) { + if (detailExists) { try { const fileContents = (await content.downloadStreamfileRaw(detailFilePath)).toString("utf-8"); debugServiceDetails = JSON.parse(fileContents); @@ -53,11 +59,6 @@ export async function getDebugServiceDetails(): Promise { return debugServiceDetails!; } -export type DebugJob = { - name: string - port: number -} - export async function startService(connection: IBMi) { const config = connection.config!; @@ -128,25 +129,29 @@ export async function stopService(connection: IBMi) { export async function getDebugServiceJob() { const content = instance.getContent(); if (content) { - return rowToDebugJob( - (await content.runSQL(`select job_name, local_port from qsys2.netstat_job_info j where local_port = ${content.ibmi.config?.debugPort || 8005} fetch first row only`)).at(0) - ); + const rows = await content.runSQL(`select distinct job_name, local_port from qsys2.netstat_job_info j where job_name = (select job_name from qsys2.netstat_job_info j where local_port = ${content.ibmi.config?.debugPort || 8005} fetch first row only)`); + if (rows && rows.length) { + return { + name: String(rows[0].JOB_NAME), + ports: rows.map(row => Number(row.LOCAL_PORT)).sort() + } as DebugJob; + } } } export async function getDebugServerJob() { const content = instance.getContent(); if (content) { - return rowToDebugJob( - (await content.runSQL(`select job_name, local_port from qsys2.netstat_job_info where cast(local_port_name as VarChar(14) CCSID 37) = 'is-debug-ile' fetch first row only`)).at(0) - ); + const [row] = await content.runSQL(`select job_name, local_port from qsys2.netstat_job_info where cast(local_port_name as VarChar(14) CCSID 37) = 'is-debug-ile' fetch first row only`); + if (row) { + return { + name: String(row.JOB_NAME), + ports: [Number(row.LOCAL_PORT)] + } as DebugJob; + } } } -function rowToDebugJob(row?: Tools.DB2Row): DebugJob | undefined { - return row?.JOB_NAME ? { name: String(row.JOB_NAME), port: Number(row.LOCAL_PORT) } : undefined; -} - /** * Gets a list of debug jobs stuck at MSGW in QSYSWRK */ diff --git a/src/instantiate.ts b/src/instantiate.ts index 91457d697..5487d6e7b 100644 --- a/src/instantiate.ts +++ b/src/instantiate.ts @@ -7,7 +7,7 @@ import { ConnectionConfiguration, DefaultOpenMode, GlobalConfiguration, onCodeFo import Instance from "./api/Instance"; import { Search } from "./api/Search"; import { Terminal } from './api/Terminal'; -import { isDebugEngineRunning } from './api/debug/server'; +import { getDebugServiceDetails, isDebugEngineRunning } from './api/debug/server'; import { refreshDiagnosticsFromServer } from './api/errors/diagnostics'; import { setupGitEventHandler } from './api/local/git'; import { QSysFS, getUriFromPath, parseFSOptions } from "./filesystems/qsys/QSysFs"; @@ -745,7 +745,7 @@ async function updateConnectedBar() { `[$(settings-gear) Settings](command:code-for-ibmi.showAdditionalSettings)`, `[$(file-binary) Actions](command:code-for-ibmi.showActionsMaintenance)`, `[$(terminal) Terminals](command:code-for-ibmi.launchTerminalPicker)`, - `[$(${debugRunning ? "bug" : "debug"}) Debugger (${debugRunning ? "on" : "off"})](command:code-for-ibmi.openDebugStatus)`, + `[$(${debugRunning ? "bug" : "debug"}) Debugger ${((await getDebugServiceDetails()).version)} (${debugRunning ? "on" : "off"})](command:code-for-ibmi.openDebugStatus)`, ].join(`\n\n---\n\n`), true); connectedBarItem.tooltip.isTrusted = true; } diff --git a/src/locale/ids/da.ts b/src/locale/ids/da.ts index f7668b97c..38fd9904c 100644 --- a/src/locale/ids/da.ts +++ b/src/locale/ids/da.ts @@ -51,6 +51,7 @@ export const da: Locale = { 'restart': 'Restart', 'stop': 'Stop', 'listening.on.port': 'Listening on port', + 'listening.on.ports': 'Listening on ports', 'overview': 'Overview', 'JOB_NAME_SHORT': 'Job name', 'JOB_USER': 'Job user', @@ -360,7 +361,7 @@ export const da: Locale = { 'actions.workAction.runOnProtected': 'Må afvikles på sikret/skrive-beskyttet', 'actions.workAction.runOnProtected.description': 'Tillader afvikling af denne aktion på sikrede eller skrive-beskyttede mål', //Debugger - 'debugger.status': 'Debugger Status', + 'debugger.status': 'Debugger {0} Status', 'loading.debugger.info': 'Loading debugger information...', 'debug.server': 'Debug Server', 'debug.service': 'Debug Service', diff --git a/src/locale/ids/en.ts b/src/locale/ids/en.ts index c388de659..23ee73a54 100644 --- a/src/locale/ids/en.ts +++ b/src/locale/ids/en.ts @@ -51,6 +51,7 @@ export const en: Locale = { 'restart': 'Restart', 'stop': 'Stop', 'listening.on.port': 'Listening on port', + 'listening.on.ports': 'Listening on ports', 'overview': 'Overview', 'JOB_NAME_SHORT': 'Job name', 'JOB_USER': 'Job user', @@ -360,7 +361,7 @@ export const en: Locale = { 'actions.workAction.runOnProtected': 'Run on protected/read only', 'actions.workAction.runOnProtected.description': 'Allows the execution of this Action on protected or read only targets', //Debugger - 'debugger.status': 'Debugger Status', + 'debugger.status': 'Debugger {0} Status', 'loading.debugger.info': 'Loading debugger information...', 'debug.server': 'Debug Server', 'debug.service': 'Debug Service', diff --git a/src/locale/ids/fr.ts b/src/locale/ids/fr.ts index c54aa7eaf..6342de859 100644 --- a/src/locale/ids/fr.ts +++ b/src/locale/ids/fr.ts @@ -51,6 +51,7 @@ export const fr: Locale = { 'restart': 'Redémarrer', 'stop': 'Arrêter', 'listening.on.port': 'Écoute sur le port', + 'listening.on.ports': 'Écoute sur les ports', 'overview': 'Aperçu', 'JOB_NAME_SHORT': 'Nom du job', 'JOB_USER': 'Utilisateur', @@ -360,7 +361,7 @@ export const fr: Locale = { 'actions.workAction.runOnProtected': 'Exécuter en mode protégé/lecture seule', 'actions.workAction.runOnProtected.description': `Autorise l'exécution de cette action sur des cibles protégés ou en lecture seule`, //Debugger - 'debugger.status': 'Status du débogueur', + 'debugger.status': 'Status du débogueur {0}', 'loading.debugger.info': 'Chargement du status du débogueur...', 'debug.server': 'Serveur de débogage', 'debug.service': 'Service de débogage', diff --git a/src/webviews/debugger/index.ts b/src/webviews/debugger/index.ts index c4d207620..8e9f2cdc2 100644 --- a/src/webviews/debugger/index.ts +++ b/src/webviews/debugger/index.ts @@ -5,7 +5,7 @@ import IBMiContent from "../../api/IBMiContent"; import { Tools } from "../../api/Tools"; import { isManaged } from "../../api/debug"; import { getLocalCertPath, getRemoteCertificateDirectory, localClientCertExists, readRemoteCertificate, remoteServerCertificateExists, setup } from "../../api/debug/certificates"; -import { DebugJob, getDebugServerJob, getDebugServiceJob, getServiceConfigurationFile, startServer, startService, stopServer, stopService } from "../../api/debug/server"; +import { DebugJob, getDebugServerJob, getDebugServiceDetails, getDebugServiceJob, getServiceConfigurationFile, startServer, startService, stopServer, stopService } from "../../api/debug/server"; import { instance } from "../../instantiate"; import { t } from "../../locale"; @@ -19,6 +19,7 @@ export async function openDebugStatusPanel() { const config = instance.getConfig() const connection = instance.getConnection(); if (content && config && connection) { + const debuggerDetails =await getDebugServiceDetails(); const debbuggerInfo = await vscode.window.withProgress({ title: t("loading.debugger.info"), location: vscode.ProgressLocation.Notification }, async () => { const serverJob = await getDebugServerJob(); const activeServerJob = serverJob ? await readActiveJob(content, serverJob) : undefined; @@ -66,7 +67,7 @@ export async function openDebugStatusPanel() {
  • ${t("status")}: ${debbuggerInfo.server ? t("online") : t("offline")}
  • ${debbuggerInfo.server ? /* html */ `
  • ${t("job")}: ${debbuggerInfo.server.job.name}
  • -
  • ${t("listening.on.port")}: ${debbuggerInfo.server.job.port}
  • ` +
  • ${t("listening.on.port")}: ${debbuggerInfo.server.job.ports[0]}
  • ` : "" } `) @@ -80,7 +81,7 @@ export async function openDebugStatusPanel() {
  • ${t("status")}: ${debbuggerInfo.service ? t("online") : t("offline")}
  • ${debbuggerInfo.service ? /* html */ `
  • ${t("job")}: ${debbuggerInfo.service.job.name}
  • -
  • ${t("listening.on.port")}: ${debbuggerInfo.service.job.port}
  • +
  • ${t("listening.on.ports")}: ${debbuggerInfo.service.job.ports.join(", ")}
  • ` : "" } @@ -135,7 +136,7 @@ export async function openDebugStatusPanel() { new CustomUI() .addComplexTabs(tabs) - .loadPage(t('debugger.status'), handleAction); + .loadPage(t('debugger.status', debuggerDetails.version), handleAction); } }