import * as vscode from "vscode";
import * as vsctmls from 'vscode-textmate-languageservice';
+import * as fs from "fs";
import * as vslc2 from "vscode-languageclient";
import * as vslc from "vscode-languageclient/node";
let client: vslc.LanguageClient;
+function get_onyx_path() {
+ let onyx_path = process.env['ONYX_PATH'];
+ if (!onyx_path) {
+ onyx_path = require('os').homedir() + "/.onyx";
+ process.env["ONYX_PATH"] = onyx_path;
+ process.env["PATH"] = process.env["PATH"] + ":" + onyx_path + "/bin"
+ }
+ return onyx_path;
+}
+
+function registerCommands() {
+ vscode.commands.registerCommand('extension.pickOnyxSession', () => {
+ return new Promise((res, rej) => {
+ let onyx_path = get_onyx_path();
+
+ const sessionEntries = fs
+ .readdirSync(onyx_path)
+ .filter(file => file.startsWith("debug."))
+ .map(file => ({
+ label: file.split(".")[1],
+ pid: parseInt(file.split(".")[1])
+ }))
+
+ if (sessionEntries.length == 0) { rej(new Error("No sessions waiting to be debugged")); return; }
+ if (sessionEntries.length == 1) { res(`${onyx_path}/debug.${sessionEntries[0].pid}`); return; }
+
+ const quickPick = vscode.window.createQuickPick<{label: string, pid: number}>();
+ quickPick.title = "Attach to session";
+ quickPick.canSelectMany = false;
+ quickPick.matchOnDescription = true;
+ quickPick.matchOnDetail = true;
+ quickPick.placeholder = "Select the session to attach to";
+ quickPick.items = sessionEntries;
+
+ quickPick.onDidAccept(() => {
+ if (quickPick.selectedItems.length !== 1) {
+ rej(new Error(`Session not selected. case one`));
+ }
+
+ const selectedId = quickPick.selectedItems[0].pid;
+ quickPick.dispose();
+
+ res(`${onyx_path}/debug.${selectedId}`);
+ });
+
+ quickPick.onDidHide(() => {
+ quickPick.dispose();
+ });
+
+ quickPick.show();
+ });
+ });
+
+}
+
export async function activate(context: vscode.ExtensionContext) {
let console = vscode.window.createOutputChannel("Onyx Extension");
console.appendLine("Starting Onyx Extension");
+ registerCommands();
+
const selector: vscode.DocumentSelector = { language: 'onyx', scheme: "file" };
const engine = new vsctmls.textmateEngine.TextmateEngine('onyx', 'source.onyx');
const documentSymbolProvider = new vsctmls.documentSymbols.DocumentSymbolProvider(engine);
context.subscriptions.push(vscode.languages.registerWorkspaceSymbolProvider(workspaceSymbolProvider));
context.subscriptions.push(vscode.languages.registerDefinitionProvider({ 'language': 'onyx' }, peekFileDefinitionProvider));
- let onyx_path = process.env['ONYX_PATH'];
- if (!onyx_path) {
- onyx_path = require('os').homedir() + "/.onyx";
- process.env["ONYX_PATH"] = onyx_path;
- process.env["PATH"] = process.env["PATH"] + ":" + onyx_path + "/bin"
- }
+ let onyx_path = get_onyx_path();
let executable = `${onyx_path}/bin/onyx`;
if (process.platform == "win32") {
exports.deactivate = exports.activate = void 0;
const vscode = require("vscode");
const vsctmls = require("vscode-textmate-languageservice");
+const fs = require("fs");
const vslc = require("vscode-languageclient/node");
let client;
+function get_onyx_path() {
+ let onyx_path = process.env['ONYX_PATH'];
+ if (!onyx_path) {
+ onyx_path = require('os').homedir() + "/.onyx";
+ process.env["ONYX_PATH"] = onyx_path;
+ process.env["PATH"] = process.env["PATH"] + ":" + onyx_path + "/bin";
+ }
+ return onyx_path;
+}
+function registerCommands() {
+ vscode.commands.registerCommand('extension.pickOnyxSession', () => {
+ return new Promise((res, rej) => {
+ let onyx_path = get_onyx_path();
+ const sessionEntries = fs
+ .readdirSync(onyx_path)
+ .filter(file => file.startsWith("debug."))
+ .map(file => ({
+ label: file.split(".")[1],
+ pid: parseInt(file.split(".")[1])
+ }));
+ if (sessionEntries.length == 0) {
+ rej(new Error("No sessions waiting to be debugged"));
+ return;
+ }
+ if (sessionEntries.length == 1) {
+ res(`${onyx_path}/debug.${sessionEntries[0].pid}`);
+ return;
+ }
+ const quickPick = vscode.window.createQuickPick();
+ quickPick.title = "Attach to session";
+ quickPick.canSelectMany = false;
+ quickPick.matchOnDescription = true;
+ quickPick.matchOnDetail = true;
+ quickPick.placeholder = "Select the session to attach to";
+ quickPick.items = sessionEntries;
+ quickPick.onDidAccept(() => {
+ if (quickPick.selectedItems.length !== 1) {
+ rej(new Error(`Session not selected. case one`));
+ }
+ const selectedId = quickPick.selectedItems[0].pid;
+ quickPick.dispose();
+ res(`${onyx_path}/debug.${selectedId}`);
+ });
+ quickPick.onDidHide(() => {
+ quickPick.dispose();
+ });
+ quickPick.show();
+ });
+ });
+}
function activate(context) {
return __awaiter(this, void 0, void 0, function* () {
let console = vscode.window.createOutputChannel("Onyx Extension");
console.appendLine("Starting Onyx Extension");
+ registerCommands();
const selector = { language: 'onyx', scheme: "file" };
const engine = new vsctmls.textmateEngine.TextmateEngine('onyx', 'source.onyx');
const documentSymbolProvider = new vsctmls.documentSymbols.DocumentSymbolProvider(engine);
context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(selector, documentSymbolProvider));
context.subscriptions.push(vscode.languages.registerWorkspaceSymbolProvider(workspaceSymbolProvider));
context.subscriptions.push(vscode.languages.registerDefinitionProvider({ 'language': 'onyx' }, peekFileDefinitionProvider));
- let onyx_path = process.env['ONYX_PATH'];
- if (!onyx_path) {
- onyx_path = require('os').homedir() + "/.onyx";
- process.env["ONYX_PATH"] = onyx_path;
- process.env["PATH"] = process.env["PATH"] + ":" + onyx_path + "/bin";
- }
+ let onyx_path = get_onyx_path();
let executable = `${onyx_path}/bin/onyx`;
if (process.platform == "win32") {
// Windows distributions are different
"name": "onyxlang",
"displayName": "Onyx Programming Language",
"description": "Onyx syntax highlighting and debugger support.",
- "version": "0.1.9",
+ "version": "0.1.10",
"publisher": "onyxlang",
"license": "BSD-2-Clause",
"engines": {
"label": "Onyx Debug",
"program": "./out/debugAdapter.js",
"runtime": "node",
+ "variables": {
+ "pickSession": "extension.pickOnyxSession"
+ },
"configurationAttributes": {
"attach": {
"properties": {
"socketPath": {
"type": "string",
"description": "Path to UNIX socket for attaching to debugger",
- "default": "/tmp/ovm-debug.0000"
+ "default": "${command:pickSession}"
},
"stopOnEntry": {
"type": "boolean",
--- /dev/null
+0: 10
+1: 11
+2: 12
+3: 13
+4: 14
+5: 15
+6: 16
+7: 17
+8: 18
+9: 19
+10: 20
+11: 21
+12: 22
+13: 23
+14: 24
+15: 25
+16: 26
+17: 27
+18: 28
+19: 29
+20: 30
+21: 31
+22: 32
+23: 33
+24: 34
+25: 35
+26: 36
+27: 37
+28: 38
+29: 39
+30: 40
+31: 41
+32: 42
+33: 43
+34: 44
+35: 45
+36: 46
+37: 47
+38: 48
+39: 49
+40: 50
+41: 51
+42: 52
+43: 53
+44: 54
+45: 55
+46: 56
+47: 57
+48: 58
+49: 59
+50: 60
+51: 61
+52: 62
+53: 63
+54: 64
+55: 65
+56: 66
+57: 67
+58: 68
+59: 69
+60: 70
+61: 71
+62: 72
+63: 73
+64: 74
+65: 75
+66: 76
+67: 77
+68: 78
+69: 79
+70: 80
+71: 81
+72: 82
+73: 83
+74: 84
+75: 85
+76: 86
+77: 87
+78: 88
+79: 89
+80: 90
+81: 91
+82: 92
+83: 93
+84: 94
+85: 95
+86: 96
+87: 97
+88: 98
+89: 99
+(i64) 0: 20
+(i64) 1: 21
+(i64) 2: 22
+(i64) 3: 23
+(i64) 4: 24
+(i64) 5: 25
+(i64) 6: 26
+(i64) 7: 27
+(i64) 8: 28
+(i64) 9: 29
+(i64) 10: 30
+(i64) 11: 31
+(i64) 12: 32
+(i64) 13: 33
+(i64) 14: 34
+(i64) 15: 35
+(i64) 16: 36
+(i64) 17: 37
+(i64) 18: 38
+(i64) 19: 39
+(i64) 20: 40
+(i64) 21: 41
+(i64) 22: 42
+(i64) 23: 43
+(i64) 24: 44
+(i64) 25: 45
+(i64) 26: 46
+(i64) 27: 47
+(i64) 28: 48
+(i64) 29: 49
+0: 2
+1: 3
+2: 5
+3: 7
+4: 11
--- /dev/null
+use core {*}
+
+main :: () {
+ for value, index in 10 .. 100 {
+ // value: 10 -> 99
+ // index: 0 -> 89
+ //
+ // value is i32
+ // index is i32
+ printf("{}: {}\n", index, value);
+ }
+
+ for value, index: i64 in 20 .. 50 {
+ // value: 20 -> 49
+ // index: 0 -> 29
+ //
+ // value is i32
+ // index is i64
+ printf("({}) {}: {}\n", typeof index, index, value);
+ }
+
+ values := .[2, 3, 5, 7, 11];
+ for value: i32, index in values {
+ printf("{}: {}\n", index, value);
+ }
+}