forked from codefori/vscode-ibmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Instance.js
61 lines (53 loc) · 1.74 KB
/
Instance.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const IBMi = require("./api/IBMi");
const IBMiContent = require("./api/IBMiContent");
const vscode = require('vscode');
module.exports = class {
static setConnection(conn) {
instance.connection = conn;
instance.content = new IBMiContent(instance.connection);
};
static getConnection() {return instance.connection};
static getContent() {return instance.content};
/**
* We call this after we have made a connect to the IBM i to load the rest of the plugin in.
* @param {vscode.ExtensionContext} context
*/
static loadAllofExtension(context) {
const memberBrowser = require('./views/memberBrowser');
const qsysFs = new (require('./views/qsysFs'));
if (instance.connection) {
context.subscriptions.push(
vscode.window.registerTreeDataProvider(
'memberBrowser',
new memberBrowser(context)
));
context.subscriptions.push(
vscode.workspace.registerFileSystemProvider('member', qsysFs, {
isCaseSensitive: false
})
);
context.subscriptions.push(
vscode.commands.registerCommand('code-for-ibmi.openEditable', async (path) => {
console.log(path);
if (path.startsWith('/')) {
//IFS
} else {
let uri = vscode.Uri.parse(path.toLowerCase()).with({scheme: 'member'});
try {
let doc = await vscode.workspace.openTextDocument(uri); // calls back into the provider
await vscode.window.showTextDocument(doc, { preview: false });
} catch (e) {
console.log(e);
}
}
})
);
}
}
};
var instance = {
/** @type {IBMi} */
connection: undefined,
/** @type {IBMiContent} */
content: undefined, //IBM
};