From a9906246e445cd9cf4620c724f466b8f8745587a Mon Sep 17 00:00:00 2001 From: worksofliam Date: Fri, 17 Nov 2023 08:42:50 -0500 Subject: [PATCH 1/8] Initial fix for scope issue --- language/parser.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/language/parser.js b/language/parser.js index a0cea3bf..555b1bd4 100644 --- a/language/parser.js +++ b/language/parser.js @@ -1032,10 +1032,12 @@ export default class Parser { scope.files.push(currentItem); } else { currentItem = scope.files[scope.files.length-1]; - currentItem.keywords = [ - ...(currentItem.keywords ? currentItem.keywords : []), - ...fSpec.keywords - ] + if (currentItem) { + currentItem.keywords = [ + ...(currentItem.keywords ? currentItem.keywords : []), + ...fSpec.keywords + ] + } } resetDefinition = true; From 61fa86bba523e4481aa170dc5ef8ceaea9f2e75e Mon Sep 17 00:00:00 2001 From: worksofliam Date: Sat, 18 Nov 2023 13:57:21 -0500 Subject: [PATCH 2/8] Fix directive value extraction bug --- language/parser.js | 17 +++++++++++++++-- tests/suite/fixed.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/language/parser.js b/language/parser.js index 555b1bd4..6d43a92b 100644 --- a/language/parser.js +++ b/language/parser.js @@ -142,13 +142,26 @@ export default class Parser { directiveLength = 9 }; + /** @type {string|undefined} */ + let directiveValue; + if (directivePosition >= 0) { if (comment >= 0) { - return line.substring(directivePosition+directiveLength, comment).trim(); + directiveValue = line.substring(directivePosition+directiveLength, comment).trim(); } else { - return line.substring(directivePosition+directiveLength).trim(); + directiveValue = line.substring(directivePosition+directiveLength).trim(); + } + } + + if (directiveValue) { + const spaceIndex = directiveValue.indexOf(` `); + if (spaceIndex >= 0) { + directiveValue = directiveValue.substring(0, spaceIndex); } + + return directiveValue; } + } /** diff --git a/tests/suite/fixed.js b/tests/suite/fixed.js index ae2ecd53..2d79be85 100644 --- a/tests/suite/fixed.js +++ b/tests/suite/fixed.js @@ -1,5 +1,6 @@ const assert = require(`assert`); +const path = require(`path`); const {default: parserSetup} = require(`../parserSetup`); @@ -416,6 +417,37 @@ exports.fixed9_2 = async () => { assert.strictEqual(theExtProcedure.subItems.length, 1); }; + + +exports.fixed9_3 = async () => { + const lines = [ + ``, + ` Ctl-Opt DftActGrp(*No);`, + ` /copy tests,eof4 Call plist update program ESF`, + ` *COPY EQCPYLESRC,PLUPT_SB Call plist update program ESF`, + ``, + ` Dcl-s MyVariable2 Char(20);`, + ``, + ` Dcl-C theConstant 'Hello world';`, + ``, + ` dsply theConstant;`, + ``, + ` Return;` + ].join(`\n`); + + const cache = await parser.getDocs(uri, lines, {withIncludes: true, ignoreCache: true}); + + assert.strictEqual(cache.includes.length, 1); + assert.strictEqual(cache.variables.length, 1, `Expect length of 1`); + assert.strictEqual(cache.constants.length, 1, `Expect length of 1`); + assert.strictEqual(cache.procedures.length, 1, `Expect length of 1`); + + const uppercase = cache.find(`UPPERCASE`); + + const baseNameInclude = path.basename(uppercase.position.path); + assert.strictEqual(baseNameInclude, `eof4.rpgle`); +} + /** * Issue with detecting correct type on subfield. */ From 0e1b7e1cb36131b19f1eb37eb0c204ab550a4d07 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Sat, 18 Nov 2023 14:12:30 -0500 Subject: [PATCH 3/8] Additional fixed test --- tests/suite/fixed.js | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/suite/fixed.js b/tests/suite/fixed.js index 2d79be85..31fcb6ff 100644 --- a/tests/suite/fixed.js +++ b/tests/suite/fixed.js @@ -1120,4 +1120,54 @@ exports.file_keywords = async () => { assert.strictEqual(ord100d.keyword[`INDDS`], `indds`); assert.strictEqual(ord100d.keyword[`SFILE`], `sfl01:rrn01`); assert.strictEqual(ord100d.keyword[`INFDS`], `Info`); +} + +exports.plist_test = async () => { + const lines = [ + ``, + ` ?* PLPVD`, + ` ?* PLPVD - Calling Plist for prompt/validate module driver PLPVD`, + ` ?* PLPVD`, + ` ?* Kaprog - E3A PLPVD`, + ` ?* PLPVD`, + ` ?* @PGMID - Program name PLPVD`, + ` ?* @FLN - Field to prompt/validate on PLPVD`, + ` ?* @SQN - Sequence number of type of validation/prompt PLPVD`, + ` ?* @PRMPT - Prompt mode ('Y' or 'N') PLPVD`, + ` ?* CCN - Communication array PLPVD`, + ` ?* @ERMSG - Error message return field & parms PLPVD`, + ` ?* @NUM - Numeric return field PLPVD`, + ` ?* @CKEY - Command key used from prompt screen return field PLPVD`, + ` ?* @PPF - Prompt performed flag ('Y' or 'N') returned PLPVD`, + ` ?* @DSCNTRL - API Control Fields PLPVD`, + ` ?* @DSSUPER - API Supervisor Data PLPVD`, + ` ?* @DSINCRM - API Incremental Mode Control Fields PLPVD`, + ` ?* @DSPV - PV Control Fields PLPVD`, + ` ?* @DLFILTER - DL Filter Data PLDLD`, + ` ?* @DLLIST - Array of DL row data PLDLD`, + ` ?* @DLSELECTION - DL Selected Item PLDLD`, + ` ?* PLDLD`, + ` C PLPVD PLIST`, + ` C PARM @PGMID 10`, + ` C PARM @FLN 6`, + ` C PARM @SQN 2 0`, + ` C PARM @PRMPT 1`, + ` C PARM CCN`, + ` C DSEPMS PARM DSEPMS @ERMSG 37`, + ` C PARM @NUM 15 0`, + ` C PARM @CKEY 2`, + ` C PARM @PPF 1`, + ` C PARM @DSCNTRL`, + ` C PARM @DSSUPER`, + ` C PARM @DSINCRM`, + ` C PARM @DSPV`, + ` C PARM @PVFILTER 256`, + ` C PARM @PVLIST 9999`, + ` C PARM @PVSELECTION 256`, + `` + ].join(`\n`); + + const cache = await parser.getDocs(uri, lines, {ignoreCache: true, withIncludes: true}); + + assert.strictEqual(cache.variables.length, 0); } \ No newline at end of file From 72ef7b88c8f6652e10ccb8c356abfde69de5878a Mon Sep 17 00:00:00 2001 From: worksofliam Date: Sat, 18 Nov 2023 14:22:53 -0500 Subject: [PATCH 4/8] Bump to 0.24.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b1b77707..2afa9bf2 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/halcyon-tech/vscode-rpgle" }, "license": "MIT", - "version": "0.23.0", + "version": "0.24.0", "engines": { "vscode": "^1.70.0" }, From 3bf8c0ce78acd586f52a6465c0061fba8478bc68 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Mon, 4 Dec 2023 16:17:53 -0500 Subject: [PATCH 5/8] Enable SQL extract feature --- extension/server/src/providers/linter/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/server/src/providers/linter/index.ts b/extension/server/src/providers/linter/index.ts index a7c1fcd8..f400e8ac 100644 --- a/extension/server/src/providers/linter/index.ts +++ b/extension/server/src/providers/linter/index.ts @@ -204,7 +204,7 @@ export async function refreshLinterDiagnostics(document: TextDocument, docs: Cac } // Turn on for SQLRunner suggestions - // options.SQLRunner = true; + options.SQLRunner = true; options.StringLiteralDupe = true; From af780ea00afd2b91d516da89b6038eecf9457ca1 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Sat, 20 Jan 2024 12:46:02 -0500 Subject: [PATCH 6/8] Package upgrades --- extension/client/package-lock.json | 14 +++++++------- extension/client/package.json | 2 +- package-lock.json | 28 ++++++++++++++-------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/extension/client/package-lock.json b/extension/client/package-lock.json index b96a7bf3..1d167961 100644 --- a/extension/client/package-lock.json +++ b/extension/client/package-lock.json @@ -12,7 +12,7 @@ "vscode-languageclient": "^7.0.0" }, "devDependencies": { - "@halcyontech/vscode-ibmi-types": "^2.1.0", + "@halcyontech/vscode-ibmi-types": "^2.6.5", "@types/vscode": "^1.63.0", "@vscode/test-electron": "^2.1.2" }, @@ -21,9 +21,9 @@ } }, "node_modules/@halcyontech/vscode-ibmi-types": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@halcyontech/vscode-ibmi-types/-/vscode-ibmi-types-2.1.0.tgz", - "integrity": "sha512-vmz3CFHoJT8m0iQhghnSY9LC/BIKDP0Dr/CcOVRUS16uVtWP82Sf+lICV4XeIcak4f3FRklDCcIbgkywwv/9lQ==", + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/@halcyontech/vscode-ibmi-types/-/vscode-ibmi-types-2.6.5.tgz", + "integrity": "sha512-5LNp2FuHlufJDl5IREqdHJ942DWi2O9/ysSElV8FLB3I0Dpvg8LyzISwV9OZ+O97yk8G45OClXMAtF3w+tWEeQ==", "dev": true }, "node_modules/@tootallnate/once": { @@ -508,9 +508,9 @@ }, "dependencies": { "@halcyontech/vscode-ibmi-types": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@halcyontech/vscode-ibmi-types/-/vscode-ibmi-types-2.1.0.tgz", - "integrity": "sha512-vmz3CFHoJT8m0iQhghnSY9LC/BIKDP0Dr/CcOVRUS16uVtWP82Sf+lICV4XeIcak4f3FRklDCcIbgkywwv/9lQ==", + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/@halcyontech/vscode-ibmi-types/-/vscode-ibmi-types-2.6.5.tgz", + "integrity": "sha512-5LNp2FuHlufJDl5IREqdHJ942DWi2O9/ysSElV8FLB3I0Dpvg8LyzISwV9OZ+O97yk8G45OClXMAtF3w+tWEeQ==", "dev": true }, "@tootallnate/once": { diff --git a/extension/client/package.json b/extension/client/package.json index e69d6c8e..415273f9 100644 --- a/extension/client/package.json +++ b/extension/client/package.json @@ -12,7 +12,7 @@ "vscode-languageclient": "^7.0.0" }, "devDependencies": { - "@halcyontech/vscode-ibmi-types": "^2.1.0", + "@halcyontech/vscode-ibmi-types": "^2.6.5", "@types/vscode": "^1.63.0", "@vscode/test-electron": "^2.1.2" } diff --git a/package-lock.json b/package-lock.json index 2e2c6570..80b622b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-rpgle", - "version": "0.20.2", + "version": "0.24.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-rpgle", - "version": "0.20.2", + "version": "0.24.0", "hasInstallScript": true, "license": "MIT", "devDependencies": { @@ -3589,9 +3589,9 @@ } }, "node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -4078,9 +4078,9 @@ "dev": true }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -6598,9 +6598,9 @@ } }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -6939,9 +6939,9 @@ "dev": true }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true }, "workerpool": { From 5cf6248a4bc2d714b6f9a047573fb6b74b4f8e81 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Sat, 20 Jan 2024 13:09:20 -0500 Subject: [PATCH 7/8] Improved logic for checking if rpglint exists (#292) --- extension/client/src/linter.ts | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/extension/client/src/linter.ts b/extension/client/src/linter.ts index 378e4758..2f25251d 100644 --- a/extension/client/src/linter.ts +++ b/extension/client/src/linter.ts @@ -10,6 +10,8 @@ export function initialise(context: ExtensionContext) { const instance = getInstance(); const editor = window.activeTextEditor; + let exists = false; + if (editor && ![`member`, `streamfile`].includes(editor.document.uri.scheme)) { const workspaces = workspace.workspaceFolders; if (workspaces && workspaces.length > 0) { @@ -44,15 +46,23 @@ export function initialise(context: ExtensionContext) { } } else if (instance && instance.getConnection()) { + const connection = instance.getConnection(); + const content = instance.getContent(); + /** @type {"member"|"streamfile"} */ let type = `member`; let configPath: string | undefined; if (filter && filter.description) { // Bad way to get the library for the filter .. - const library = filter.description.split(`/`)[0]; + const library = (filter.description.split(`/`)[0]).toLocaleUpperCase(); configPath = `${library}/VSCODE/RPGLINT.JSON`; + exists = (await connection.runCommand({ + command: `CHKOBJ OBJ(${library}/VSCODE) OBJTYPE(*FILE) MBR(RPGLINT)`, + noLibList: true + })).code === 0; + } else if (editor) { //@ts-ignore type = editor.document.uri.scheme; @@ -74,12 +84,18 @@ export function initialise(context: ExtensionContext) { }); configPath = memberUri.path; + + exists = (await connection.runCommand({ + command: `CHKOBJ OBJ(${memberPath.library!.toLocaleUpperCase()}/VSCODE) OBJTYPE(*FILE) MBR(RPGLINT)`, + noLibList: true + })).code === 0; break; case `streamfile`: const config = instance.getConfig(); if (config.homeDirectory) { configPath = path.posix.join(config.homeDirectory, `.vscode`, `rpglint.json`) + exists = (await connection.sendCommand({ command: `test -e ${configPath}` })).code === 0; } break; } @@ -90,12 +106,9 @@ export function initialise(context: ExtensionContext) { if (configPath) { console.log(`Current path: ${configPath}`); - const exists = await commands.executeCommand(`code-for-ibmi.openEditable`, configPath, 1); - - if (!exists) { - const connection = instance.getConnection(); - const content = instance.getContent(); - + if (exists) { + await commands.executeCommand(`code-for-ibmi.openEditable`, configPath); + } else { window.showErrorMessage(`RPGLE linter config doesn't exist for this file. Would you like to create a default at ${configPath}?`, `Yes`, `No`).then (async (value) => { if (value === `Yes`) { @@ -157,10 +170,10 @@ export function initialise(context: ExtensionContext) { ) } -function parseMemberUri(path: string): {asp?: string, library?: string, file?: string, name: string} { - const parts = path.split(`/`).map(s => s.split(`,`)).flat().filter(s => s.length >= 1); +function parseMemberUri(fullPath: string): {asp?: string, library?: string, file?: string, name: string} { + const parts = fullPath.split(`/`).map(s => s.split(`,`)).flat().filter(s => s.length >= 1); return { - name: parts[parts.length - 1], + name: path.parse(parts[parts.length - 1]).name, file: parts[parts.length - 2], library: parts[parts.length - 3], asp: parts[parts.length - 4] From 511d8c3b72872b37764fb33033e3b3ce47325934 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Sun, 21 Jan 2024 10:36:46 -0500 Subject: [PATCH 8/8] Bump to 0.24.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2afa9bf2..cff248d8 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/halcyon-tech/vscode-rpgle" }, "license": "MIT", - "version": "0.24.0", + "version": "0.24.1", "engines": { "vscode": "^1.70.0" },