-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathextension.ts
More file actions
153 lines (134 loc) Β· 6.15 KB
/
extension.ts
File metadata and controls
153 lines (134 loc) Β· 6.15 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// The module 'vscode' contains the VS Code extensibility API
import { commands, ExtensionContext, 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
import path from "path";
import IBMi from "./api/IBMi";
import { SearchTools } from "./api/SearchTools";
import { extensionComponentRegistry } from "./api/components/manager";
import { Mapepire } from "./api/components/mapepire";
import { sshSqlJob } from "./api/components/mapepire/sqlJob";
import { parseErrors } from "./api/errors/parser";
import { CustomCLI } from "./api/tests/components/customCli";
import { onCodeForIBMiConfigurationChange } from "./config/Configuration";
import * as Debug from './debug';
import { CustomEditor, CustomEditorProvider } from "./editors/customEditorProvider";
import { IFSFS } from "./filesystems/ifsFs";
import { DeployTools } from "./filesystems/local/deployTools";
import { Deployment } from "./filesystems/local/deployment";
import { handleEditorsLeftOpened } from "./filesystems/qsys/FSUtils";
import { instance, loadAllofExtension } from './instantiate';
import { LocalActionCompletionItemProvider } from "./languages/actions/completion";
import { mergeCommandProfiles } from "./mergeProfiles";
import { initialise } from "./testing";
import { CodeForIBMi } from "./typings";
import { VscodeTools } from "./ui/Tools";
import { registerActionTools } from "./ui/actions";
import { initializeConnectionBrowser } from "./ui/views/ConnectionBrowser";
import { initializeLibraryListView } from "./ui/views/LibraryListView";
import { initializeDebugBrowser } from "./ui/views/debugView";
import { initializeEnvironmentView } from "./ui/views/environment/environmentView";
import { HelpView } from "./ui/views/helpView";
import { initializeIFSBrowser } from "./ui/views/ifsBrowser";
import { initializeObjectBrowser } from "./ui/views/objectBrowser";
import { initializeSearchView } from "./ui/views/searchView";
import { registerURIHandler } from "./uri";
import { openURIHandler } from "./uri/handlers/open";
import { initializeSandbox, sandboxURIHandler } from "./uri/handlers/sandbox";
import { CustomUI } from "./webviews/CustomUI";
import { SettingsUI } from "./webviews/settings";
import { ActionTools } from "./api/actions";
export async function activate(context: ExtensionContext): Promise<CodeForIBMi> {
// 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 "code-for-ibmi" is now active!`);
sshSqlJob.application = `${context.extension.packageJSON.name} ${context.extension.packageJSON.version}`;
await loadAllofExtension(context);
const updateLastConnectionAndServerCache = () => {
const connections = IBMi.connectionManager.getAll();
const lastConnections = (IBMi.GlobalStorage.getLastConnections() || []).filter(lc => connections.find(c => c.name === lc.name));
IBMi.GlobalStorage.setLastConnections(lastConnections);
commands.executeCommand(`setContext`, `code-for-ibmi:hasPreviousConnection`, lastConnections.length > 0);
IBMi.GlobalStorage.deleteStaleServerSettingsCache(connections);
commands.executeCommand(`code-for-ibmi.refreshConnections`);
};
SettingsUI.init(context);
initializeConnectionBrowser(context);
initializeObjectBrowser(context)
initializeIFSBrowser(context);
initializeDebugBrowser(context);
initializeSearchView(context);
initializeLibraryListView(context);
initializeEnvironmentView(context);
context.subscriptions.push(
window.registerTreeDataProvider(
`helpView`,
new HelpView(context)
),
onCodeForIBMiConfigurationChange("connections", updateLastConnectionAndServerCache),
onCodeForIBMiConfigurationChange("connectionSettings", async () => {
const connection = instance.getConnection();
if (connection) {
const config = connection.getConfig();
if (config) {
Object.assign(config, (await IBMi.connectionManager.load(config.name)));
}
}
}),
workspace.registerFileSystemProvider(`streamfile`, new IFSFS(), {
isCaseSensitive: false
}),
languages.registerCompletionItemProvider({ language: 'json', pattern: "**/.vscode/actions.json" }, new LocalActionCompletionItemProvider(), "&"),
window.registerCustomEditorProvider(`code-for-ibmi.editor`, new CustomEditorProvider(), {
webviewOptions: {
retainContextWhenHidden: true
}
})
);
registerActionTools(context);
Debug.initialize(context);
Deployment.initialize(context);
updateLastConnectionAndServerCache();
initializeSandbox();
console.log(`Developer environment: ${process.env.DEV}`);
if (process.env.DEV) {
// Run tests if not in production build
initialise(context);
// Test user-component
extensionComponentRegistry.registerComponent(context, new CustomCLI());
}
instance.subscribe(
context,
'connected',
`Refresh views`,
() => {
commands.executeCommand("code-for-ibmi.refreshObjectBrowser");
commands.executeCommand("code-for-ibmi.refreshLibraryListView");
commands.executeCommand("code-for-ibmi.refreshIFSBrowser");
commands.executeCommand("code-for-ibmi.environment.refresh");
});
const mapepire = new Mapepire(path.join(context.extensionPath, `dist`));
extensionComponentRegistry.registerComponent(context, mapepire);
registerURIHandler(context,
sandboxURIHandler,
openURIHandler
);
await mergeCommandProfiles();
handleEditorsLeftOpened(context);
return {
instance,
customUI: () => new CustomUI(),
customEditor: (target, onSave, onClosed) => new CustomEditor(target, onSave, onClosed),
evfeventParser: parseErrors,
tools: VscodeTools,
deployTools: DeployTools,
actionTools: ActionTools,
componentRegistry: extensionComponentRegistry,
connectionManager: IBMi.connectionManager,
searchTools: SearchTools
};
}
// this method is called when your extension is deactivated
export async function deactivate() {
await commands.executeCommand(`code-for-ibmi.disconnect`, true);
}