diff --git a/package.json b/package.json index 06d732aa2..f15c9277a 100644 --- a/package.json +++ b/package.json @@ -43,12 +43,6 @@ "type": "ibmi" } ], - "snippets": [ - { - "path": "./schemas/local-variables.code-snippets", - "language": "json" - } - ], "jsonValidation": [ { "fileMatch": [ diff --git a/schemas/local-variables.code-snippets b/schemas/local-variables.code-snippets deleted file mode 100644 index 25fd59f9e..000000000 --- a/schemas/local-variables.code-snippets +++ /dev/null @@ -1,110 +0,0 @@ -{ - "&CURLIB": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&CURLIB", - "body": "&CURLIB", - "description": "Current library" - }, - "&BUILDLIB": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&BUILDLIB", - "body": "&BUILDLIB", - "description": "Build library. This is always the same as &CURLIB" - }, - "&USERNAME": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&USERNAME", - "body": "&USERNAME", - "description": "Username being used for the connection" - }, - "&HOST": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&HOST", - "body": "&HOST", - "description": "Hostname (or IP) being used for the connection" - }, - "&HOME": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&HOME", - "body": "&HOME", - "description": "Working directory of the user" - }, - "&LIBLS": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&LIBLS", - "body": "&LIBLS", - "description": "Library list, space delimited" - }, - "&LOCALPATH": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&LOCALPATH", - "body": "&LOCALPATH", - "description": "Full local path of the file the Action is running against" - }, - "&RELATIVEPATH": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&RELATIVEPATH", - "body": "&RELATIVEPATH", - "description": "Relative path of the file the Action is running against" - }, - "&FULLPATH": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&FULLPATH", - "body": "&FULLPATH", - "description": "Full remote path of the file the Action is running against" - }, - "&WORKDIR": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&WORKDIR", - "body": "&WORKDIR", - "description": "Working directory of the user. Typically the deployment directory" - }, - "&BRANCHLIB": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&BRANCHLIB", - "body": "&BRANCHLIB", - "description": "Branch library. This is based on the current branch" - }, - "&BRANCH": { - "scope": { - "language": "json", - "path": ".vscode/actions.json" - }, - "prefix": "&BRANCH", - "body": "&BRANCH", - "description": "Current branch inside of Git" - } -} diff --git a/src/extension.ts b/src/extension.ts index 486547ef8..28e514e6d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,5 +1,5 @@ // The module 'vscode' contains the VS Code extensibility API -import { ExtensionContext, commands, window, workspace } from "vscode"; +import { ExtensionContext, commands, languages, window, workspace } from "vscode"; // this method is called when your extension is activated // your extension is activated the very first time the command is executed @@ -17,6 +17,7 @@ import { parseErrors } from "./api/errors/parser"; import { DeployTools } from "./api/local/deployTools"; import { Deployment } from "./api/local/deployment"; import { IFSFS } from "./filesystems/ifsFs"; +import { LocalActionCompletionItemProvider } from "./languages/actions/completion"; import { updateLocale } from "./locale"; import * as Sandbox from "./sandbox"; import { initialise } from "./testing"; @@ -42,14 +43,14 @@ export async function activate(context: ExtensionContext): Promise GlobalStorage.get().setLastConnections(lastConnections); commands.executeCommand(`setContext`, `code-for-ibmi:hasPreviousConnection`, lastConnections.length > 0); }; - + SettingsUI.init(context); initializeConnectionBrowser(context); initializeObjectBrowser(context) initializeIFSBrowser(context); initializeDebugBrowser(context); - context.subscriptions.push( + context.subscriptions.push( window.registerTreeDataProvider( `helpView`, new HelpView() @@ -90,7 +91,8 @@ export async function activate(context: ExtensionContext): Promise }), workspace.registerFileSystemProvider(`streamfile`, new IFSFS(), { isCaseSensitive: false - }) + }), + languages.registerCompletionItemProvider({ language: 'json', pattern: "**/.vscode/actions.json" }, new LocalActionCompletionItemProvider(), "&") ); CompileTools.register(context); @@ -122,14 +124,14 @@ export async function activate(context: ExtensionContext): Promise return { instance, customUI: () => new CustomUI(), deployTools: DeployTools, evfeventParser: parseErrors, tools: Tools }; } -async function fixLoginSettings(){ +async function fixLoginSettings() { const connections = (GlobalConfiguration.get(`connections`) || []); let update = false; - for(const connection of connections){ + for (const connection of connections) { //privateKey was used to hold privateKeyPath - if('privateKey' in connection){ + if ('privateKey' in connection) { const privateKey = connection["privateKey"] as string; - if(privateKey){ + if (privateKey) { connection.privateKeyPath = privateKey; } delete connection["privateKey"]; @@ -137,19 +139,19 @@ async function fixLoginSettings(){ } //An empty privateKeyPath will crash the connection - if(!connection.privateKeyPath?.trim()) { + if (!connection.privateKeyPath?.trim()) { connection.privateKeyPath = undefined; update = true; } - + //buttons were added by the login settings page - if(`buttons` in connection) { + if (`buttons` in connection) { delete connection["buttons"]; update = true; } } - if(update){ + if (update) { await GlobalConfiguration.set(`connections`, connections); } } diff --git a/src/languages/actions/completion.ts b/src/languages/actions/completion.ts new file mode 100644 index 000000000..63258adce --- /dev/null +++ b/src/languages/actions/completion.ts @@ -0,0 +1,47 @@ +import vscode from "vscode"; +import { t } from "../../locale"; + +type Item = { + name: string + description: string +} + +const ITEMS = [ + "BASENAME", + "BRANCH", + "BRANCHLIB", + "BUILDLIB", + "CURLIB", + "EXT", + "EXTL", + "FILEDIR", + "FULLPATH", + "HOST", + "LIBLC", + "LIBLS", + "LIBRARY", + "LOCALPATH", + "NAME", + "NAMEL", + "PARENT", + "RELATIVEPATH", + "USERNAME", + "WORKDIR", +]; + +export class LocalActionCompletionItemProvider implements vscode.CompletionItemProvider { + provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext) { + //Only provide items if the cursor is on a "command" line + if (/^\s*"command"\s*:/.test(document.lineAt(position.line).text)) { + return ITEMS.map(item => ({ + label: item, + detail: t(`actions.${item}`).replaceAll(/|<\/code>|&/g, ""), + insertText: context.triggerCharacter ? undefined : `&${item}`, + kind: vscode.CompletionItemKind.Variable + } as vscode.CompletionItem)); + } + else{ + return []; + } + } +} \ No newline at end of file diff --git a/src/locale/ids/da.ts b/src/locale/ids/da.ts index b585d2f96..723195bf7 100644 --- a/src/locale/ids/da.ts +++ b/src/locale/ids/da.ts @@ -299,6 +299,8 @@ export const da: Locale = { 'actions.USERNAME': `Brugernavn for forbindelsen`, 'actions.WORKDIR': `Aktuel arbejdsmappe, kan ændres i IFS Browser`, 'actions.HOST': `Host navn eller IP adresse fra den aktuelle forbindelse`, + 'actions.BRANCH': `Nuværende git-gren`, + 'actions.BRANCHLIB': `Bibliotek for den nuværende Git-gren`, 'actions.BUILDLIB': `Det samme som &CURLIB`, 'actions.LIBLC': `Liste af biblioteker adskilt af komma`, 'actions.LIBLS': `Liste af biblioteker adskilt af mellemrum`, @@ -315,8 +317,11 @@ export const da: Locale = { 'actions.streamfile.EXT': `Filtypen (&EXTL for små bogstaver)`, 'actions.LIBRARY': `Biblioteksnavn med objektet (&LIBRARYL for små bogstaver)`, 'actions.NAME': `Navn på objektet (&NAMEL for små bogstaver)`, + 'actions.NAMEL': `Navn på objektet med små bogstaver`, 'actions.object.TYPE': `Typen af objektet (&TYPEL for små bogstaver)`, 'actions.object.EXT': `Objektets attribut (&EXTL for små bogstaver)`, + 'actions.EXT': `Filtypen`, + 'actions.EXTL': `Filtypen med små bogstaver`, 'actions.mainMenu.workWithActions': `Arbejd med Aktioner`, 'actions.mainMenu.createOrMaintain': `Opret eller revider Aktioner. Aktioner er grupperede efter typen på de vedrørte filer/objekter.`, 'actions.mainMenu.newAction': `Opret`, diff --git a/src/locale/ids/en.ts b/src/locale/ids/en.ts index 7229d69f6..8529fdbab 100644 --- a/src/locale/ids/en.ts +++ b/src/locale/ids/en.ts @@ -299,6 +299,8 @@ export const en: Locale = { 'actions.USERNAME': `Username for connection`, 'actions.WORKDIR': `Current working directory, changeable in IFS Browser`, 'actions.HOST': `Hostname or IP address from the current connection`, + 'actions.BRANCH': `Current Git branch`, + 'actions.BRANCHLIB': `Branch library, based on the current branch`, 'actions.BUILDLIB': `The same as &CURLIB`, 'actions.LIBLC': `Library list delimited by comma`, 'actions.LIBLS': `Library list delimited by space`, @@ -315,8 +317,11 @@ export const en: Locale = { 'actions.streamfile.EXT': `Extension of the file (&EXTL for lowercase)`, 'actions.LIBRARY': `Library name where the object lives (&LIBRARYL for lowercase)`, 'actions.NAME': `Name of the object (&NAMEL for lowercase)`, + 'actions.NAMEL': `Lowercase name of the object`, 'actions.object.TYPE': `Type of the object (&TYPEL for lowercase)`, 'actions.object.EXT': `Extension/attribute of the object (&EXTL for lowercase)`, + 'actions.EXT': `Filte type`, + 'actions.EXTL': `Lowercase file type`, 'actions.mainMenu.workWithActions': `Work with Actions`, 'actions.mainMenu.createOrMaintain': `Create or maintain Actions. Actions are grouped by the type of file/object they target.`, 'actions.mainMenu.newAction': `New Action`, diff --git a/src/locale/ids/fr.ts b/src/locale/ids/fr.ts index 6c6e6c43c..59759c1cb 100644 --- a/src/locale/ids/fr.ts +++ b/src/locale/ids/fr.ts @@ -299,6 +299,8 @@ export const fr: Locale = { 'actions.USERNAME': `Nom d'utilisateur de la connexion`, 'actions.WORKDIR': `Répertoire de travail actuel, modifiable dans le navigateur IFS`, 'actions.HOST': `Nom d'hôte ou adresse IP de la connexion`, + 'actions.BRANCH': `Branche Git en cours`, + 'actions.BRANCHLIB': `Bibliothèque de la branche, basée sur la branche en cours`, 'actions.BUILDLIB': `Voir &CURLIB`, 'actions.LIBLC': `Liste des bilbiothèques, séparée par des virgules`, 'actions.LIBLS': `Liste des bilbiothèques, séparée par des espaces`, @@ -315,8 +317,11 @@ export const fr: Locale = { 'actions.streamfile.EXT': `Extension du fichier (&EXTL pour le nom en minuscule)`, 'actions.LIBRARY': `Nom de la bibliothèque contenant l'objet (&LIBRARYL pour le nom en minuscule)`, 'actions.NAME': `Nom de l'objet (&NAMEL pour le nom en minuscule)`, + 'actions.NAMEL': `Nom de l'objet en minuscule`, 'actions.object.TYPE': `Type de l'objet (&TYPEL pour le nom en minuscule)`, 'actions.object.EXT': `Extension/attribut de l'objet (&EXTL pour le nom en minuscule)`, + 'actions.EXT': `Extension du fichier`, + 'actions.EXTL': `Extension du fichier en minuscule`, 'actions.mainMenu.workWithActions': `Maintenance des Actions`, 'actions.mainMenu.createOrMaintain': `Créez ou éditez des Actions. Les Actions sont groupées par type.`, 'actions.mainMenu.newAction': `Créer Action`,