Skip to content
Draft
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions cli/src/builders/bob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export class BobProject {

for (let target of targets.getTargets()) {
let dirname: string|undefined;
if (target.relativePath) {
dirname = path.dirname(target.relativePath);
if (target.source?.relativePath) {
dirname = path.dirname(target.source.relativePath);
} else if (target.type === `PGM`) {
// If there is no relative path, this might mean it's a multimodule program
const possibleModule = targets.getTarget({systemName: target.systemName, type: `MODULE`});
if (possibleModule) {
dirname = path.dirname(possibleModule.relativePath);
if (possibleModule && possibleModule.source) {
dirname = path.dirname(possibleModule.source.relativePath);
}
}

Expand Down Expand Up @@ -55,7 +55,7 @@ export class BobProject {

if (this.targets.binderRequired()) {
const servicePrograms = this.targets.getResolvedObjects(`SRVPGM`);
const relativePaths = servicePrograms.map(sp => path.dirname(sp.relativePath));
const relativePaths = servicePrograms.map(sp => path.dirname(sp.source.relativePath));

if (relativePaths.length === 1) {
// We know the rules
Expand Down Expand Up @@ -123,7 +123,7 @@ class RulesFile {

const existingLine = this.parsed.find(r => r.target === objName && r.isUserWritten !== true);

const lineContent = `${target.relativePath ? path.relative(this.subdir, target.relativePath) + ' ' : ``}${target.headers ? target.headers.join(` `) + ` ` : ``}${target.deps.filter(d => d.reference !== true).map(d => `${d.systemName}.${d.type}`).join(` `)}`.trimEnd();
const lineContent = `${target.source?.relativePath ? path.relative(this.subdir, target.source.relativePath) : ``} ${target.headers ? target.headers.join(` `) + ` ` : ``}${target.deps.filter(d => d.reference !== true).map(d => `${d.systemName}.${d.type}`).join(` `)}`.trim();

if (existingLine) {
existingLine.ogLine = `${objName}: ${lineContent}`;
Expand Down
10 changes: 5 additions & 5 deletions cli/src/builders/imd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export class ImpactMarkdown {
if (this.relativePaths.length > 0) {
lines.push(`## Impact Analysis`, ``);

const possibleObjects = this.relativePaths.map(r => this.targets.getResolvedObject(path.join(this.cwd, r))).filter(x => x && x.relativePath);
const possibleObjects = this.relativePaths.map(r => this.targets.getResolvedObject(path.join(this.cwd, r))).filter(x => x && x.source);

lines.push(
`Touched objects: `, ``,
...possibleObjects.map(ileObject => `* ${TypeEmoji[ileObject.type] || `❔`} \`${ileObject.systemName}.${ileObject.type}\`: \`${ileObject.relativePath}\``),
...possibleObjects.map(ileObject => `* ${TypeEmoji[ileObject.type] || `❔`} \`${ileObject.systemName}.${ileObject.type}\`: \`${ileObject.source.relativePath}\``),
``,
`---`,
``
Expand Down Expand Up @@ -141,7 +141,7 @@ export class ImpactMarkdown {
function lookupObject(ileObject: ILEObject) {
let resultLines: string[] = [];

resultLines.push(`${''.padEnd(currentTree.length, `\t`)}* ${TypeEmoji[ileObject.type] || `❔`} \`${ileObject.systemName}.${ileObject.type}\` (${ileObject.relativePath ? `\`${ileObject.relativePath}\`` : `no source`})`);
resultLines.push(`${''.padEnd(currentTree.length, `\t`)}* ${TypeEmoji[ileObject.type] || `❔`} \`${ileObject.systemName}.${ileObject.type}\` (${ileObject.source ? `\`${ileObject.source.relativePath}\`` : `no source`})`);

currentTree.push(ileObject);

Expand Down Expand Up @@ -180,15 +180,15 @@ export class ImpactMarkdown {

this.targets.getResolvedObjects().forEach(ileObject => {

let logs = this.targets.logger.getLogsFor(ileObject.relativePath) || [];
let logs = this.targets.logger.getLogsFor(ileObject.source?.relativePath) || [];
let parents = this.targets.getTargets().filter(t => t.deps.some(d => d.systemName === ileObject.systemName && d.type === ileObject.type));
let children = this.targets.getTarget(ileObject)?.deps || [];

lines.push(`| ` + [
TypeEmoji[ileObject.type] || `❔`,
ileObject.systemName,
ileObject.type,
`\`${ileObject.relativePath}\``,
`\`${ileObject.source?.relativePath}\``,
ImpactMarkdown.createLogExpand(logs),
ImpactMarkdown.createObjectExpand(parents),
ImpactMarkdown.createObjectExpand(children)
Expand Down
38 changes: 19 additions & 19 deletions cli/src/builders/make/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export class MakeProject {
};

const addStep = (ileObject: ILEObject) => {
let data = ileObject.relativePath ? this.settings.getCompileDataForSource(ileObject.relativePath) : this.settings.getCompileDataForType(ileObject.type);
let data = ileObject.source?.relativePath ? this.settings.getCompileDataForSource(ileObject.source.relativePath) : this.settings.getCompileDataForType(ileObject.type);
const customAttributes = this.getObjectAttributes(data, ileObject);

if (ileObject.relativePath) {
const possibleAction = this.projectActions.getActionForPath(ileObject.relativePath);
if (ileObject.source?.relativePath) {
const possibleAction = this.projectActions.getActionForPath(ileObject.source.relativePath);
if (possibleAction) {
const clData = fromCl(possibleAction.command);
// If there is an action for this object, we want to apply the action's parameters
Expand Down Expand Up @@ -102,7 +102,7 @@ export class MakeProject {
steps.push(
{
object: {name: ileObject.systemName, type: ileObject.type},
command: MakeProject.resolveCommand(`CPYFRMSTMF FROMSTMF('${asPosix(ileObject.relativePath)}') TOMBR('/QSYS.LIB/&CURLIB.LIB/${qsysTempName}.FILE/${data.parameters[`srcmbr`]}.MBR') MBROPT(*REPLACE)`, ileObject, commandOptions)
command: MakeProject.resolveCommand(`CPYFRMSTMF FROMSTMF('${asPosix(ileObject.source.relativePath)}') TOMBR('/QSYS.LIB/&CURLIB.LIB/${qsysTempName}.FILE/${data.parameters[`srcmbr`]}.MBR') MBROPT(*REPLACE)`, ileObject, commandOptions)
}
);
}
Expand All @@ -111,15 +111,15 @@ export class MakeProject {

steps.push({
object: {name: ileObject.systemName, type: ileObject.type},
relativePath: ileObject.relativePath,
relativePath: ileObject.source?.relativePath,
command
});

if (data.postCommands?.length > 0) {
for (const postCommand of data.postCommands) {
steps.push({
object: {name: ileObject.systemName, type: ileObject.type},
relativePath: ileObject.relativePath,
relativePath: ileObject.source?.relativePath,
command: MakeProject.resolveCommand(MakeProject.stripSystem(postCommand), ileObject, commandOptions)
});
}
Expand Down Expand Up @@ -150,9 +150,9 @@ export class MakeProject {
public getObjectAttributes(compileData: CompileData, ileObject: ILEObject): CommandParameters {
let customAttributes = this.settings.objectAttributes[`${ileObject.systemName}.${ileObject.type}`] || {};

if (ileObject.relativePath) {
if (ileObject.source) {
// We need to take in the current folders .ibmi.json file for any specific values
const folder = path.dirname(ileObject.relativePath);
const folder = ileObject.source && ileObject.source.relativePath ? path.dirname(ileObject.source.relativePath) : undefined;
const folderSettings = this.folderSettings[folder];
if (folderSettings) {
// If there is a tgtccsid, we only want to apply it to commands
Expand Down Expand Up @@ -280,8 +280,8 @@ export class MakeProject {

for (const ileObject of objects) {
if (ileObject.reference) continue;
if (ileObject.relativePath) {
const sourcePath = path.join(this.cwd, ileObject.relativePath);
if (ileObject.source) {
const sourcePath = path.join(this.cwd, ileObject.source.relativePath);
const exists = existsSync(sourcePath); // Is this even needed? We already have relativePath??

if (exists) {
Expand All @@ -293,13 +293,13 @@ export class MakeProject {
const customAttributes = this.settings.objectAttributes[`${ileObject.systemName}.${ileObject.type}`];

lines.push(
`$(PREPATH)/${ileObject.systemName}.${data.becomes}: ${asPosix(ileObject.relativePath)}`,
`$(PREPATH)/${ileObject.systemName}.${data.becomes}: ${asPosix(ileObject.source.relativePath)}`,
...(commands.map(l => `\t-system -q "${toCl(l, customAttributes)}"`)),
``,
);

} catch (e) {
console.log(`Failed to parse '${ileObject.relativePath}'`);
console.log(`Failed to parse '${ileObject.source.relativePath}'`);
process.exit();
}
}
Expand All @@ -319,8 +319,8 @@ export class MakeProject {
const possibleTarget: ILEObjectTarget = this.targets.getTarget(ileObject) || (ileObject as ILEObjectTarget);
const customAttributes = this.getObjectAttributes(data, possibleTarget);

if (ileObject.relativePath) {
const possibleAction = this.projectActions.getActionForPath(ileObject.relativePath);
if (ileObject.source?.relativePath) {
const possibleAction = this.projectActions.getActionForPath(ileObject.source.relativePath);
if (possibleAction) {
const clData = fromCl(possibleAction.command);
// If there is an action for this object, we want to apply the action's parameters
Expand Down Expand Up @@ -399,12 +399,12 @@ export class MakeProject {
const objectKey = `${ileObject.systemName}.${ileObject.type}`;

lines.push(
`$(PREPATH)/${objectKey}: ${asPosix(ileObject.relativePath)}`,
`$(PREPATH)/${objectKey}: ${asPosix(ileObject.source.relativePath)}`,
...(qsysTempName && data.member ?
[
// TODO: consider CCSID when creating the source file
`\t-system -qi "CRTSRCPF FILE(${data.parameters[`srcfile`]}) RCDLEN(112) CCSID(${sourceFileCcsid})"`,
`\tsystem "CPYFRMSTMF FROMSTMF('${asPosix(ileObject.relativePath)}') TOMBR('$(PREPATH)/${qsysTempName}.FILE/${data.parameters[`srcmbr`]}.MBR') MBROPT(*REPLACE)"`
`\tsystem "CPYFRMSTMF FROMSTMF('${asPosix(ileObject.source.relativePath)}') TOMBR('$(PREPATH)/${qsysTempName}.FILE/${data.parameters[`srcmbr`]}.MBR') MBROPT(*REPLACE)"`
] : []),
...(data.preCommands ? data.preCommands.map(cmd => `\t${MakeProject.resolveCommand(cmd, ileObject)}`) : []),
...(data.command ?
Expand Down Expand Up @@ -446,7 +446,7 @@ export class MakeProject {

command = command.replace(new RegExp(`\\*CURLIB`, `g`), libraryValue);
command = command.replace(new RegExp(`\\$\\*`, `g`), ileObject.systemName);
command = command.replace(new RegExp(`\\$<`, `g`), asPosix(ileObject.relativePath));
command = command.replace(new RegExp(`\\$<`, `g`), asPosix(ileObject.source.relativePath));
command = command.replace(new RegExp(`\\$\\(SRCPF\\)`, `g`), qsysTempName);

// Additionally, we have to support Actions variables
Expand All @@ -456,9 +456,9 @@ export class MakeProject {
command = simpleReplace(command, `&LIBLS`, ``);
command = simpleReplace(command, `&BRANCHLIB`, libraryValue);

const pathDetail = path.parse(ileObject.relativePath || ``);
const pathDetail = path.parse(ileObject.source?.relativePath || ``);

command = simpleReplace(command, `&RELATIVEPATH`, asPosix(ileObject.relativePath));
command = simpleReplace(command, `&RELATIVEPATH`, asPosix(ileObject.source?.relativePath));
command = simpleReplace(command, `&BASENAME`, pathDetail.base);
command = simpleReplace(command, `{filename}`, pathDetail.base);
command = simpleReplace(command, `&NAME`, getTrueBasename(pathDetail.name));
Expand Down
2 changes: 1 addition & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ async function listDeps(cwd: string, targets: Targets, query: string) {
let currentTree: ILEObject[] = [];

function lookupObject(ileObject: ILEObject) {
console.log(`${''.padEnd(currentTree.length, `\t`)}${ileObject.systemName}.${ileObject.type} (${ileObject.relativePath || `no source`})`);
console.log(`${''.padEnd(currentTree.length, `\t`)}${ileObject.systemName}.${ileObject.type} (${ileObject.source ? ileObject.source.relativePath : `no source`})`);

currentTree.push(ileObject);

Expand Down
59 changes: 59 additions & 0 deletions cli/src/languages/clle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Module, Subroutine, Variable, File, Statement } from "vscode-clle/language";
import { SourceSymbol, SymbolReferences } from "../targets";

export function collectClReferences(relativePath: string, doc: Module): SourceSymbol[] {
const symbols: SourceSymbol[] = [];

const defs = doc.getDefinitions();

const getRefs = (def: Variable|Subroutine): SymbolReferences => {
const refs = doc.getReferences(def);

const result: SymbolReferences = {relativePath: []};

for (const ref of refs) {
result[relativePath].push(ref);
}

return result;
}

for (const def of defs) {
let newSymbol: SourceSymbol|undefined;
if (def instanceof Variable && def.name) {
newSymbol = {
name: def.name.value,
type: String(def.dataType), // RTODO: what is this?
relativePath,
references: getRefs(def)
}
}

else if (def instanceof File && def.file) {
newSymbol = {
name: def.file.name,
type: `table`, //RTODO: is table correct?
relativePath,
references: {}, // File's don't have refs, but children do
external: def.file.name
}

// RTODO: get children of file
}

else if (def instanceof Subroutine && def.name) {
newSymbol = {
name: def.name.value,
type: `subroutine`,
relativePath,
references: getRefs(def)
}
}

if (newSymbol) {
symbols.push(newSymbol);
}
}

return symbols;
}
Loading
Loading