Skip to content

Commit

Permalink
Fix for comments within statements (#100)
Browse files Browse the repository at this point in the history
Signed-off-by: Liam Barry Allan <[email protected]>
  • Loading branch information
worksofliam committed Jul 26, 2022
1 parent 2c71977 commit 5e81bd1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
"args": ["error1"]
"type": "node"
},
{
"name": "Run Extension",
Expand Down
5 changes: 5 additions & 0 deletions src/language/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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\`).`,
Expand Down Expand Up @@ -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 === ``) {
Expand Down
35 changes: 35 additions & 0 deletions tests/suite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down

0 comments on commit 5e81bd1

Please sign in to comment.