Skip to content

Commit

Permalink
Merge pull request #121 from halcyon-tech/fix/valid_ctdata
Browse files Browse the repository at this point in the history
Initial work for CTDATA fix
  • Loading branch information
worksofliam authored Sep 6, 2022
2 parents eed5652 + e4f95dc commit 847a9a1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/language/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ module.exports = class Linter {

switch (statement[0].type) {
case `format`:
if (statement[0].value.toUpperCase() === `**CTDATA`) {
if (lineNumber > 0 && statement[0].value.startsWith(`**`)) {
if (rules.NoCTDATA) {
errors.push({
range: new vscode.Range(
Expand Down
5 changes: 5 additions & 0 deletions src/language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ module.exports = class Parser {
lineIsFree = false;
lineNumber += 1;

// After compile time data, we're done
if (lineNumber > 0 && line.startsWith(`**`)) {
break;
}

if (isFullyFree === false && line.length > 6) {
const comment = line[6];
spec = line[5].toUpperCase();
Expand Down
56 changes: 56 additions & 0 deletions tests/suite/keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,62 @@ exports.ctdata1 = async () => {
assert.strictEqual(indentErrors.length, 0, `Expect length of 0`);
},

exports.ctdata2 = async () => {
const lines = [
`**FREE`,
`ctl-opt debug option(*nodebugio: *srcstmt);`,
`dcl-ds mything DIM(8) PERRCD(3) CTDATA;`,
`end-ds;`,
``,
`Dcl-s MyVariable2 Char(20);`,
``,
`myVariable2 = *blank;`,
``,
`If myVariable2 = *blank;`,
`MyVariable2 = 'Hello world';`,
`Endif;`,
`Return;`,
``,
`** ARC`,
`Toronto 12:15:00Winnipeg 13:23:00Calgary 15:44:00`,
`Sydney 17:24:30Edmonton 21:33:00Saskatoon 08:40:00`,
`Regina 12:33:00Vancouver 13:20:00`
].join(`\n`);

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

assert.strictEqual(cache.variables.length, 1);
assert.strictEqual(cache.structs.length, 1);
}

exports.ctdata3 = async () => {
const lines = [
` DCL-F QSYSPRT PRINTER(132) USAGE(*OUTPUT) OFLIND(*INOF);`,
` `,
` DCL-S OVR_FILE CHAR(21);`,
``,
` DCL-S TP CHAR(1) DIM(6) CTDATA PERRCD(1); // Deduction types`,
` DCL-S TD CHAR(20) DIM(6) ALT(TP);`,
``,
` *INLR = *ON;`,
` Return;`,
``,
`** TP and TD - Deduction types and descriptions`,
`BBenefit Benefit`,
`DDeferred CompDef Cmp`,
`CChild supportCh Sup`,
`GGarnishment Garnish`,
`SStatutory Statut.`,
`VVoluntary Volntry`,
].join(`\n`);

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

assert.strictEqual(cache.files.length, 1);
assert.strictEqual(cache.variables.length, 3);
}

exports.likeds1 = async () => {
const lines = [
Expand Down

0 comments on commit 847a9a1

Please sign in to comment.