From db255999e7523059805e865d77b373bbdb318e01 Mon Sep 17 00:00:00 2001 From: Liam Barry Allan Date: Wed, 12 Oct 2022 17:28:13 -0400 Subject: [PATCH] Support directives on specs (#123) Signed-off-by: Liam Barry Allan --- src/vscode/LanguageWorker.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/vscode/LanguageWorker.js b/src/vscode/LanguageWorker.js index 78626612..3ca926af 100644 --- a/src/vscode/LanguageWorker.js +++ b/src/vscode/LanguageWorker.js @@ -31,8 +31,14 @@ module.exports = class LanguageWorker { const position = editor.selection.active; if (document.languageId === rpgLanguageid) { const linePieces = document.lineAt(position.line).text.trim().split(` `); - if ([`/COPY`, `/INCLUDE`].includes(linePieces[0].toUpperCase())) { - const {uri} = await Parser.getContent(document.uri, linePieces[1]); + const copyIndex = linePieces.findIndex(piece => { + if (piece.includes(`*`)) return false; // Comment + const pieceUpper = piece.toUpperCase(); + return (pieceUpper.includes(`/COPY`) || pieceUpper.includes(`/INCLUDE`)); + }); + + if (copyIndex >= 0 && linePieces[copyIndex+1]) { + const {uri} = await Parser.getContent(document.uri, linePieces[copyIndex+1]); if (uri) { vscode.workspace.openTextDocument(uri).then(doc => { @@ -193,8 +199,14 @@ module.exports = class LanguageWorker { ) } else { - if ([`/COPY`, `/INCLUDE`].includes(linePieces[0].toUpperCase())) { - const include = await Parser.getContent(document.uri, linePieces[1]); + const copyIndex = linePieces.findIndex(piece => { + if (piece.includes(`*`)) return false; // Comment + const pieceUpper = piece.toUpperCase(); + return (pieceUpper.includes(`/COPY`) || pieceUpper.includes(`/INCLUDE`)); + }); + + if (copyIndex >= 0 && linePieces[copyIndex+1]) { + const include = await Parser.getContent(document.uri, linePieces[copyIndex+1]); return new vscode.Hover( new vscode.MarkdownString(