Skip to content

Commit

Permalink
Better support for overload in prototypes
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Mar 4, 2022
1 parent 957af5e commit d1dec6c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/language/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,12 +894,9 @@ module.exports = class Linter {
if ([
`IF`, `ELSE`, `ELSEIF`, `FOR`, `FOR-EACH`, `DOW`, `DOU`, `MONITOR`, `ON-ERROR`, `ON-EXIT`, `BEGSR`, `SELECT`, `WHEN`, `OTHER`, `DCL-PROC`, `DCL-PI`, `DCL-PR`, `DCL-DS`
].includes(opcode)) {
if (opcode === `DCL-DS` && oneLineTriggers[opcode].some(trigger => upperLine.includes(trigger))) {
//No change
if ([`DCL-DS`, `DCL-PI`, `DCL-PR`].includes(opcode) && oneLineTriggers[opcode].some(trigger => upperLine.includes(trigger))) {
//No change
}
else if (opcode === `DCL-PI` && oneLineTriggers[opcode].some(trigger => upperLine.includes(trigger))) {
//No change
}
else if (opcode === `SELECT`) {
if (skipIndentCheck === false) expectedIndent += (indent*2);
}
Expand Down
1 change: 1 addition & 0 deletions src/language/models/oneLineTriggers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
'DCL-DS': [`LIKEDS`, `LIKEREC`, `END-DS`],
'DCL-PI': [`END-PI`],
'DCL-PR': [`OVERLOAD`]
}
6 changes: 6 additions & 0 deletions src/language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,12 @@ module.exports = class Parser {

currentItem.readParms = true;

// Does the keywords include a keyword that makes end-ds useless?
if (currentItem.keywords.some(keyword => oneLineTriggers[`DCL-PR`].some(trigger => keyword.startsWith(trigger)))) {
scope.procedures.push(currentItem);
resetDefinition = true;
}

currentDescription = [];
}
}
Expand Down
38 changes: 38 additions & 0 deletions tests/suite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2520,5 +2520,43 @@ module.exports = {
},
newValue: undefined,
});
},

overload1: async () => {
const lines = [
`**FREE`,
``,
`Dcl-PR json_setBool pointer extproc(*CWIDEN : 'jx_SetBoolByName');`,
` node pointer value;`,
` nodePath pointer value options(*string);`,
` value ind value;`,
`End-PR;`,
``,
`Dcl-PR json_setNum pointer extproc(*CWIDEN : 'jx_SetDecByName');`,
` node pointer value;`,
` nodePath pointer value options(*string);`,
` value packed(30:15) value;`,
`End-PR;`,
``,
`Dcl-PR json_set pointer overload ( `,
` json_setBool: `,
` json_setNum `,
`);`,
``,
`Dcl-PR json_nodeType int(5) extproc(*CWIDEN : 'jx_GetNodeType');`,
` node pointer value;`,
`End-PR;`,
].join(`\n`);

const parser = new Parser();
const cache = await parser.getDocs(URI, lines);

const { indentErrors } = Linter.getErrors(lines, {
indent: 2,
PrettyComments: true
}, cache);

assert.strictEqual(cache.procedures.length, 4);
assert.strictEqual(indentErrors.length, 0);
}
}

0 comments on commit d1dec6c

Please sign in to comment.