Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion language/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,11 @@ export default class Parser {
i++; // Skip one for the block.
} else {
if (isConst) {
keyvalues[`CONST`] = keywordParts[i].value;
if (!keyvalues[`CONST`]) {
keyvalues[`CONST`] = ``;
}

keyvalues[`CONST`] += keywordParts[i].value;
} else {
keyvalues[keywordParts[i].value.toUpperCase()] = true;
}
Expand Down
16 changes: 15 additions & 1 deletion tests/suite/basics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1732,4 +1732,18 @@ test('can resolve return structure correctly', async () => {
expect(typeDataD.reference.name).toBe(`return_t`);
expect(typeDataD.reference.type).toBe(`struct`);
expect(typeDataD.reference.subItems.length).toBe(2);
});
});

test('const value #400', async () => {
const lines = [
`**free`,
`Dcl-C PI 3.14159;`
].join(`\n`);

const cache = await parser.getDocs(uri, lines, { ignoreCache: true, withIncludes: false });

expect(cache.constants.length).toBe(1);
const pi = cache.find(`PI`);
expect(pi.name).toBe(`PI`);
expect(pi.keyword[`CONST`]).toBe(`3.14159`);
})
4 changes: 1 addition & 3 deletions tests/suite/directives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,7 @@ test('depth test', async () => {
const cache = await parser.getDocs(uri, lines, { withIncludes: true, ignoreCache: true });

expect(cache.includes.length).toBe(2);

console.log(cache.includes);


expect(cache.includes[0].fromPath).toBe(uri);
expect(cache.includes[0].toPath.endsWith(path.posix.join(`rpgle`, `depth1.rpgleinc`))).toBeTruthy();
expect(cache.includes[0].line).toBe(2); // zero indexed
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3296,7 +3296,7 @@ test('issue_353_indent_4', async () => {
const atQuote = cache.find(`@QUOTE`);
expect(atQuote).toBeDefined();
expect(atQuote).toBeDefined();
expect(atQuote.keyword[`CONST`]).toBe(`''`);
expect(atQuote.keyword[`CONST`]).toBe(`''''`);

const atSomethingInBetween = cache.find(`@SOMETHING_IN_BETWEEN`);
expect(atSomethingInBetween).toBeDefined();
Expand Down