From 6b46362279012a8e57abe3ad141da7323b3c9f0c Mon Sep 17 00:00:00 2001 From: worksofliam Date: Thu, 4 Apr 2024 20:16:53 -0400 Subject: [PATCH 1/2] Fallback to system resolve if error file path not relative Signed-off-by: worksofliam --- src/api/errors/diagnostics.ts | 42 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/api/errors/diagnostics.ts b/src/api/errors/diagnostics.ts index 7282793b9..18aa856f6 100644 --- a/src/api/errors/diagnostics.ts +++ b/src/api/errors/diagnostics.ts @@ -105,7 +105,7 @@ export async function refreshDiagnosticsFromLocal(instance: Instance, evfeventIn } } -export async function handleEvfeventLines(lines: string[], instance: Instance, evfeventInfo: EvfEventInfo) { +export function handleEvfeventLines(lines: string[], instance: Instance, evfeventInfo: EvfEventInfo) { const connection = instance.getConnection(); const config = instance.getConfig(); const asp = evfeventInfo.asp ? `${evfeventInfo.asp}/` : ``; @@ -151,29 +151,35 @@ export async function handleEvfeventLines(lines: string[], instance: Instance, e const workspaceDeployPath = storage.getWorkspaceDeployPath(workspaceFolder); const deployPathIndex = file.toLowerCase().indexOf(workspaceDeployPath.toLowerCase()); - let relativeCompilePath = (deployPathIndex !== -1 ? file.substring(0, deployPathIndex) + file.substring(deployPathIndex + workspaceDeployPath.length) : file); - - if (connection) { - // Belive it or not, sometimes if the deploy directory is symlinked into as ASP, this can be a problem - const aspNames = Object.values(connection.aspInfo); - for (const aspName of aspNames) { - const aspRoot = `/${aspName}`; - if (relativeCompilePath.startsWith(aspRoot)) { - relativeCompilePath = relativeCompilePath.substring(aspRoot.length); - break; + let relativeCompilePath = (deployPathIndex !== -1 ? file.substring(0, deployPathIndex) + file.substring(deployPathIndex + workspaceDeployPath.length) : undefined); + + if (relativeCompilePath) { + + if (connection) { + // Belive it or not, sometimes if the deploy directory is symlinked into as ASP, this can be a problem + const aspNames = Object.values(connection.aspInfo); + for (const aspName of aspNames) { + const aspRoot = `/${aspName}`; + if (relativeCompilePath.startsWith(aspRoot)) { + relativeCompilePath = relativeCompilePath.substring(aspRoot.length); + break; + } } } - } - const diagnosticTargetFile = vscode.Uri.joinPath(workspaceFolder.uri, relativeCompilePath); + const diagnosticTargetFile = vscode.Uri.joinPath(workspaceFolder.uri, relativeCompilePath); - if (diagnosticTargetFile !== undefined) { - ileDiagnostics.set(diagnosticTargetFile, diagnostics); - } else { - vscode.window.showWarningMessage("Couldn't show compile error(s) in problem view."); + if (diagnosticTargetFile !== undefined) { + ileDiagnostics.set(diagnosticTargetFile, diagnostics); + } else { + vscode.window.showWarningMessage("Couldn't show compile error(s) in problem view."); + } + continue; } } - } else { + } + + { if (file.startsWith(`/`)) ileDiagnostics.set(Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `streamfile`, path: file })), diagnostics); else { From 8ac202dc831d9dfd378e0223fb70aa7b2b455cfa Mon Sep 17 00:00:00 2001 From: Seb Julliand Date: Wed, 17 Apr 2024 21:42:24 +0200 Subject: [PATCH 2/2] Cleanup Signed-off-by: Seb Julliand --- src/api/errors/diagnostics.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/api/errors/diagnostics.ts b/src/api/errors/diagnostics.ts index 18aa856f6..e669a46d6 100644 --- a/src/api/errors/diagnostics.ts +++ b/src/api/errors/diagnostics.ts @@ -1,11 +1,11 @@ import * as vscode from "vscode"; -import Instance from "../Instance"; -import { parseErrors } from "./parser"; import { FileError } from "../../typings"; -import { getEvfeventFiles } from "../local/actions"; import { GlobalConfiguration } from "../Configuration"; +import Instance from "../Instance"; import { Tools } from "../Tools"; +import { getEvfeventFiles } from "../local/actions"; +import { parseErrors } from "./parser"; const ileDiagnostics = vscode.languages.createDiagnosticCollection(`ILE`); @@ -55,7 +55,7 @@ export function clearDiagnostic(uri: vscode.Uri, changeRange: vscode.Range) { const existing = currentList.findIndex(d => d.range.contains(changeRange)); if (existing >= 0) { - const newList = [...currentList.slice(0, existing), ...currentList.slice(existing+1)]; + const newList = [...currentList.slice(0, existing), ...currentList.slice(existing + 1)]; ileDiagnostics.set(uri, newList); } @@ -150,11 +150,10 @@ export function handleEvfeventLines(lines: string[], instance: Instance, evfeven if (workspaceFolder && storage) { const workspaceDeployPath = storage.getWorkspaceDeployPath(workspaceFolder); const deployPathIndex = file.toLowerCase().indexOf(workspaceDeployPath.toLowerCase()); - + let relativeCompilePath = (deployPathIndex !== -1 ? file.substring(0, deployPathIndex) + file.substring(deployPathIndex + workspaceDeployPath.length) : undefined); if (relativeCompilePath) { - if (connection) { // Belive it or not, sometimes if the deploy directory is symlinked into as ASP, this can be a problem const aspNames = Object.values(connection.aspInfo); @@ -168,7 +167,6 @@ export function handleEvfeventLines(lines: string[], instance: Instance, evfeven } const diagnosticTargetFile = vscode.Uri.joinPath(workspaceFolder.uri, relativeCompilePath); - if (diagnosticTargetFile !== undefined) { ileDiagnostics.set(diagnosticTargetFile, diagnostics); } else { @@ -179,13 +177,12 @@ export function handleEvfeventLines(lines: string[], instance: Instance, evfeven } } - { - if (file.startsWith(`/`)) - ileDiagnostics.set(Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `streamfile`, path: file })), diagnostics); - else { - const memberUri = Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `member`, path: `/${asp}${file}${evfeventInfo.extension ? `.` + evfeventInfo.extension : ``}` })); - ileDiagnostics.set(memberUri, diagnostics); - } + if (file.startsWith(`/`)) { + ileDiagnostics.set(Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `streamfile`, path: file })), diagnostics); + } + else { + const memberUri = Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `member`, path: `/${asp}${file}${evfeventInfo.extension ? `.` + evfeventInfo.extension : ``}` })); + ileDiagnostics.set(memberUri, diagnostics); } } } else {