diff --git a/src/commands/actions.ts b/src/commands/actions.ts index ccf53608b..98956850c 100644 --- a/src/commands/actions.ts +++ b/src/commands/actions.ts @@ -169,7 +169,7 @@ export function registerActionsCommands(instance: Instance): Disposable[] { const [library, object] = inputPath.split(`/`); if (library && object) { const nameDetail = path.parse(object); - refreshDiagnosticsFromServer(instance, { library, object: nameDetail.name, extension: (nameDetail.ext.length > 1 ? nameDetail.ext.substring(1) : undefined), workspace: options.workspace }, options.keepDiagnostics); + refreshDiagnosticsFromServer(instance, [{ library, object: nameDetail.name, extension: (nameDetail.ext.length > 1 ? nameDetail.ext.substring(1) : undefined), workspace: options.workspace }], options.keepDiagnostics); } } }), diff --git a/src/ui/actions.ts b/src/ui/actions.ts index 6f51aa8a9..2b586952a 100644 --- a/src/ui/actions.ts +++ b/src/ui/actions.ts @@ -34,7 +34,7 @@ export type ActionTarget = { } const actionUsed: Map = new Map; -const PARM_REGEX = /(PNLGRP|OBJ|PGM|MODULE)\((?.+?)\)/; +const PARM_REGEX = /(PNLGRP|OBJ|PGM|MODULE|FILE|MENU)\((?.+?)\)/; export function registerActionTools(context: vscode.ExtensionContext) { context.subscriptions.push( @@ -170,6 +170,7 @@ export async function runAction(instance: Instance, uris: vscode.Uri | vscode.Ur extension: target.extension, workspace: fromWorkspace }; + const evfeventInfos: EvfEventInfo[] = []; let processedPath = ""; switch (chosenAction.type) { @@ -382,12 +383,26 @@ export async function runAction(instance: Instance, uris: vscode.Uri | vscode.Ur fromWorkspace && chosenAction.postDownload && (chosenAction.postDownload.includes(`.evfevent`) || chosenAction.postDownload.includes(`.evfevent/`)); - const possibleObject = getObjectFromCommand(commandResult.command); - if (isIleCommand && possibleObject) { - Object.assign(evfeventInfo, possibleObject); + const possibleObjects = getObjectsFromJoblog(commandResult.stderr) || getObjectFromCommand(commandResult.command); + if (isIleCommand && possibleObjects) { + evfeventInfos.length = 0; + if (Array.isArray(possibleObjects)) { + for(const o of possibleObjects) { + evfeventInfos.push({ + library: o.library || evfeventInfo.library, + object: o.object, + extension: evfeventInfo.extension, + asp: evfeventInfo.asp + }) + }; + } else { + evfeventInfo.library = possibleObjects.library ? possibleObjects.library : evfeventInfo.library; + evfeventInfo.object = possibleObjects.object; + evfeventInfos.push(evfeventInfo); + } } - actionName = (isIleCommand && possibleObject ? `${chosenAction.name} for ${evfeventInfo.library}/${evfeventInfo.object}` : actionName); + actionName = (isIleCommand && possibleObjects ? `${chosenAction.name} for ${evfeventInfo.library}/${evfeventInfo.object}` : actionName); successful = (commandResult.code === 0 || commandResult.code === null); writeEmitter.fire(CompileTools.NEWLINE); @@ -398,8 +413,8 @@ export async function runAction(instance: Instance, uris: vscode.Uri | vscode.Ur } else if (evfeventInfo.object && evfeventInfo.library) { if (chosenAction.command.includes(`*EVENTF`)) { - writeEmitter.fire(`Fetching errors for ${evfeventInfo.library}/${evfeventInfo.object}.` + CompileTools.NEWLINE); - await refreshDiagnosticsFromServer(instance, evfeventInfo); + writeEmitter.fire(`Fetching errors for ` + (evfeventInfos.length > 1 ? `multiple objects` : `${evfeventInfo.library}/${evfeventInfo.object}.`) + CompileTools.NEWLINE); + await refreshDiagnosticsFromServer(instance, evfeventInfos); problemsFetched = true; } else if (chosenAction.command.trimStart().toUpperCase().startsWith(`CRT`)) { writeEmitter.fire(`*EVENTF not found in command string. Not fetching errors for ${evfeventInfo.library}/${evfeventInfo.object}.` + CompileTools.NEWLINE); @@ -630,6 +645,34 @@ export async function getAllAvailableActions(targets: ActionTarget[], scheme: st return availableActions; } +function getObjectsFromJoblog(stderr: string): CommandObject[] | undefined { + const objects: CommandObject[] = []; + + // Filter lines with EVFEVENT info from server. + const joblogLines = stderr.split(`\n`).filter(line => line.match(/: EVFEVENT:/i)); + + for(const joblogLine of joblogLines) { + const evfevent = joblogLine.match(/: EVFEVENT:(.*)/i) || ''; + if (evfevent.length) { + const object = evfevent[1].trim().split(/[,\|/]/); + if (object) { + if (object.length >= 2) { + objects.push({ + library: object[0].trim(), + object: object[1].trim() + }); + } else { + objects.push({ + object: object[0].trim() + }); + } + } + } + } + + return objects.length > 0 ? objects : undefined; +} + function getObjectFromCommand(baseCommand?: string): CommandObject | undefined { if (baseCommand) { const regex = PARM_REGEX.exec(baseCommand.toUpperCase()); diff --git a/src/ui/diagnostics.ts b/src/ui/diagnostics.ts index a348c2398..59bb2cb4b 100644 --- a/src/ui/diagnostics.ts +++ b/src/ui/diagnostics.ts @@ -57,20 +57,22 @@ export function clearDiagnostic(uri: vscode.Uri, changeRange: vscode.Range) { } } -export async function refreshDiagnosticsFromServer(instance: Instance, evfeventInfo: EvfEventInfo, keepDiagnostics?: boolean) { +export async function refreshDiagnosticsFromServer(instance: Instance, evfeventInfo: EvfEventInfo[], keepDiagnostics?: boolean) { const connection = instance.getConnection(); if (connection) { const content = connection.getContent(); - const tableData = await content.getTable(evfeventInfo.library, `EVFEVENT`, evfeventInfo.object); - const lines = tableData.map(row => String(row.EVFEVENT)); if (IBMi.connectionManager.get(`clearErrorsBeforeBuild`) && !keepDiagnostics) { // Clear all errors if the user has this setting enabled clearDiagnostics(); } - handleEvfeventLines(lines, instance, evfeventInfo); + evfeventInfo.forEach(async e => { + const tableData = await content.getTable(e.library, `EVFEVENT`, e.object); + const lines = tableData.map(row => String(row.EVFEVENT)); + handleEvfeventLines(lines, instance, e); + }); } else { throw new Error('Please connect to an IBM i'); } @@ -153,7 +155,7 @@ export function handleEvfeventLines(lines: string[], instance: Instance, evfeven if (connection) { // Belive it or not, sometimes if the deploy directory is symlinked into as ASP, this can be a problem const aspNames = connection.getAllIAsps().map(asp => asp.name); - + for (const aspName of aspNames) { const aspRoot = `/${aspName}`; if (relativeCompilePath.startsWith(aspRoot)) {