From 5e81bd160eff918506d38714fd6a3942992ef1dc Mon Sep 17 00:00:00 2001 From: Liam Barry Allan Date: Mon, 25 Jul 2022 21:31:24 -0500 Subject: [PATCH] Fix for comments within statements (#100) Signed-off-by: Liam Barry Allan --- .vscode/launch.json | 3 +-- src/language/linter.js | 5 +++++ tests/suite/index.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index fb9bfa08..65ef4a74 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,8 +12,7 @@ "skipFiles": [ "/**" ], - "type": "node", - "args": ["error1"] + "type": "node" }, { "name": "Run Extension", diff --git a/src/language/linter.js b/src/language/linter.js index 54b684ec..36fbd2dc 100644 --- a/src/language/linter.js +++ b/src/language/linter.js @@ -6,6 +6,7 @@ const Declaration = require(`./models/declaration`); const Statement = require(`./statement`); const oneLineTriggers = require(`./models/oneLineTriggers`); const IssueRange = require(`./models/ContentRange`); +const { isContinueStatement } = require("typescript"); const errorText = { 'BlankStructNamesCheck': `Struct names cannot be blank (\`*N\`).`, @@ -152,6 +153,10 @@ module.exports = class Linter { } if (isLineComment) { + if (isContinueStatement) { + currentStatement += line + ``.padEnd(newLineLength, ` `); + } + const comment = line.substring(currentIndent + 2).trimEnd(); if (rules.PrettyComments) { if (comment === ``) { diff --git a/tests/suite/index.js b/tests/suite/index.js index c7b6a605..50c006d7 100644 --- a/tests/suite/index.js +++ b/tests/suite/index.js @@ -1065,6 +1065,41 @@ module.exports = { assert.strictEqual(errors[0].newValue, `%trim`); }, + linter7_casing10: async () => { + const lines = [ + `**free`, + ``, + `dcl-s sFirstName char(10);`, + `dcl-s sEmpNo char(6);`, + ``, + `Exec Sql`, + ` // Break The Parser`, + ` Select`, + ` empno`, + ` Into`, + ` :sEmpNo`, + ` From`, + ` sample.employee`, + ` Where`, + ` firstnme = :SFIRSTNAME;`, + ``, + `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 length of 1`); + assert.strictEqual(errors[0].range.start.line, 5); + assert.strictEqual(errors[0].range.end.line, 14); + assert.strictEqual(errors[0].offset.position, 120); + assert.strictEqual(errors[0].offset.length, 130); + assert.strictEqual(errors[0].newValue, `sFirstName`) + }, + linter8: async () => { const lines = [ `**FREE`,