Skip to content

Commit

Permalink
Merge branch 'main' into feature/validranges
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Aug 21, 2022
2 parents 524e60c + dc46939 commit 2c1410c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,16 @@ module.exports = class Parser {
if (parts[0] === `/IF`) {
// Directive IF
directIfScope += 1;
continue;
} else
if (parts[0] === `/ENDIF`) {
// Directive ENDIF
directIfScope -= 1;
continue;
} else
if (directIfScope > 0) {
// Ignore lines inside the IF scope.
continue;
}

switch (parts[0]) {
Expand Down Expand Up @@ -795,7 +801,7 @@ module.exports = class Parser {
}

if (currentItem && [`procedure`, `struct`].includes(currentItem.type)) {
if (currentItem.readParms) {
if (currentItem.readParms && parts.length > 0) {
if (parts[0].startsWith(`DCL`))
parts.slice(1);

Expand Down
38 changes: 38 additions & 0 deletions tests/suite/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,42 @@ module.exports = {
},
});
},

if1: async () => {
const lines = [
`**FREE`,
`// Function Return Param Definitions`,
`Dcl-Ds Prp00a Qualified`,
`/IF DEFINED(PRP00A_TEMPLATE_ALL_DS)`,
` Template`,
`/ENDIF`,
`;`,
` Address Char(220);`,
` Emp Packed(6);`,
` Empname Char(60);`,
` Phone_w_errm Char(95);`,
` Phone Char(15) Overlay(Phone_w_errm :1);`,
` Zipcode_w_errm Char(90);`,
` Zipcode Char(10) Overlay(Zipcode_w_errm :1);`,
`End-Ds;`,
``,
`Dcl-Ds Tmplt_EmpFmtAddress Qualified Template;`,
` Name Char(60);`,
` Addr1 Char(40);`,
` Addr2 Char(40);`,
` Addr3 Char(40);`,
` Addr4 Char(40);`,
`End-Ds;`,
].join(`\n`);

const parser = new Parser();
const cache = await parser.getDocs(uri, lines);

assert.strictEqual(cache.structs.length, 2);

const Prp00a = cache.find(`Prp00a`);
assert.strictEqual(Prp00a.subItems.length, 7);
assert.strictEqual(Prp00a.keyword[`QUALIFIED`], true);
assert.strictEqual(Prp00a.keyword[`TEMPLATE`], undefined);
}
}

0 comments on commit 2c1410c

Please sign in to comment.