657 lines
22 KiB
TypeScript
657 lines
22 KiB
TypeScript
// The module 'vscode' contains the VS Code extensibility API
|
||
// Import the module and reference it with the alias vscode in your code below
|
||
import * as vscode from 'vscode';
|
||
|
||
import { GenericTreeDataProvider } from './tdp/GenericTreeDataProvider';
|
||
import { GenericTreeDataItem } from './tdp/GenericTreeDataItem';
|
||
import { ModuleExplorerTreeDataProvider } from './moduleExplorer/ModuleExplorerTreeDataProvider';
|
||
import { userInfo } from 'os';
|
||
import { Machine } from './Machine';
|
||
|
||
import { SuvManagerTreeDecorationProvider } from './suvManager/SuvManagerTreeDecorationProvider';
|
||
import { SuvManagerTreeDataProvider } from './suvManager/SuvManagerTreeDataProvider';
|
||
|
||
import * as path from 'path';
|
||
|
||
import https from 'node:https';
|
||
import { stat } from 'node:fs';
|
||
import { ZqGenerator } from './zq/ZqGenerator';
|
||
import { ZqFunctionDefinition } from './zq/ZqFunctionDefinition';
|
||
import { ZqClass } from './zq/ZqClass';
|
||
import { InstanceKey } from './mocha/core/InstanceKey';
|
||
import { ZqAttribute } from './zq/ZqAttribute';
|
||
import { ZqRelationship } from './zq/ZqRelationship';
|
||
import { ZqInstance } from './zq/ZqInstance';
|
||
import { ZqInstanceReference } from './zq/ZqInstanceReference';
|
||
import { ZqObject } from './zq/ZqObject';
|
||
import { ZqParser } from './zq/parser/ZqParser';
|
||
|
||
const cp = require('child_process');
|
||
|
||
const extension = vscode.extensions.getExtension('mochapowered.mocha-vscode');
|
||
|
||
let dpModuleExplorer = new ModuleExplorerTreeDataProvider();
|
||
let treeSuvManager: vscode.TreeView<Machine> | undefined = undefined;
|
||
let currentSuvId: string | null = null;
|
||
let statusBarItem : vscode.StatusBarItem | undefined = undefined;
|
||
const updateStatusBarText = () => {
|
||
if (statusBarItem !== undefined) { statusBarItem.text = `$(server-environment) ${currentSuvId || "(none)"}`; }
|
||
}
|
||
const updateStatusBarItemVisibility = () => {
|
||
let showStatusbar: boolean = true;
|
||
if (statusBarItem !== undefined) { showStatusbar ? statusBarItem.show() : statusBarItem.hide(); }
|
||
}
|
||
|
||
export function getCurrentSuvId() {
|
||
return currentSuvId;
|
||
}
|
||
|
||
|
||
// register the decoration provider
|
||
vscode.window.registerFileDecorationProvider(new SuvManagerTreeDecorationProvider());
|
||
|
||
export function mkotsuri(suvId : string, tenantName : string, command : string, serviceName : string = "zq", version : string = "v1") : vscode.Uri
|
||
{
|
||
let otsUri = vscode.Uri.parse("https://" + suvId + ".privatesuv.com/ots/" + tenantName + "/services/" + serviceName + "/" + version + "/" + command);
|
||
return otsUri;
|
||
}
|
||
|
||
function updateModuleExplorerTreeView() {
|
||
|
||
/*
|
||
dpModuleExplorer.items.push(new GenericTreeDataItem("tools", "tools", [
|
||
new GenericTreeDataItem("tools:xpresso", "xpressO", [
|
||
new GenericTreeDataItem("tools:xpressO:method", "method", [
|
||
new GenericTreeDataItem("tools:xpresso:method:AccessModifier", "AccessModifier", undefined, {
|
||
"type": "class",
|
||
"instanceId": "1$4170"
|
||
}),
|
||
new GenericTreeDataItem("tools:xpresso:method:Method", "Method", undefined, {
|
||
"type": "class",
|
||
"instanceId": "1$4171"
|
||
})
|
||
], {
|
||
"type": "module"
|
||
})
|
||
], {
|
||
"type": "module"
|
||
})],
|
||
{
|
||
"type": "module"
|
||
}
|
||
));
|
||
return;
|
||
*/
|
||
|
||
let suvId: string | null = getCurrentSuvId();
|
||
if (suvId !== null) {
|
||
let tenantName: string = "super";
|
||
let otsuri = mkotsuri(suvId, tenantName, "module/list");
|
||
|
||
cp.exec("curl " + otsuri.toString(), (err: string, stdout: string, stderr: string) => {
|
||
if (err !== "") {
|
||
vscode.window.showErrorMessage(err);
|
||
}
|
||
let json = JSON.parse(stdout);
|
||
for (var i = 0; i < json.items.length; i++) {
|
||
recursiveAddItemToTreeView(dpModuleExplorer, json.items[i], null);
|
||
}
|
||
|
||
dpModuleExplorer.refresh();
|
||
|
||
//let treeModuleExplorer = vscode.window.createTreeView("mocha.moduleExplorer", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": dpModuleExplorer });
|
||
//console.log(stdout);
|
||
});
|
||
}
|
||
}
|
||
|
||
function recursiveAddItemToTreeView(dp : GenericTreeDataProvider, item : any, parent : GenericTreeDataItem | null)
|
||
{
|
||
var p;
|
||
if (item.instanceId)
|
||
{
|
||
p = new GenericTreeDataItem(item.name, item.title, undefined, { "type": item.type, "instanceId": item.instanceId });
|
||
}
|
||
else
|
||
{
|
||
p = new GenericTreeDataItem(item.name, item.title, undefined, { "type": item.type });
|
||
}
|
||
p.description = item.instanceId;
|
||
if (item.items)
|
||
{
|
||
for (var i = 0; i < item.items.length; i++)
|
||
{
|
||
recursiveAddItemToTreeView(dp, item.items[i], p);
|
||
}
|
||
}
|
||
if (parent === null)
|
||
{
|
||
console.log("adding item '" + p.name + "' to root");
|
||
dp.items.push(p);
|
||
}
|
||
else
|
||
{
|
||
console.log("adding item '" + p.name + "' to parent '" + parent.name + "'");
|
||
parent.children.push(p);
|
||
}
|
||
}
|
||
|
||
function launchSuv(name : string)
|
||
{
|
||
cp.exec("mocha suv up " + name, (err2: string, stdout2: string, stderr2: string) => {
|
||
vscode.window.showInformationMessage('Selected SUV ( ' + name + ' ) launched successfully!');
|
||
});
|
||
vscode.window.showInformationMessage('Selected SUV ( ' + name + ' ) is launching now!');
|
||
}
|
||
|
||
let outputChannel: vscode.OutputChannel | undefined = undefined;
|
||
|
||
const options = {
|
||
borderWidth: '1px',
|
||
borderStyle: 'solid',
|
||
overviewRulerColor: 'blue',
|
||
|
||
overviewRulerLane: vscode.OverviewRulerLane.Right,
|
||
light: {
|
||
// this color will be used in light color themes
|
||
borderColor: 'darkblue',
|
||
contentIconPath: extension?.extensionPath + '/icons/light/explorer/class.svg'
|
||
|
||
},
|
||
dark: {
|
||
// this color will be used in dark color themes
|
||
borderColor: 'lightblue',
|
||
contentIconPath: extension?.extensionPath + '/icons/dark/explorer/class.svg'
|
||
}
|
||
};
|
||
|
||
const classDecorationType = vscode.window.createTextEditorDecorationType({
|
||
before:
|
||
{
|
||
contentIconPath: extension?.extensionPath + '/icons/decorations/class.svg',
|
||
margin: "2px 2px 0px 2px"
|
||
}
|
||
});
|
||
|
||
function openEditorForInstance(filename: string, instanceId: string)
|
||
{
|
||
let tdi = vscode.workspace.openTextDocument(vscode.Uri.file(path.join(userInfo().homedir, filename + ".zql") ).with({ scheme: "untitled" })).then( (doc) =>
|
||
{
|
||
vscode.window.showTextDocument(doc).then((editor) =>
|
||
{
|
||
editor.edit(edit => {
|
||
// let zq = new ZqGenerator();
|
||
let clz = new ZqClass();
|
||
clz.name = filename.replaceAll(' ', '').replaceAll('-', '_');
|
||
clz.instanceKey = InstanceKey.parse(instanceId);
|
||
clz.attributes = [
|
||
new ZqAttribute("name", InstanceKey.parse("4$1"), "text"),
|
||
new ZqAttribute("order", InstanceKey.parse("4$1"), "text")
|
||
];
|
||
clz.relationships = [
|
||
new ZqRelationship("snapshotsSystemName", InstanceKey.parse("3$61051"))
|
||
];
|
||
|
||
clz.functions = [
|
||
new ZqFunctionDefinition(),
|
||
new ZqFunctionDefinition()
|
||
];
|
||
clz.functions[0].name = "getMethodAccessPublicInstance";
|
||
clz.functions[0].isStatic = true;
|
||
clz.functions[0].returnDataType = "AccessModifier";
|
||
clz.functions[0].returnValue = "Public";
|
||
|
||
clz.functions[1].name = "getMostRestrictiveFromSet";
|
||
clz.functions[1].isStatic = true;
|
||
clz.functions[1].isStub = true;
|
||
clz.functions[1].returnDataType = "AccessModifier";
|
||
clz.functions[1].returnValue = "Public";
|
||
|
||
clz.instances = [
|
||
new ZqInstanceReference("Public", InstanceKey.parse("934$102"))
|
||
];
|
||
|
||
edit.delete(new vscode.Range(new vscode.Position(0, 0), new vscode.Position(editor.document.lineCount - 1, editor.document.lineAt(editor.document.lineCount - 1).range.end.character)));
|
||
edit.insert(new vscode.Position(0, 0), clz.toString());
|
||
}).then(success => {
|
||
updateZqEditor(editor);
|
||
});
|
||
});
|
||
});
|
||
}
|
||
|
||
export function openWebBrowser(url: vscode.Uri) {
|
||
|
||
cp.exec("xdg-open " + url.toString(), (err: string, stdout: string, stderr: string) => {
|
||
});
|
||
}
|
||
|
||
// This method is called when your extension is activated
|
||
// Your extension is activated the very first time the command is executed
|
||
export function activate(context: vscode.ExtensionContext) {
|
||
|
||
outputChannel = vscode.window.createOutputChannel("Mocha");
|
||
outputChannel.appendLine("Mocha for VSCode activated");
|
||
|
||
let treeDataProvider = new SuvManagerTreeDataProvider();
|
||
treeSuvManager = vscode.window.createTreeView("mocha.suvManager", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": treeDataProvider });
|
||
treeDataProvider.treeview = treeSuvManager;
|
||
treeSuvManager.badge = { "value": 1, "tooltip": "1 SUV(s) running" };
|
||
|
||
|
||
let treeModuleExplorer = vscode.window.createTreeView("mocha.moduleExplorer", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": dpModuleExplorer });
|
||
// dpModuleExplorer.treeview = treeModuleExplorer;
|
||
// treeModuleExplorer.badge = { "value": 1, "tooltip": "1 SUV(s) running" };
|
||
|
||
updateModuleExplorerTreeView();
|
||
|
||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
||
// This line of code will only be executed once when your extension is activated
|
||
console.log('Congratulations, your extension "suvmanager" is now active!');
|
||
|
||
vscode.commands.registerCommand("mocha.suvmanager.set_selected_item", (item:vscode.TreeItem) => {
|
||
cp.exec('mocha suv status -f csv ' + item.label, (err: string, stdout: string, stderr: string) => {
|
||
let listSuvs = new Array<Machine>();
|
||
let list = stdout.trim().split('\n');
|
||
console.log(list[0]);
|
||
});
|
||
});
|
||
|
||
vscode.commands.registerCommand("mocha.suvmanager.suv_copy_id", (item: Machine) => {
|
||
if (item.name !== undefined) {
|
||
vscode.env.clipboard.writeText(item.name);
|
||
}
|
||
});
|
||
|
||
vscode.commands.registerCommand("mocha.zq_import_function_implementation", () => {
|
||
|
||
let ed = vscode.window.activeTextEditor;
|
||
if (ed !== undefined) {
|
||
if (ed.document.languageId === 'zql') {
|
||
|
||
// thanks https://stackoverflow.com/questions/68342626
|
||
const selection = ed.selection;
|
||
const currentLineRange = ed.document.lineAt(selection.active.line).range;
|
||
const line: string = ed.document.getText(currentLineRange).trim();
|
||
|
||
let c = ZqParser.parse("class Relationship, 1$3 {\n\nattributes:\n name, 4$1 : text\n order, 4$8 : text\n\nrelationships:\n snapshotsBySystemTarget, 3$418926\n\ninstances:\n testRel, 3$112842\n}");
|
||
|
||
let decl = ZqParser.parse(line);
|
||
if (decl !== null) {
|
||
(decl as ZqFunctionDefinition).isStub = false;
|
||
|
||
ed.edit(edit => edit.replace(currentLineRange, decl.toString()));
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
let cmd_zq_import_function_signature = vscode.commands.registerCommand("mocha.zq_import_function_signature", () => {
|
||
/*s
|
||
const rootCas = require('ssl-root-cas').create();
|
||
rootCas.addFile(path.resolve(__dirname, 'localhost.crt'));
|
||
https.globalAgent.options.ca = rootCas;
|
||
let req = https.request({
|
||
"hostname": otsuri.authority,
|
||
"port": 443,
|
||
"path": otsuri.path,
|
||
"method": "GET",
|
||
"headers":
|
||
{
|
||
}
|
||
}, (res) => {
|
||
res.on("data", (chunk) => {
|
||
console.log("BODY: " + chunk);
|
||
});
|
||
res.on("end", () => {
|
||
console.log("end transmission");
|
||
});
|
||
});
|
||
|
||
req.on('error', (e) => {
|
||
console.error(`problem with request: ${e.message}`);
|
||
});
|
||
|
||
req.end();
|
||
|
||
*/
|
||
|
||
vscode.window.showQuickPick([ "Access Modifier@get Access Modifier.for Metadata With Access Modifier(GR)",
|
||
"Access Modifier@get Access Modifiers Effectively Equivalent to A2 Root Acess(GSI)*S",
|
||
"Access Modifier@get Access Modifiers with Override Restrictions(GSI)*S",
|
||
"Access Modifier@get Active Method Accesses(IOP)*S",
|
||
"Access Modifier@get Method Access Public Instance(GSI)*S(public)",
|
||
"Access Modifier@get Methods for Access Modifiers(IOP)*P*S",
|
||
"Access Modifier@get Most Restrictive from Set(SS)*P*S"], { title: "Function name or instance ID"}).then ((choice) =>
|
||
{
|
||
let ed = vscode.window.activeTextEditor;
|
||
if (ed !== undefined)
|
||
{
|
||
ed.edit((edit) => {
|
||
|
||
if (ed !== undefined)
|
||
{
|
||
if (choice !== undefined)
|
||
{
|
||
var ppp = choice.split("@");
|
||
var qqq = ppp[1].replaceAll(" ", "").replaceAll(".", "");
|
||
var xxx = qqq.substring(0, qqq.indexOf('('));
|
||
|
||
let spct: number = ed.selection.start.character;
|
||
edit.insert(ed.selection.active, "/**\n" + indentLines(spct, [
|
||
" formerly known as: " + choice,
|
||
"",
|
||
" @return the Public access modifier",
|
||
" */",
|
||
"static stub function " + xxx + "() : AccessModifier = Public"
|
||
]));
|
||
}
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
});
|
||
|
||
});
|
||
|
||
vscode.commands.registerCommand("mocha.moduleExplorer.module_import_zq_implementation", (item: GenericTreeDataItem) => {
|
||
if (item.customAttributes["instanceId"]) {
|
||
openEditorForInstance(item.title, item.customAttributes["instanceId"]);
|
||
}
|
||
});
|
||
|
||
let cmd_mocha_open_doc = vscode.commands.registerCommand("mocha.zq_open_document", (item : GenericTreeDataItem) => {
|
||
if (item.customAttributes["instanceId"]) {
|
||
openEditorForInstance(item.title, item.customAttributes["instanceId"]);
|
||
}
|
||
});
|
||
|
||
// The command has been defined in the package.json file
|
||
// Now provide the implementation of the command with registerCommand
|
||
// The commandId parameter must match the command field in package.json
|
||
let cmd_suv_manager = vscode.commands.registerCommand('mocha.suvmanager.suv_manager', () => {
|
||
// The code you place here will be executed every time your command is executed
|
||
// Display a message box to the user
|
||
|
||
vscode.window.showInformationMessage('Add code here to display SUV Manager panel!');
|
||
});
|
||
context.subscriptions.push(cmd_suv_manager);
|
||
|
||
let cmd_suv_refresh = vscode.commands.registerCommand('mocha.suvmanager.suv_refresh', () => {
|
||
vscode.window.showInformationMessage('Add code here to display SUV Manager panel!');
|
||
});
|
||
context.subscriptions.push(cmd_suv_refresh);
|
||
|
||
let cmd_suv_show = vscode.commands.registerCommand('mocha.suvmanager.suv_show', (...args) => {
|
||
if (args.length === 0) {
|
||
cp.exec('mocha suv status -f csv', (err: string, stdout: string, stderr: string) => {
|
||
vscode.window.showInformationMessage(stdout);
|
||
let list = stdout.split('\n');
|
||
let list2 = new Array<string>();
|
||
list.forEach((element) => {
|
||
let list3 = element.trim().split(',');
|
||
if (list3[2] === 'running') {
|
||
list2.push(list3[0].trim());
|
||
}
|
||
});
|
||
|
||
var w = vscode.window.showQuickPick(list2, { "title": "Launch SUV", "placeHolder": "Pick an SUV to launch (e.g. i-012345678)" }).then((value) => {
|
||
if (value !== undefined) {
|
||
openWebBrowser(vscode.Uri.parse("https://" + value + ".privatesuv.com"));
|
||
}
|
||
});
|
||
});
|
||
}
|
||
else
|
||
{
|
||
let machine : Machine = args[0] as Machine;
|
||
openWebBrowser(vscode.Uri.parse("https://" + machine.name + ".privatesuv.com"));
|
||
}
|
||
});
|
||
|
||
let cmd_suv_up = vscode.commands.registerCommand('mocha.suvmanager.suv_up', (...args) => {
|
||
if (args.length === 0) {
|
||
cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) => {
|
||
|
||
|
||
vscode.window.showInformationMessage(stdout);
|
||
let list = stdout.split('\n');
|
||
let list2 = new Array<string>();
|
||
list.forEach((element) => {
|
||
list2.push(element.trim());
|
||
});
|
||
|
||
var w = vscode.window.showQuickPick(list2, { "title": "Open SUV in Web Browser", "placeHolder": "Choose an SUV to open" }).then((value) => {
|
||
if (value !== undefined) {
|
||
launchSuv(value);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
else
|
||
{
|
||
let machine : Machine = args[0] as Machine;
|
||
launchSuv(machine.name);
|
||
}
|
||
});
|
||
|
||
statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10);
|
||
statusBarItem.name = "Mocha SUV Manager";
|
||
statusBarItem.tooltip = "Choose preferred SUV";
|
||
statusBarItem.command = "mocha.suvmanager.suv_select";
|
||
// statusBarItem.setText = text => statusBarItem.text = `$(currentSuvId) ${currentSuvId || "(none)"}`;
|
||
// statusBarItem.setText();
|
||
|
||
updateStatusBarText();
|
||
updateStatusBarItemVisibility();
|
||
|
||
let cmd_suv_select = vscode.commands.registerCommand('mocha.suvmanager.suv_select', (...args) => {
|
||
if (args.length === 0) {
|
||
cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) => {
|
||
|
||
|
||
vscode.window.showInformationMessage(stdout);
|
||
let list = stdout.split('\n');
|
||
let list2 = new Array<string>();
|
||
list.forEach((element) => {
|
||
if (element.trim() === "") {
|
||
return;
|
||
}
|
||
|
||
list2.push(element.trim());
|
||
});
|
||
|
||
var w = vscode.window.showQuickPick(list2, { "title": "Select Preferred SUV", "placeHolder": "Choose your preferred SUV" }).then((value) => {
|
||
if (value !== undefined) {
|
||
selectPreferredSuv(value);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
else
|
||
{
|
||
let machine : Machine = args[0] as Machine;
|
||
selectPreferredSuv(machine.name);
|
||
}
|
||
});
|
||
|
||
let cmd_suv_new = vscode.commands.registerCommand('mocha.suvmanager.suv_new', () => {
|
||
outputChannel?.appendLine("Provisioning a new persistent SUV...");
|
||
|
||
cp.exec('mocha suv new --unattended', (err: string, stdout: string, stderr: string) =>
|
||
{
|
||
if (err == null) {
|
||
outputChannel?.appendLine("New SUV provisioned successfully!");
|
||
|
||
vscode.window.showInformationMessage('New SUV provisioned successfully!');
|
||
}
|
||
else {
|
||
outputChannel?.appendLine(err);
|
||
vscode.window.showErrorMessage("SUV provisioning failed. Check the error log for details.", "Show Error Log").then((value) => {
|
||
if (value == "Show Error Log")
|
||
{
|
||
outputChannel?.show();
|
||
}
|
||
});
|
||
}
|
||
treeDataProvider.refresh();
|
||
});
|
||
});
|
||
context.subscriptions.push(cmd_suv_up);
|
||
|
||
const relationshipDecorations: vscode.TextEditorDecorationType[] = [];
|
||
|
||
context.subscriptions.push(vscode.window.onDidChangeTextEditorSelection((e) => {
|
||
if (e.textEditor.document.languageId === "zql") {
|
||
let clz = ZqParser.parse(e.textEditor.document.getText()) as ZqClass;
|
||
if (clz !== null)
|
||
{
|
||
relationshipDecorations.forEach(element => {
|
||
e.textEditor.setDecorations(element, []);
|
||
});
|
||
|
||
clz.relationships.forEach(rel => {
|
||
let n = "";
|
||
let ns = [];
|
||
for (var i = 0; i < rel.name.length; i++) {
|
||
if (i < rel.name.length - 1 && rel.name[i].toUpperCase() === rel.name[i] && rel.name[i + 1].toLowerCase() === rel.name[i + 1]) {
|
||
ns.push(n);
|
||
n = "";
|
||
}
|
||
n += rel.name[i];
|
||
}
|
||
if (n !== "") {
|
||
ns.push(n);
|
||
}
|
||
|
||
let nom = "", rest = "";
|
||
for (var i = 0; i < ns.length; i++) {
|
||
if (i === 0) {
|
||
nom = ns[i];
|
||
}
|
||
else {
|
||
rest += ns[i] + ' ';
|
||
}
|
||
}
|
||
rest = rest.trim();
|
||
|
||
const relationshipDecorationType = vscode.window.createTextEditorDecorationType({
|
||
before:
|
||
{
|
||
contentIconPath: extension?.extensionPath + '/icons/decorations/arrow-both.svg',
|
||
margin: "2px 10px 2px 10px"
|
||
}
|
||
});
|
||
const relationshipDecorationType2 = vscode.window.createTextEditorDecorationType({
|
||
before:
|
||
{
|
||
contentText: nom,
|
||
margin: "0px 4px 0px 4px",
|
||
fontWeight: "bold"
|
||
}
|
||
});
|
||
const relationshipDecorationType3 = vscode.window.createTextEditorDecorationType({
|
||
before:
|
||
{
|
||
contentText: rest,
|
||
margin: "0px 4px 0px 4px",
|
||
color: "#4EC9B0"
|
||
}
|
||
});
|
||
|
||
e.textEditor.setDecorations(relationshipDecorationType, [
|
||
new vscode.Range(rel.definition.lineIndex + 1 /*hack*/, rel.definition.columnIndex + rel.toString().length + 16,
|
||
rel.definition.lineIndex + 1, rel.definition.columnIndex + rel.toString().length + 16)
|
||
]);
|
||
e.textEditor.setDecorations(relationshipDecorationType2, [
|
||
new vscode.Range(rel.definition.lineIndex + 1 /*hack*/, rel.definition.columnIndex + rel.toString().length + 24,
|
||
rel.definition.lineIndex + 1, rel.definition.columnIndex + rel.toString().length + 24)
|
||
]);
|
||
e.textEditor.setDecorations(relationshipDecorationType3, [
|
||
new vscode.Range(rel.definition.lineIndex + 1 /*hack*/, rel.definition.columnIndex + rel.toString().length + 24 + nom.length,
|
||
rel.definition.lineIndex + 1, rel.definition.columnIndex + rel.toString().length + 24 + nom.length)
|
||
]);
|
||
|
||
relationshipDecorations.push(relationshipDecorationType);
|
||
relationshipDecorations.push(relationshipDecorationType2);
|
||
relationshipDecorations.push(relationshipDecorationType3);
|
||
});
|
||
|
||
}
|
||
}
|
||
}));
|
||
|
||
context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor((editor) => {
|
||
if (editor?.document !== undefined) {
|
||
updateZqEditor(editor);
|
||
}
|
||
}));
|
||
}
|
||
|
||
function updateZqEditor(editor: vscode.TextEditor) {
|
||
if (editor?.document.languageId !== 'zql') {
|
||
return;
|
||
}
|
||
|
||
if (editor?.document.getText().startsWith("class ")) {
|
||
addClassDecoration(editor);
|
||
}
|
||
}
|
||
|
||
function addClassDecoration(editor : vscode.TextEditor) {
|
||
const decorations: vscode.DecorationOptions[] = [];
|
||
const myContent = new vscode.MarkdownString(editor?.document.fileName + '\n[Open in Mocha](command:myCommand?arg1)');
|
||
myContent.isTrusted = true;
|
||
|
||
const decoration = { range: new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)), hoverMessage: myContent };
|
||
|
||
decorations.push(decoration);
|
||
editor.setDecorations(classDecorationType, decorations);
|
||
}
|
||
|
||
// This method is called when your extension is deactivated
|
||
export function deactivate() {}
|
||
|
||
|
||
export function selectPreferredSuv(value: string) {
|
||
currentSuvId = value;
|
||
updateStatusBarText();
|
||
|
||
updateModuleExplorerTreeView();
|
||
}
|
||
|
||
function indentLines(count: number, lines: string[]): string {
|
||
let indent: string = " ".repeat(count);
|
||
let retval: string = "";
|
||
lines.forEach(line => {
|
||
retval += indent + line + "\n";
|
||
});
|
||
retval += indent;
|
||
return retval;
|
||
}
|
||
/*
|
||
|
||
// This method is called when your extension is activated
|
||
// Your extension is activated the very first time the command is executed
|
||
export function activate(context: vscode.ExtensionContext) {
|
||
|
||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
||
// This line of code will only be executed once when your extension is activated
|
||
console.log('Blah blah the blah blah!');
|
||
|
||
// The command has been defined in the package.json file
|
||
// Now provide the implementation of the command with registerCommand
|
||
// The commandId parameter must match the command field in package.json
|
||
const disposable = vscode.commands.registerCommand('mocha-vscode.helloWorld', () => {
|
||
// The code you place here will be executed every time your command is executed
|
||
// Display a message box to the user
|
||
vscode.window.showInformationMessage('Blah blah the blah blah!');
|
||
});
|
||
|
||
context.subscriptions.push(disposable);
|
||
}
|
||
|
||
// This method is called when your extension is deactivated
|
||
export function deactivate() {}
|
||
*/ |