Skip to content

Commit

Permalink
Fix broken range for oneline struct
Browse files Browse the repository at this point in the history
Signed-off-by: Liam Barry Allan <[email protected]>
  • Loading branch information
worksofliam committed Aug 21, 2022
1 parent 649bf3f commit 524e60c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ module.exports = class Parser {

// Does the keywords include a keyword that makes end-ds useless?
if (currentItem.keywords.some(keyword => oneLineTriggers[`DCL-DS`].some(trigger => keyword.startsWith(trigger)))) {
currentItem.range.end = lineNumber;
scope.structs.push(currentItem);
} else {
currentItem.readParms = true;
Expand Down Expand Up @@ -1039,7 +1040,7 @@ module.exports = class Parser {

currentItem.range = {
start: lineNumber,
end: null
end: lineNumber
};

currentGroup = `procedures`;
Expand Down
28 changes: 26 additions & 2 deletions tests/suite/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ exports.subds1 = async () => {
});
};

exports.dothingy = async () => {
exports.range1 = async () => {
const lines = [
`**FREE`,
`///`,
Expand Down Expand Up @@ -501,4 +501,28 @@ exports.dothingy = async () => {
start: 21,
end: 23
});
};
};

exports.range2 = async () => {
const lines = [
`**free`,
`Dcl-S FullCmd Char(32);`,
`Dcl-DS ABCD LikeDS(BBOOP);`,
``,
``,
`Dcl-S Eod Ind;`,
].join(`\n`);

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

assert.strictEqual(cache.variables.length, 2);
assert.strictEqual(cache.structs.length, 1);

const ABCD = cache.find(`ABCD`);
assert.strictEqual(ABCD.keyword[`LIKEDS`], `BBOOP`);
assert.deepStrictEqual(ABCD.range, {
start: 2,
end: 2
});
}

0 comments on commit 524e60c

Please sign in to comment.