Skip to content

Commit 9c54b91

Browse files
authored
Merge pull request #372 from codefori/fix/libl_special_in_include
Support *libl lookups in language server
2 parents c740899 + 8005019 commit 9c54b91

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

extension/server/src/server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ parser.setIncludeFileFetch(async (stringUri: string, includeString: string) => {
232232
let baseFile = parts.file || `QRPGLESRC`;
233233
let baseMember = parts.name;
234234

235+
if (parts.library && parts.library.startsWith(`*`)) {
236+
parts.library = undefined;
237+
}
238+
235239
if (parts.library) {
236240
cleanString = [
237241
``,

language/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default class Parser {
117117
* @returns {string|undefined}
118118
*/
119119
static getIncludeFromDirective(line: string): string|undefined {
120-
if (line.includes(`*`)) return; // Likely comment
120+
if (line.indexOf(`*`) !== line.toLowerCase().indexOf(`*libl`)) return; // Likely comment
121121
if (line.trim().startsWith(`//`)) return; // Likely comment
122122

123123
const upperLine = line.toUpperCase();

tests/suite/directives.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from "path";
22
import setupParser from "../parserSetup";
33
import Linter from "../../language/linter";
44
import { test, expect } from "vitest";
5+
import Parser from "../../language/parser";
56

67
const parser = setupParser();
78
const uri = `source.rpgle`;
@@ -653,4 +654,12 @@ test('fixed copy with comment and using double quotes', async () => {
653654
const cache = await parser.getDocs(uri, lines, { withIncludes: true, ignoreCache: true });
654655

655656
expect(cache.includes.length).toBe(2);
657+
});
658+
659+
test('test copy with *libl', async () => {
660+
const valueA = Parser.getIncludeFromDirective(`/copy qrpgleref,stufh`);
661+
expect(valueA).toBe(`qrpgleref,stufh`);
662+
663+
const valueB = Parser.getIncludeFromDirective(`/copy *libl/qrpgleref,stufh`);
664+
expect(valueB).toBe(`*libl/qrpgleref,stufh`);
656665
});

0 commit comments

Comments
 (0)