Skip to content

Commit

Permalink
Support directives on specs (#123)
Browse files Browse the repository at this point in the history
Signed-off-by: Liam Barry Allan <[email protected]>
  • Loading branch information
worksofliam committed Oct 12, 2022
1 parent 7eba9f8 commit db25599
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/vscode/LanguageWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit db25599

Please sign in to comment.