Skip to content

Commit

Permalink
Merge pull request #1976 from codefori/fix/local_compile_with_qsys
Browse files Browse the repository at this point in the history
Fallback to system resolve if error file path not relative
  • Loading branch information
worksofliam authored Apr 18, 2024
2 parents 7948a84 + 8ac202d commit cc8940a
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions src/api/errors/diagnostics.ts
Original file line number Diff line number Diff line change
@@ -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`);

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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}/` : ``;
Expand Down Expand Up @@ -150,36 +150,39 @@ export async function handleEvfeventLines(lines: string[], instance: Instance, e
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) : 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);

if (diagnosticTargetFile !== undefined) {
ileDiagnostics.set(diagnosticTargetFile, diagnostics);
} else {
vscode.window.showWarningMessage("Couldn't show compile error(s) in problem view.");
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.");
}
continue;
}
}
} else {
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 {
Expand Down

0 comments on commit cc8940a

Please sign in to comment.