Skip to content

Commit

Permalink
Fix for invalid keyword check on prototypes
Browse files Browse the repository at this point in the history
Signed-off-by: Liam Barry Allan <[email protected]>
  • Loading branch information
worksofliam committed Oct 28, 2022
1 parent 58fd6b1 commit 83db7bc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion schemas/rpglint.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"PrototypeCheck": {
"$id": "#/properties/PrototypeCheck",
"type": "boolean",
"description": "Prototypes can only be defined with either EXT, EXTPGM or EXTPROC"
"description": "Prototypes can only be defined with either EXTPGM or EXTPROC."
},
"ForceOptionalParens": {
"$id": "#/properties/ForceOptionalParens",
Expand Down
4 changes: 2 additions & 2 deletions server/src/language/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Range, Position } from "./models/DataPoints";
const errorText = {
'BlankStructNamesCheck': `Struct names cannot be blank (\`*N\`).`,
'QualifiedCheck': `Struct names must be qualified (\`QUALIFIED\`).`,
'PrototypeCheck': `Prototypes can only be defined with either \`EXT\`, \`EXTPGM\` or \`EXTPROC\``,
'PrototypeCheck': `Prototypes can only be defined with either \`EXTPGM\` or \`EXTPROC\``,
'ForceOptionalParens': `Expressions must be surrounded by brackets.`,
'NoOCCURS': `\`OCCURS\` is not allowed.`,
'NoSELECTAll': `\`SELECT *\` is not allowed in Embedded SQL.`,
Expand Down Expand Up @@ -471,7 +471,7 @@ export default class Linter {
inPrototype = true;
if (rules.PrototypeCheck || rules.NoExtProgramVariable) {

const extIndex = statement.findIndex(part => part.value && part.value.toUpperCase().startsWith(`EXT`));
const extIndex = statement.findIndex(part => part.value && [`EXTPGM`, `EXTPROC`].includes(part.value.toUpperCase()));
if (extIndex >= 0) {
if (rules.NoExtProgramVariable) {

Expand Down
24 changes: 20 additions & 4 deletions tests/suite/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1783,10 +1783,6 @@ exports.linter21 = async () => {
});
}

/**
* Test procedure length.
* When Procedure is defined, the prototype is overridden.
*/
exports.linter22 = async () => {
const lines = [
`**FREE`,
Expand Down Expand Up @@ -1821,6 +1817,26 @@ exports.linter22 = async () => {
});
}

exports.linter22_b = async () => {
const lines = [
`**FREE`,
``,
`Dcl-Pr TheProcedure EXTPROC;`,
` parmA CHAR(20);`,
`End-Pr`,
``,
`Dcl-S theVar CHAR(20);`,
].join(`\n`);

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

assert.strictEqual(errors.length, 0);
}

exports.linter23 = async () => {
const lines = [
`**free`,
Expand Down

0 comments on commit 83db7bc

Please sign in to comment.