Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions cli/src/targets/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { infoOut } from '../cli';
import { infoOut, warningOut } from '../cli';
import Document from "vscode-db2i/src/language/sql/document";
import { ObjectRef, StatementType } from 'vscode-db2i/src/language/sql/types';
import { Logger } from '../logger';
Expand All @@ -16,6 +16,14 @@ const DEFAULT_BINDER_TARGET: ILEObject = { systemName: `$(APP_BNDDIR)`, type: `B

const TextRegex = /\%TEXT.*(?=\n|\*)/gm

export interface ParserError {
filePath: string;
content: string;
ileObject: ILEObject;
}

export type ParserErrorCallback = (error: ParserError) => void;

export interface ILEObject {
systemName: string;
longName?: string;
Expand Down Expand Up @@ -85,6 +93,7 @@ export class Targets {

private actionSuggestions: TargetSuggestions = {};

private parserErrorCallback: ParserErrorCallback | undefined;
public logger: Logger;

constructor(private cwd: string, private fs: ReadFileSystem) {
Expand All @@ -95,6 +104,10 @@ export class Targets {
return ignoredObjects;
}

public setParserErrorCallback(callback: ParserErrorCallback) {
this.parserErrorCallback = callback;
}

public getCwd() {
return this.cwd;
}
Expand Down Expand Up @@ -397,8 +410,6 @@ export class Targets {
this.logger.flush(relative);
}

const ext = pathDetail.ext.substring(1).toLowerCase();

try {
const content = await this.fs.readFile(filePath);

Expand Down Expand Up @@ -427,13 +438,21 @@ export class Targets {
type: `warning`
});

console.log(relative);
console.log(e);
if (this.parserErrorCallback) {
this.parserErrorCallback({
filePath,
content: e.content,
ileObject: { systemName: pathDetail.name, type: this.getObjectType(relative, pathDetail.ext) }
});

} else {
warningOut(`Failed to parse file ${filePath}!`);
warningOut(`Error: ${e.message}`);
warningOut(`Create a GitHub issue if this persists.`);
}

success = false;
}

infoOut(``);
} else {
success = false;
}
Expand Down
Loading