diff --git a/vscode-extension/airalang-1.0.3.vsix b/vscode-extension/airalang-1.0.3.vsix new file mode 100644 index 0000000..5ccb9f2 Binary files /dev/null and b/vscode-extension/airalang-1.0.3.vsix differ diff --git a/vscode-extension/extension.js b/vscode-extension/extension.js new file mode 100644 index 0000000..235bc96 --- /dev/null +++ b/vscode-extension/extension.js @@ -0,0 +1,46 @@ +const vscode = require('vscode'); + +/** + * Activates the AiraLang extension + * @param {vscode.ExtensionContext} context + */ +function activate(context) { + const runFileDisposable = vscode.commands.registerCommand('airalang.runFile', async (fileUri) => { + let filePath = ''; + + if (fileUri && fileUri.fsPath) { + filePath = fileUri.fsPath; + } else { + const editor = vscode.window.activeTextEditor; + if (editor && editor.document) { + if (editor.document.isDirty) { + await editor.document.save(); + } + filePath = editor.document.fileName; + } + } + + if (!filePath) { + vscode.window.showWarningMessage('No active AiraLang (.aira) file to run.'); + return; + } + + // Reuse existing AiraLang terminal or create a new one + let terminal = vscode.window.terminals.find((t) => t.name === 'AiraLang'); + if (!terminal) { + terminal = vscode.window.createTerminal('AiraLang'); + } + + terminal.show(true); + terminal.sendText(`airalang "${filePath}"`); + }); + + context.subscriptions.push(runFileDisposable); +} + +function deactivate() {} + +module.exports = { + activate, + deactivate +}; diff --git a/vscode-extension/package.json b/vscode-extension/package.json index 792e626..0ed4006 100644 --- a/vscode-extension/package.json +++ b/vscode-extension/package.json @@ -2,9 +2,14 @@ "name": "airalang", "displayName": "AiraLang Language Support", "description": "Rich language support, syntax highlighting, and code snippets for AiraLang.", - "version": "1.0.2", + "version": "1.0.3", "publisher": "AiraGroupOfTechnology", "icon": "icon.png", + "main": "./extension.js", + "activationEvents": [ + "onLanguage:airalang", + "onCommand:airalang.runFile" + ], "author": { "name": "Adam Eehan (Aira Group Of Technology)" }, @@ -55,6 +60,37 @@ "language": "airalang", "path": "./snippets/snippets.json" } - ] + ], + "commands": [ + { + "command": "airalang.runFile", + "title": "Run AiraLang File in Terminal", + "category": "AiraLang", + "icon": "$(play)" + } + ], + "menus": { + "editor/title": [ + { + "command": "airalang.runFile", + "group": "navigation", + "when": "editorLangId == airalang || resourceExtname == .aira" + } + ], + "editor/title/run": [ + { + "command": "airalang.runFile", + "group": "1_run", + "when": "editorLangId == airalang || resourceExtname == .aira" + } + ], + "editor/context": [ + { + "command": "airalang.runFile", + "group": "AiraLang", + "when": "editorLangId == airalang || resourceExtname == .aira" + } + ] + } } }