Skip to content

Commit

Permalink
Ensure commented out includes are not read
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Sep 18, 2024
1 parent c034545 commit 1f8e857
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export default class Parser {
*/
static getIncludeFromDirective(line) {
if (line.includes(`*`)) return; // Likely comment
if (line.includes(`//`)) return; // Likely comment

const upperLine = line.toUpperCase();
let comment = -1;
Expand Down Expand Up @@ -297,7 +298,7 @@ export default class Parser {
} else {
// We need to add qualified as it is qualified by default.
if (!ds.keywords.includes(`QUALIFIED`))
ds.keywords.push(`QUALIFIED`);
ds.keywords.push(`QUALIFIED`);

// Fetch from local definitions
for (let i = scopes.length - 1; i >= 0; i--) {
Expand Down
24 changes: 23 additions & 1 deletion tests/suite/directives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,29 @@ test('variable_case1', async () => {
type: `IncorrectVariableCase`,
newValue: `CustomerName_t`
});
})
});

test('variable_case1 commented out', async () => {
const lines = [
`**FREE`,
`Ctl-Opt DftActGrp(*No);`,
`// /copy './tests/rpgle/copy3.rpgle'`,
`Dcl-S MyCustomerName1 like(customername_t);`,
`Dcl-S MyCustomerName2 like(CustomerName_t);`,
`Dcl-S MyCustomerName3 like(CUSTOMERNAME_t);`,
`Dcl-S MyCustomerName4 like(CUSTOMERNAME_T);`,
`MyCustomerName1 = 'John Smith';`,
`dsply MyCustomerName1;`,
`Return;`
].join(`\n`);

const cache = await parser.getDocs(uri, lines, { withIncludes: true, ignoreCache: true });
const { errors } = Linter.getErrors({ uri, content: lines }, {
IncorrectVariableCase: true
}, cache);

expect(errors.length).toBe(0);
});

test('uppercase1', async () => {
const lines = [
Expand Down

0 comments on commit 1f8e857

Please sign in to comment.