diff --git a/src/language/linter.js b/src/language/linter.js index 5c47d909..69fdb377 100644 --- a/src/language/linter.js +++ b/src/language/linter.js @@ -125,14 +125,13 @@ module.exports = class Linter { /** @type {{value: string, definition?: string, list: {range: vscode.Range, offset: {position: number, length: number}}[]}[]} */ const stringLiterals = []; - for (const currentLine of lines) { + for (lineNumber = 0; lineNumber < lines.length; lineNumber++) { + const currentLine = lines[lineNumber]; currentIndent = currentLine.search(/\S/); let line = currentLine.trimEnd(); let upperLine = line.trim().toUpperCase(); - lineNumber += 1; - isLineComment = line.trimStart().startsWith(`//`); if (currentIndent >= 0) { @@ -191,7 +190,8 @@ module.exports = class Linter { // Special comment check if (comment.trim() === `@rpglint-skip`) { - break; + lineNumber += 1; + continue; } } @@ -246,6 +246,8 @@ module.exports = class Linter { let value; if (statement.length >= 1) { + if (statement[0].type === `directive` && statement[0].value.toUpperCase() === `/EOF`) break; + switch (statement[0].type) { case `format`: if (statement[0].value.toUpperCase() === `**CTDATA`) { diff --git a/src/language/parser.js b/src/language/parser.js index f07bf3bd..117fafbb 100644 --- a/src/language/parser.js +++ b/src/language/parser.js @@ -322,6 +322,11 @@ module.exports = class Parser { parts = pieces[0].toUpperCase().split(` `).filter(piece => piece !== ``); partsLower = pieces[0].split(` `).filter(piece => piece !== ``); + if (parts[0] === `/EOF`) { + // End of parsing for this file + break; + } + switch (parts[0]) { case `DCL-F`: const recordFormats = await this.fetchTable(parts[1]); diff --git a/tests/suite/index.js b/tests/suite/index.js index 238518f5..c5a59130 100644 --- a/tests/suite/index.js +++ b/tests/suite/index.js @@ -1476,6 +1476,28 @@ module.exports = { }, cache); assert.strictEqual(indentErrors.length, 0, `Expect no indent errors`); + }, + + skip3: async () => { + const lines = [ + `**free`, + `dcl-s xxField1 char(1);`, + ``, + `// @rpglint-skip`, + `/copy myds.ds`, + ``, + `dsply xxfield1;`, + ``, + `return`, + ].join(`\n`); + + const parser = new Parser(); + const cache = await parser.getDocs(URI, lines); + const { errors } = Linter.getErrors(lines, { + IncorrectVariableCase: true + }, cache); + + assert.strictEqual(errors.length, 1, `Expect one errors`); }, fixed1: async () => { @@ -2020,5 +2042,31 @@ module.exports = { assert.strictEqual(parmInputDs.name, `inputDS`); assert.strictEqual(parmInputDs.position.line, 11); assert.strictEqual(parmInputDs.subItems.length, 2); - } + }, + + // eof1: async () => { + // const lines = [ + // ` D UPPERCASE PR 4096 Varying`, + // ` D String 4096 Const Varying`, + // ` D Escaped n Const Options(*NoPass)`, + // ` /EoF`, + // ` Converts all of the letters in String to their`, + // ` UPPER CASE equivalents. Non-alphabetic characters`, + // ` remain unchanged.`, + // ``, + // ` Escaped = *ON = converts characters that would crash iPDF and`, + // ` HTML to approximately equivalent characters.`, + // ` For example, translate " and ' to \` .`, + // ` (Default)`, + // ` *OFF= Do not convert any characters other than A-Z.`, + // ].join(`\n`); + + // const parser = new Parser(); + // const cache = await parser.getDocs(URI, lines); + + // const uppercase = cache.find(`UPPERCASE`); + // assert.strictEqual(uppercase.name, `UPPERCASE`); + // assert.strictEqual(uppercase.position.line, 0); + // assert.strictEqual(uppercase.subItems, 2); + // } } \ No newline at end of file