forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextensionInit.ts
More file actions
43 lines (33 loc) · 1.83 KB
/
extensionInit.ts
File metadata and controls
43 lines (33 loc) · 1.83 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
// tslint:disable:max-func-body-length
import { Container } from 'inversify';
import { Disposable, Memento } from 'vscode';
import { GLOBAL_MEMENTO, IDisposableRegistry, IExtensionContext, IMemento, WORKSPACE_MEMENTO } from './common/types';
import { ServiceContainer } from './ioc/container';
import { ServiceManager } from './ioc/serviceManager';
import { IServiceContainer, IServiceManager } from './ioc/types';
// The code in this module should do nothing more complex than register
// objects to DI and simple init (e.g. no side effects). That implies
// that constructors are likewise simple and do no work. It also means
// that it is inherently synchronous.
export function initializeGlobals(context: IExtensionContext): [IServiceManager, IServiceContainer] {
const cont = new Container();
const serviceManager = new ServiceManager(cont);
const serviceContainer = new ServiceContainer(cont);
serviceManager.addSingletonInstance<IServiceContainer>(IServiceContainer, serviceContainer);
serviceManager.addSingletonInstance<IServiceManager>(IServiceManager, serviceManager);
serviceManager.addSingletonInstance<Disposable[]>(IDisposableRegistry, context.subscriptions);
serviceManager.addSingletonInstance<Memento>(IMemento, context.globalState, GLOBAL_MEMENTO);
serviceManager.addSingletonInstance<Memento>(IMemento, context.workspaceState, WORKSPACE_MEMENTO);
serviceManager.addSingletonInstance<IExtensionContext>(IExtensionContext, context);
return [serviceManager, serviceContainer];
}
export function initializeComponents(
_context: IExtensionContext,
_serviceManager: IServiceManager,
_serviceContainer: IServiceContainer
) {
// We will be pulling code over from activateLegacy().
}